clear-cache
Clear cached data on the CCXT MCP Server to ensure up-to-date cryptocurrency exchange integration and optimal performance.
Instructions
Clear CCXT cache
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {},
"type": "object"
}
Implementation Reference
- src/index.ts:163-171 (handler)The MCP tool handler for 'clear-cache'. Calls clearCache() from utils/cache and returns a success message.server.tool("clear-cache", "Clear CCXT cache", {}, async () => { clearCache(); return { content: [{ type: "text", text: "Cache cleared successfully." }] }; });
- src/utils/cache.ts:108-133 (helper)Core implementation of cache clearing logic. When called without arguments (as in the tool handler), clears the entire LRU cache, resets statistics, and logs the action.export function clearCache(keyPattern?: string): void { if (keyPattern) { // Clear all keys matching specific pattern const keys = []; for (const key of dataCache.keys()) { if (typeof key === 'string' && key.includes(keyPattern)) { keys.push(key); } } // Delete all matching keys from cache keys.forEach(key => dataCache.delete(key)); log(LogLevel.INFO, `Cleared ${keys.length} cache items matching "${keyPattern}"`); } else { // Clear entire cache const size = dataCache.size; dataCache.clear(); log(LogLevel.INFO, `Cleared all ${size} cache items`); } // Update cache statistics cacheStats.size = dataCache.size; cacheStats.lastCleared = new Date().toISOString(); cacheStats.hits = 0; cacheStats.misses = 0; }
- src/index.ts:163-171 (registration)Registers the 'clear-cache' tool on the MCP server with empty schema and description 'Clear CCXT cache'.server.tool("clear-cache", "Clear CCXT cache", {}, async () => { clearCache(); return { content: [{ type: "text", text: "Cache cleared successfully." }] }; });