MCPcopy Create free account
hub / github.com/Accenture/mcp-bench / _init_db

Method _init_db

mcp_modules/tool_cache.py:63–83  ·  view source on GitHub ↗

Initialize SQLite database

(self)

Source from the content-addressed store, hash-verified

61 return self.local.conn
62
63 def _init_db(self):
64 """Initialize SQLite database"""
65 conn = sqlite3.connect(str(self.db_path), timeout=30.0)
66 try:
67 conn.execute('PRAGMA journal_mode=WAL')
68 conn.execute('''
69 CREATE TABLE IF NOT EXISTS cache (
70 cache_key TEXT PRIMARY KEY,
71 server_name TEXT NOT NULL,
72 tool_name TEXT NOT NULL,
73 params TEXT NOT NULL,
74 result TEXT NOT NULL,
75 timestamp REAL NOT NULL,
76 access_count INTEGER DEFAULT 1
77 )
78 ''')
79 conn.execute('CREATE INDEX IF NOT EXISTS idx_timestamp ON cache(timestamp)')
80 conn.execute('CREATE INDEX IF NOT EXISTS idx_server_tool ON cache(server_name, tool_name)')
81 conn.commit()
82 finally:
83 conn.close()
84
85 def _generate_cache_key(self, server_name: str, tool_name: str, params: Dict[str, Any]) -> str:
86 """

Callers 1

__init__Method · 0.95

Calls 3

connectMethod · 0.80
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected