Skip to main content
Glama
conorluddy

XC-MCP: XCode CLI wrapper

by conorluddy

persistence-enable

Enable file-based persistence for Xcode CLI tool cache data, improving workflow efficiency by retaining build configurations, simulator preferences, and usage patterns across server restarts.

Instructions

šŸ”’ Enable Opt-in Persistent State Management - File-based persistence for cache data across server restarts.

Privacy First: Disabled by default. Only usage patterns, build preferences, and performance metrics are stored. No source code, credentials, or personal information is persisted.

Key Benefits: • šŸ“ˆ Learns Over Time - Remembers successful build configurations and simulator preferences • šŸš€ Faster Workflows - Cached project information and usage patterns persist across restarts • šŸ¤ Team Sharing - Project-local caching allows teams to benefit from shared optimizations • šŸ’¾ CI/CD Friendly - Maintains performance insights across build environments

Storage Location Priority:

  1. User-specified directory (cacheDir parameter)

  2. Environment variable: XC_MCP_CACHE_DIR

  3. XDG cache directory (Linux/macOS standard)

  4. Project-local: .xc-mcp/cache/

  5. User home: ~/.xc-mcp/cache/

  6. System temp (fallback)

The system automatically selects the first writable location and creates proper .gitignore entries to prevent accidental commits.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cacheDirNoOptional custom directory for cache storage. If not provided, uses intelligent location selection.

Implementation Reference

  • The primary handler function that implements the persistence-enable tool logic. It checks if already enabled, calls persistenceManager.enable(), and returns formatted JSON response with status and privacy info.
    export async function persistenceEnableTool(args: any): Promise<ToolResult> {
      try {
        const { cacheDir } = args as PersistenceEnableArgs;
    
        if (persistenceManager.isEnabled()) {
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(
                  {
                    success: false,
                    message: 'Persistence is already enabled',
                    currentStatus: await persistenceManager.getStatus(),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
    
        const result = await persistenceManager.enable(cacheDir);
    
        if (result.success) {
          const status = await persistenceManager.getStatus(true);
    
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(
                  {
                    success: true,
                    message: result.message,
                    cacheDirectory: result.cacheDir,
                    status,
                    privacyNotice:
                      'Only usage patterns, build preferences, and performance metrics are stored. No source code, credentials, or personal information is persisted.',
                    nextSteps: [
                      'State will now persist across server restarts',
                      'Use "persistence-status" to monitor storage usage',
                      'Use "persistence-disable" to turn off persistence',
                    ],
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } else {
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to enable persistence: ${result.message}`
          );
        }
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to enable persistence: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Type definition for input arguments to the persistenceEnableTool handler.
    interface PersistenceEnableArgs {
      cacheDir?: string;
    }
  • Core PersistenceManager.enable() method that performs the actual file system operations to enable persistence: selects storage location, creates directories, marker files, gitignore, and version file.
    async enable(
      userCacheDir?: string
    ): Promise<{ success: boolean; cacheDir: string; message?: string }> {
      try {
        const selectedDir = await this.determineStorageLocation(userCacheDir);
    
        // Ensure directory exists and is writable
        if (!(await this.ensureDirectoryWritable(selectedDir))) {
          return {
            success: false,
            cacheDir: selectedDir,
            message: 'Directory is not writable',
          };
        }
    
        this.cacheDir = selectedDir;
        this.enabled = true;
    
        // Create directory structure
        await this.createDirectoryStructure();
    
        // Create .gitignore if needed
        await this.ensureGitignore();
    
        // Create version file
        await this.writeVersionFile();
    
        return {
          success: true,
          cacheDir: selectedDir,
          message: 'Persistence enabled successfully',
        };
      } catch (error) {
        return {
          success: false,
          cacheDir: userCacheDir || 'unknown',
          message: `Failed to enable persistence: ${error instanceof Error ? error.message : String(error)}`,
        };
      }
    }
  • Routing logic in consolidated 'persistence' tool that dispatches 'enable' operation to persistenceEnableTool.
    case 'enable':
      if (!args.cacheDir) {
        throw new McpError(ErrorCode.InvalidRequest, 'cacheDir is required for enable operation');
      }
      return persistenceEnableTool({ cacheDir: args.cacheDir });
    case 'disable':
      return persistenceDisableTool({ clearData: args.clearData ?? false });
    case 'status':
      return persistenceStatusTool({ includeStorageInfo: args.includeStorageInfo ?? true });
    default:
  • MCP server registration of the consolidated 'persistence' tool, which routes 'enable' to the persistence-enable implementation. Note: 'persistence-enable' appears in docs for backwards compatibility but is not separately registered.
      server.registerTool(
        'persistence',
        {
          description: getDescription(PERSISTENCE_DOCS, PERSISTENCE_DOCS_MINI),
          inputSchema: {
            operation: z.enum(['enable', 'disable', 'status']),
            cacheDir: z.string().optional(),
            clearData: z.boolean().default(false),
            includeStorageInfo: z.boolean().default(true),
          },
          ...DEFER_LOADING_CONFIG,
        },
        async args => {
          try {
            await validateXcodeInstallation();
            // eslint-disable-next-line @typescript-eslint/no-explicit-any
            return (await persistenceTool(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)}`
            );
          }
        }
      );
    }
Behavior4/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 does an excellent job describing what gets persisted (usage patterns, build preferences, performance metrics) and what doesn't (source code, credentials, personal information). It explains storage location priority and automatic selection logic. It mentions the system creates .gitignore entries, which is valuable behavioral context. The only minor gap is not explicitly stating this is a configuration/mutation operation rather than a read operation.

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 clear sections (Privacy First, Key Benefits, Storage Location Priority) and uses bullet points effectively. While slightly longer than minimal, every section adds value. The emoji/icons help visual organization but don't replace substantive content. The information is front-loaded with the core purpose stated first.

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?

For a configuration tool with no annotations and no output schema, the description provides comprehensive context about what the tool does, what data is persisted, storage behavior, and benefits. It covers the behavioral aspects well. The main gap is not explicitly describing the return value or confirmation of successful enabling, which would be helpful since there's no output schema.

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

Parameters4/5

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

The schema has 100% description coverage for its single parameter (cacheDir), so the baseline is 3. The description adds meaningful context by explaining the storage location priority system, where the cacheDir parameter fits as the first priority option. This provides valuable semantic understanding beyond the schema's technical description of the parameter.

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 clearly states the tool's purpose: enabling file-based persistence for cache data across server restarts. It specifies the exact functionality (opt-in persistent state management) and distinguishes it from sibling tools like persistence-disable and persistence-status, which handle disabling and checking status respectively.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool: to enable opt-in persistence for caching across restarts. It mentions it's disabled by default, implying this should be used when persistence is desired. However, it doesn't explicitly contrast when to use this versus alternatives like persistence-disable or when persistence might not be appropriate.

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