Skip to main content
Glama

xcode_get_schemes

Retrieve a list of available schemes for an Xcode project using a specified .xcodeproj or .xcworkspace file path. Simplify Xcode build automation and project management.

Instructions

Get list of available schemes for a specific project

Input Schema

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

Implementation Reference

  • Core handler function that validates the project path, ensures the project is open, executes a JXA script via JXAExecutor to retrieve schemes from the Xcode workspace (including names, IDs, and active status), handles empty schemes case, and returns formatted JSON.
    public static async getSchemes(projectPath: string, openProject: OpenProjectCallback): Promise<McpResult> { const validationError = PathValidator.validateProjectPath(projectPath); if (validationError) return validationError; await openProject(projectPath); const script = ` (function() { ${getWorkspaceByPathScript(projectPath)} const schemes = workspace.schemes(); const activeScheme = workspace.activeScheme(); const schemeInfo = schemes.map(scheme => ({ name: scheme.name(), id: scheme.id(), isActive: activeScheme && scheme.id() === activeScheme.id() })); return JSON.stringify(schemeInfo, null, 2); })() `; const result = await JXAExecutor.execute(script); // Parse the result to check if schemes array is empty try { const schemeInfo = JSON.parse(result); if (Array.isArray(schemeInfo) && schemeInfo.length === 0) { return { content: [{ type: 'text', text: 'No schemes found in the project' }] }; } } catch (error) { // If parsing fails, return the raw result } return { content: [{ type: 'text', text: result }] }; }
  • Tool definition including name, description, and input schema (object with optional 'xcodeproj' string parameter). Used by getToolDefinitions() to register the tool.
    { name: 'xcode_get_schemes', description: 'Get list of available schemes for a specific project', 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'], }, },
  • Switch case in CallToolRequestSchema handler that validates input, resolves preferred xcodeproj if needed, and delegates to ProjectTools.getSchemes handler.
    case 'xcode_get_schemes': if (!args.xcodeproj) { throw new McpError(ErrorCode.InvalidParams, `Missing required parameter: xcodeproj`); } return await ProjectTools.getSchemes(args.xcodeproj as string, this.openProject.bind(this));
  • ListToolsRequestSchema handler that calls getToolDefinitions() (which includes xcode_get_schemes) and returns tool list with schemas for MCP registration.
    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