Skip to main content
Glama
ebowwa

Xcode MCP Server

by ebowwa

xcode_read_file

Read file contents within Xcode projects to access code, configuration, or resource files for development tasks.

Instructions

Read contents of a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the file to read

Implementation Reference

  • The core handler function that executes the file reading logic using Node.js fs.readFile. This is the exact implementation that reads the file contents for the xcode_read_file tool.
    async readFile(filePath: string): Promise<string> {
      return await fs.readFile(filePath, 'utf-8');
    }
  • Handler in executeInternalCommand that processes the 'read_file' internal command by calling fileManager.readFile with the provided file_path argument.
    case 'read_file':
      output = await this.fileManager.readFile(args.file_path);
      break;
  • src/index.ts:91-171 (registration)
    MCP CallTool request handler that registers and executes all xcode_* tools, including xcode_read_file, by stripping the prefix and delegating to commandExecutor.executeCommand.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        // Handle web monitor tools
        if (name === 'start_web_monitor') {
          const result = await this.webMonitorManager.start();
          return {
            content: [
              {
                type: 'text',
                text: `${result.message}\n\nWeb interface available at: ${result.url}`
              }
            ]
          };
        }
        
        if (name === 'stop_web_monitor') {
          const result = this.webMonitorManager.stop();
          return {
            content: [
              {
                type: 'text',
                text: result.message
              }
            ]
          };
        }
        
        if (name === 'web_monitor_status') {
          const status = this.webMonitorManager.getStatus();
          let text = status.running 
            ? `Web monitor is running at ${status.url} (port ${status.port})`
            : 'Web monitor is not running';
          return {
            content: [
              {
                type: 'text',
                text: text
              }
            ]
          };
        }
        
        // Handle Xcode commands
        // Remove 'xcode_' prefix if present
        const commandName = name.startsWith('xcode_') ? name.slice(6) : name;
        const result = await this.commandExecutor.executeCommand(commandName, args);
        
        let responseText = result.output;
        if (result.error) {
          responseText += `\n\nWarnings/Errors:\n${result.error}`;
        }
        if (!result.success) {
          responseText = `Command failed: ${result.error}\n\nCommand executed: ${result.command}`;
        }
        
        return {
          content: [
            {
              type: 'text',
              text: responseText,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${errorMessage}`,
            },
          ],
        };
      }
    });
  • Generates the MCP tool definitions including name 'xcode_read_file', description, and inputSchema based on the 'read_file' command parameters from commands.json.
    generateMCPToolDefinitions(): Array<{
      name: string;
      description: string;
      inputSchema: any;
    }> {
      return Object.entries(this.commands).map(([name, command]) => ({
        name: `xcode_${name}`,
        description: command.description,
        inputSchema: {
          type: 'object',
          properties: command.parameters ? Object.fromEntries(
            Object.entries(command.parameters).map(([paramName, paramDef]) => [
              paramName,
              {
                type: paramDef.type,
                description: paramDef.description,
                ...(paramDef.default !== undefined && { default: paramDef.default })
              }
            ])
          ) : {},
          required: command.parameters ? Object.entries(command.parameters)
            .filter(([_, paramDef]) => paramDef.required)
            .map(([paramName]) => paramName) : []
        }
      }));
    }
  • src/index.ts:52-90 (registration)
    Registers the xcode_read_file tool in the MCP ListTools response by including it in the dynamic tools list from generateMCPToolDefinitions.
    // Load commands and dynamically create tool list
    await this.commandExecutor.loadCommands();
    const tools = this.commandExecutor.generateMCPToolDefinitions();
    
    // Add web monitor management tools
    const webMonitorTools = [
      {
        name: 'start_web_monitor',
        description: 'Start the web interface for visual command execution and monitoring',
        inputSchema: {
          type: 'object',
          properties: {},
          required: []
        }
      },
      {
        name: 'stop_web_monitor',
        description: 'Stop the web interface if it is running',
        inputSchema: {
          type: 'object',
          properties: {},
          required: []
        }
      },
      {
        name: 'web_monitor_status',
        description: 'Get the current status of the web monitor',
        inputSchema: {
          type: 'object',
          properties: {},
          required: []
        }
      }
    ];
    
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [...tools, ...webMonitorTools],
    }));
Behavior2/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 of behavioral disclosure. While 'Read' implies a read-only operation, it doesn't specify error handling (e.g., for missing files), permissions required, output format (e.g., text, binary), or any side effects. This is a significant gap for a tool with no annotation coverage.

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 extremely concise ('Read contents of a file') and front-loaded with the core action. There is zero wasted language, making it efficient and easy to parse, though this conciseness comes at the cost of completeness.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., file content as string, error messages), behavioral details, or usage context. For a tool with no structured support, this minimal description leaves critical gaps for an AI agent.

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 description adds no parameter semantics beyond what the input schema provides. The schema has 100% description coverage, with 'file_path' clearly documented as 'Path to the file to read'. The baseline score of 3 is appropriate since the schema does the heavy lifting, but the description doesn't enhance understanding of the parameter.

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 'Read contents of a file' clearly states the verb ('Read') and resource ('contents of a file'), making the purpose immediately understandable. However, it doesn't differentiate from potential sibling tools (though no obvious reading siblings exist in the provided list), and the title is null, so it relies solely on this brief description.

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. It doesn't mention prerequisites (e.g., file existence, permissions), context (e.g., Xcode project files vs. general files), or comparisons to other tools in the server, leaving usage entirely implicit.

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

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/ebowwa/xcode-mcp'

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