cache-get-config
Retrieve current cache configuration settings for Xcode CLI operations in XC-MCP, enabling efficient management of simulator, project, or response caches.
Instructions
Get current cache configuration settings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cacheType | No | Which cache configuration to retrieve | all |
Implementation Reference
- src/tools/cache/get-config.ts:65-126 (handler)The core handler function `getCacheConfigTool` implementing the `cache-get-config` tool logic. Retrieves current cache retention configuration for specified cache types (simulator, project, response) and formats output with human-readable durations.export async function getCacheConfigTool(args: any): Promise<ToolResult> { try { const { cacheType = 'all' } = args as GetCacheConfigArgs; if (!['simulator', 'project', 'response', 'all'].includes(cacheType)) { throw new McpError( ErrorCode.InvalidParams, 'cacheType must be one of: simulator, project, response, all' ); } const config: Record<string, any> = {}; if (cacheType === 'simulator' || cacheType === 'all') { const maxAge = simulatorCache.getCacheMaxAge(); config.simulator = { maxAgeMs: maxAge, maxAgeHuman: formatDuration(maxAge), }; } if (cacheType === 'project' || cacheType === 'all') { const maxAge = projectCache.getCacheMaxAge(); config.project = { maxAgeMs: maxAge, maxAgeHuman: formatDuration(maxAge), }; } if (cacheType === 'response' || cacheType === 'all') { config.response = { maxAgeMs: 30 * 60 * 1000, // Fixed 30 minutes maxAgeHuman: '30m', note: 'Response cache duration is currently fixed', }; } return { content: [ { type: 'text' as const, text: JSON.stringify( { cacheConfiguration: config, timestamp: new Date().toISOString(), }, null, 2 ), }, ], }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Failed to get cache config: ${error instanceof Error ? error.message : String(error)}` ); } }
- Helper function `formatDuration` converts milliseconds to human-readable time strings (e.g., '1h 30m') used in the cache configuration output.function formatDuration(ms: number): string { const seconds = Math.floor(ms / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); if (days > 0) return `${days}d ${hours % 24}h`; if (hours > 0) return `${hours}h ${minutes % 60}m`; if (minutes > 0) return `${minutes}m ${seconds % 60}s`; return `${seconds}s`; }
- src/registry/cache.ts:24-32 (schema)Input schema validation for the consolidated `cache` tool, which includes `get-config` operation with `cacheType` parameter validation using Zod.inputSchema: { operation: z.enum(['get-stats', 'get-config', 'set-config', 'clear']), cacheType: z.enum(['simulator', 'project', 'response', 'all']).optional(), maxAgeMs: z.number().optional(), maxAgeMinutes: z.number().optional(), maxAgeHours: z.number().optional(), }, ...DEFER_LOADING_CONFIG, },
- src/registry/cache.ts:20-46 (registration)MCP server registration of the `cache` tool, which dispatches `get-config` operations to the `cache-get-config` implementation via `cacheTool` router.server.registerTool( 'cache', { description: getDescription(CACHE_DOCS, CACHE_DOCS_MINI), inputSchema: { operation: z.enum(['get-stats', 'get-config', 'set-config', 'clear']), cacheType: z.enum(['simulator', 'project', 'response', 'all']).optional(), maxAgeMs: z.number().optional(), maxAgeMinutes: z.number().optional(), maxAgeHours: z.number().optional(), }, ...DEFER_LOADING_CONFIG, }, async args => { try { await validateXcodeInstallation(); // eslint-disable-next-line @typescript-eslint/no-explicit-any return (await cacheTool(args)) as any; } catch (error) { if (error instanceof McpError) throw error; throw new McpError( ErrorCode.InternalError, `Tool execution failed: ${error instanceof Error ? error.message : String(error)}` ); } } );
- src/tools/cache/index.ts:60-98 (helper)Router function `routeOperation` in consolidated `cacheTool` that dispatches 'get-config' operation to `getCacheConfigTool`.async function routeOperation(args: CacheToolArgs) { const { operation } = args; switch (operation) { case 'get-stats': return getCacheStatsTool({}); case 'get-config': if (!args.cacheType) { throw new McpError( ErrorCode.InvalidRequest, 'cacheType is required for get-config operation' ); } return getCacheConfigTool({ cacheType: args.cacheType }); case 'set-config': if (!args.cacheType) { throw new McpError( ErrorCode.InvalidRequest, 'cacheType is required for set-config operation' ); } return setCacheConfigTool({ cacheType: args.cacheType, maxAgeMs: args.maxAgeMs, maxAgeMinutes: args.maxAgeMinutes, maxAgeHours: args.maxAgeHours, }); case 'clear': if (!args.cacheType) { throw new McpError(ErrorCode.InvalidRequest, 'cacheType is required for clear operation'); } return clearCacheTool({ cacheType: args.cacheType }); default: throw new McpError( ErrorCode.InvalidRequest, `Unknown operation: ${operation}. Valid operations: get-stats, get-config, set-config, clear` ); } }