Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

cache-set-config

Adjust cache timeout settings in XC-MCP to optimize performance, control data freshness, and manage memory usage. Tailor cache duration for simulators, projects, or all caches to suit development or CI workflows.

Instructions

šŸŽ›ļø Cache Optimization - Fine-tune XC-MCP's intelligent caching for your workflow.

Why manage caching: • ⚔ Performance tuning - Longer caches = faster repeated operations • šŸ”„ Fresh data control - Shorter caches = more up-to-date information
• šŸ’¾ Memory management - Balance speed vs memory usage • šŸŽÆ Workflow optimization - Different cache settings for development vs CI

Configure cache maximum age settings. Default is 1 hour for simulator and project caches.

Examples:

  • Set 30 minutes: {"cacheType": "all", "maxAgeMinutes": 30}

  • Set 2 hours for simulators: {"cacheType": "simulator", "maxAgeHours": 2}

  • Set 5 minutes: {"cacheType": "project", "maxAgeMinutes": 5}

Common Workflow:

  1. cache-get-stats → check current cache status

  2. cache-set-config → adjust cache timeouts

  3. cache-clear → force refresh when needed

  4. Your normal xcodebuild/simctl operations (now faster!)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cacheTypeYesWhich cache to configure
maxAgeHoursNoMaximum cache age in hours (alternative to maxAgeMs)
maxAgeMinutesNoMaximum cache age in minutes (alternative to maxAgeMs)
maxAgeMsNoMaximum cache age in milliseconds

Implementation Reference

  • The core handler function that implements the logic for the 'cache-set-config' tool. It validates input parameters, calculates max age in milliseconds from various units, updates cache max ages for specified cache types, and returns a formatted JSON response with results.
    export async function setCacheConfigTool(args: any): Promise<ToolResult> {
      try {
        const { cacheType, maxAgeMs, maxAgeMinutes, maxAgeHours } = args as SetCacheConfigArgs;
    
        if (!['simulator', 'project', 'response', 'all'].includes(cacheType)) {
          throw new McpError(
            ErrorCode.InvalidParams,
            'cacheType must be one of: simulator, project, response, all'
          );
        }
    
        // Calculate max age in milliseconds
        let maxAge: number;
        if (maxAgeMs !== undefined) {
          maxAge = maxAgeMs;
        } else if (maxAgeMinutes !== undefined) {
          maxAge = maxAgeMinutes * 60 * 1000;
        } else if (maxAgeHours !== undefined) {
          maxAge = maxAgeHours * 60 * 60 * 1000;
        } else {
          throw new McpError(
            ErrorCode.InvalidParams,
            'Must specify one of: maxAgeMs, maxAgeMinutes, or maxAgeHours'
          );
        }
    
        if (maxAge < 1000) {
          throw new McpError(
            ErrorCode.InvalidParams,
            'Cache max age must be at least 1000ms (1 second)'
          );
        }
    
        const results: Record<string, string> = {};
    
        if (cacheType === 'simulator' || cacheType === 'all') {
          simulatorCache.setCacheMaxAge(maxAge);
          results.simulator = `Set to ${formatDuration(maxAge)}`;
        }
    
        if (cacheType === 'project' || cacheType === 'all') {
          projectCache.setCacheMaxAge(maxAge);
          results.project = `Set to ${formatDuration(maxAge)}`;
        }
    
        if (cacheType === 'response' || cacheType === 'all') {
          // Note: responseCache doesn't have setCacheMaxAge yet, we'd need to implement it
          results.response = 'Response cache config is fixed at 30 minutes';
        }
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  message: 'Cache configuration updated',
                  results,
                  timestamp: new Date().toISOString(),
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to set cache config: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • TypeScript interface defining the expected input arguments for the cache-set-config tool handler.
    interface SetCacheConfigArgs {
      cacheType: 'simulator' | 'project' | 'response' | 'all';
      maxAgeMs?: number;
      maxAgeMinutes?: number;
      maxAgeHours?: number;
    }
  • Utility function used by the handler to convert milliseconds to a human-readable duration string.
    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`;
    }
  • Dispatcher logic in the consolidated 'cache' tool that routes 'set-config' operation to the setCacheConfigTool handler.
    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,
      });
  • Registration of the consolidated 'cache' tool, which includes the 'set-config' operation (backwards compatible with 'cache-set-config'). Includes Zod input schema validation for all cache operations.
    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)}`
          );
        }
      }
    );
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool configures cache settings (implying mutation) and mentions default values (1 hour for simulator and project caches), which adds useful context. However, it lacks details on permissions, side effects, or error handling, leaving behavioral gaps for a mutation tool.

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

Conciseness4/5

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

The description is well-structured with sections (Why manage caching, Examples, Common Workflow) and uses bullet points and emojis for readability. However, it includes some promotional language (e.g., 'now faster!') and could be more streamlined by focusing strictly on tool functionality rather than general benefits.

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

Completeness4/5

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

Given no annotations and no output schema, the description does a good job covering purpose, usage, and examples. It addresses the tool's role in a workflow and provides practical guidance. However, it lacks details on return values or error cases, which would enhance completeness for a mutation tool.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by providing examples (e.g., using maxAgeMinutes vs. maxAgeHours) and mentioning cacheType options, but it doesn't explain parameter interactions or constraints not in the schema. Baseline 3 is appropriate given high schema coverage.

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

Purpose5/5

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

The description explicitly states the tool's purpose as 'Configure cache maximum age settings' and distinguishes it from siblings like cache-get-stats and cache-clear by explaining its specific role in the workflow. It provides a clear verb ('configure') and resource ('cache maximum age settings').

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

Usage Guidelines5/5

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

The description includes explicit guidance on when to use this tool in the 'Common Workflow' section, positioning it after cache-get-stats and before cache-clear. It also explains why to manage caching (e.g., performance tuning, fresh data control), which helps the agent decide when this tool is appropriate versus alternatives.

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