get_cache_stats
Retrieve statistics about cached data to monitor usage and optimize token efficiency in the Memory Cache MCP Server.
Instructions
Get cache statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:230-240 (handler)MCP tool handler for 'get_cache_stats': retrieves statistics from CacheManager instance and returns them as a formatted JSON text response.case 'get_cache_stats': { const stats = this.cacheManager.getStats(); return { content: [ { type: 'text', text: JSON.stringify(stats, null, 2), }, ], }; }
- src/index.ts:149-155 (schema)Schema definition for the 'get_cache_stats' tool, specifying name, description, and empty input schema (no parameters required).name: 'get_cache_stats', description: 'Get cache statistics', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:98-157 (registration)Registration of available tools including 'get_cache_stats' in the ListToolsRequestSchema handler.tools: [ { name: 'store_data', description: 'Store data in the cache with optional TTL', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Unique identifier for the cached data', }, value: { type: 'any', description: 'Data to cache', }, ttl: { type: 'number', description: 'Time-to-live in seconds (optional)', }, }, required: ['key', 'value'], }, }, { name: 'retrieve_data', description: 'Retrieve data from the cache', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Key of the cached data to retrieve', }, }, required: ['key'], }, }, { name: 'clear_cache', description: 'Clear specific or all cache entries', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Specific key to clear (optional - clears all if not provided)', }, }, }, }, { name: 'get_cache_stats', description: 'Get cache statistics', inputSchema: { type: 'object', properties: {}, }, }, ], }));
- src/CacheManager.ts:107-109 (helper)Core implementation of cache statistics retrieval: returns a shallow copy of the internal stats object containing metrics like totalEntries, memoryUsage, hitRate, etc.getStats(): CacheStats { return { ...this.stats }; }