Skip to main content
Glama

xcode_get_projects

Retrieve a list of projects within a specified Xcode workspace or project file. Supports both absolute and relative paths for seamless integration with Xcode build automation.

Instructions

Get list of projects in a specific workspace

Input Schema

NameRequiredDescriptionDefault
xcodeprojYesPath to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths

Input Schema (JSON Schema)

{ "properties": { "xcodeproj": { "description": "Path to the .xcodeproj file (or .xcworkspace if available) - supports both absolute (/path/to/project.xcodeproj) and relative (MyApp.xcodeproj) paths", "type": "string" } }, "required": [ "xcodeproj" ], "type": "object" }

Implementation Reference

  • Core handler function that validates the project path, opens the project if needed, executes JXA script to retrieve list of projects from the workspace, and returns their names and IDs as JSON.
    public static async getProjects(projectPath: string, openProject: OpenProjectCallback): Promise<McpResult> { const validationError = PathValidator.validateProjectPath(projectPath); if (validationError) return validationError; await openProject(projectPath); const script = ` (function() { ${getWorkspaceByPathScript(projectPath)} const projects = workspace.projects(); const projectInfo = projects.map(project => ({ name: project.name(), id: project.id() })); return JSON.stringify(projectInfo, null, 2); })() `; const result = await JXAExecutor.execute(script); return { content: [{ type: 'text', text: result }] }; }
  • Input schema definition for the xcode_get_projects tool, specifying the xcodeproj parameter.
    { name: 'xcode_get_projects', description: 'Get list of projects in a specific workspace', inputSchema: { type: 'object', properties: { xcodeproj: { type: 'string', description: preferredXcodeproj ? `Absolute path to the .xcodeproj file (or .xcworkspace if available) - defaults to ${preferredXcodeproj}` : 'Absolute path to the .xcodeproj file (or .xcworkspace if available) - e.g., /path/to/project.xcodeproj', }, }, required: preferredXcodeproj ? [] : ['xcodeproj'], }, },
  • Tool dispatch/registration in the main switch statement of the CallToolRequest handler, which calls InfoTools.getProjects with validated arguments.
    case 'xcode_get_projects': if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await InfoTools.getProjects(args.xcodeproj as string, this.openProject.bind(this));
  • Registration via ListToolsRequest handler, which uses getToolDefinitions (including xcode_get_projects schema) to provide tool list to MCP clients.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { const toolOptions: { includeClean: boolean; preferredScheme?: string; preferredXcodeproj?: string; } = { includeClean: this.includeClean }; if (this.preferredScheme) toolOptions.preferredScheme = this.preferredScheme; if (this.preferredXcodeproj) toolOptions.preferredXcodeproj = this.preferredXcodeproj; const toolDefinitions = getToolDefinitions(toolOptions); return { tools: toolDefinitions.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })), }; });

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/lapfelix/XcodeMCP'

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