get_cache_stats
Retrieve statistics on the MTA:SA documentation cache, including cache size and hit rates. Use it to monitor cache performance and verify data freshness.
Instructions
Get statistics about the MTA:SA documentation cache.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:604-625 (handler)The handler function that executes the get_cache_stats tool logic. It queries the database for document count and database size, then returns cache statistics including file path and cache duration.
async (): Promise<CallToolResult> => { const count = queries.countDocs().get() as { count: number }; const dbStats = db .prepare( "SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()", ) .get() as { size: number }; return { content: [ { type: "text", text: `# Cache Statistics\n\n` + `- Cached MTA:SA docs: ${count.count}\n` + `- Database size: ${(dbStats.size / 1024 / 1024).toFixed(2)} MB\n` + `- Database path: ${DB_PATH}\n` + `- Cache duration: ${CACHE_DURATION / 1000 / 60 / 60 / 24} days`, }, ], }; }, - src/index.ts:597-626 (registration)Tool registration for get_cache_stats using server.registerTool() with inputSchema set to empty object (no inputs required).
// Register tool: get_cache_stats server.registerTool( "get_cache_stats", { description: "Get statistics about the MTA:SA documentation cache.", inputSchema: {}, }, async (): Promise<CallToolResult> => { const count = queries.countDocs().get() as { count: number }; const dbStats = db .prepare( "SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()", ) .get() as { size: number }; return { content: [ { type: "text", text: `# Cache Statistics\n\n` + `- Cached MTA:SA docs: ${count.count}\n` + `- Database size: ${(dbStats.size / 1024 / 1024).toFixed(2)} MB\n` + `- Database path: ${DB_PATH}\n` + `- Cache duration: ${CACHE_DURATION / 1000 / 60 / 60 / 24} days`, }, ], }; }, ); - src/index.ts:600-603 (schema)Input schema for get_cache_stats - an empty object since the tool takes no arguments.
{ description: "Get statistics about the MTA:SA documentation cache.", inputSchema: {}, }, - src/database/queries.ts:114-117 (helper)The countDocs query used by the handler to count documents in the function_docs table.
countDocs: () => db.prepare(` SELECT COUNT(*) as count FROM function_docs `), - src/config/constants.ts:16-22 (helper)Constants file providing DB_PATH (temporary directory path) and CACHE_DURATION (30 days) used in the handler's output message.
export const DB_PATH = path.join( os.tmpdir(), "mtasa-mcp-cache", "mtasa_docs.db", ); export const CACHE_DURATION = 30 * 24 * 60 * 60 * 1000; // 30 days