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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the file to read |
Implementation Reference
- src/command-executor.ts:206-208 (handler)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;
- src/file-manager.ts:34-36 (helper)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'); }
- src/command-executor.ts:280-306 (registration)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], }));
- src/index.ts:135-156 (handler)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) {