Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

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
NameRequiredDescriptionDefault
cacheTypeNoWhich cache configuration to retrieveall

Implementation Reference

  • 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`;
    }
  • 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,
    },
  • 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)}`
          );
        }
      }
    );
  • 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`
          );
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a 'Get' operation but doesn't mention whether it requires permissions, what format the configuration returns, or if there are any side effects. For a configuration tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without any wasted words. It's appropriately sized for a simple configuration retrieval tool and gets straight to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only configuration tool with good schema coverage but no annotations or output schema, the description is minimally adequate. It states what the tool does but lacks important context about return format, permissions, and differentiation from sibling tools, leaving room for improvement.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'cacheType' well-documented with enum values and a default. The description doesn't add any parameter semantics beyond what the schema already provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'current cache configuration settings', making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'cache-get-stats' or 'cache-set-config', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'cache-get-stats' or 'cache-set-config'. It doesn't mention prerequisites, timing considerations, or any context for choosing this specific configuration retrieval tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/conorluddy/xc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server