Skip to main content
Glama
ebowwa
by ebowwa

xcode_read_file

Read contents of a specified file programmatically within Xcode projects. Enables AI assistants to access and process file data directly for iOS/macOS development tasks.

Instructions

Read contents of a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the file to read

Implementation Reference

  • Specific handler case for the 'read_file' internal command, which is executed when the MCP tool 'xcode_read_file' is called. Calls FileManager.readFile to read the file contents.
    case 'read_file': output = await this.fileManager.readFile(args.file_path); break;
  • Core implementation of file reading using Node.js fs.promises.readFile. This is the terminal logic for the xcode_read_file tool.
    async readFile(filePath: string): Promise<string> { return await fs.readFile(filePath, 'utf-8'); }
  • Generates the MCP tool definitions dynamically from loaded commands. For the 'read_file' command, creates the tool named 'xcode_read_file' with appropriate description and input schema.
    // Generate MCP tool definitions from commands 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:87-89 (registration)
    Registers the list tools handler in the MCP server, which returns the list including 'xcode_read_file'.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [...tools, ...webMonitorTools], }));
  • Main MCP tool call handler for Xcode tools. Strips 'xcode_' prefix from tool name (e.g., 'xcode_read_file' -> 'read_file'), calls CommandExecutor.executeCommand, and formats the response.
    // 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) {

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