Skip to main content
Glama

XC-MCP: XCode CLI wrapper

by conorluddy
list.ts1.8 kB
import { validateProjectPath } from '../../utils/validation.js'; import { executeCommand, buildXcodebuildCommand } from '../../utils/command.js'; import type { XcodeProject, OutputFormat } from '../../types/xcode.js'; import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; interface ListToolArgs { projectPath: string; outputFormat?: OutputFormat; } export async function xcodebuildListTool(args: any) { const { projectPath, outputFormat = 'json' } = args as ListToolArgs; try { // Validate inputs await validateProjectPath(projectPath); // Build command const command = buildXcodebuildCommand('-list', projectPath, { json: outputFormat === 'json', }); // Execute command const result = await executeCommand(command); if (result.code !== 0) { throw new McpError( ErrorCode.InternalError, `Failed to list project information: ${result.stderr}` ); } let responseText: string; if (outputFormat === 'json') { try { // Parse and format JSON response const projectInfo: XcodeProject = JSON.parse(result.stdout); responseText = JSON.stringify(projectInfo, null, 2); } catch (parseError) { throw new McpError( ErrorCode.InternalError, `Failed to parse xcodebuild output: ${parseError}` ); } } else { responseText = result.stdout; } return { content: [ { type: 'text' as const, text: responseText, }, ], }; } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `xcodebuild-list failed: ${error instanceof Error ? error.message : String(error)}` ); } }

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/conorluddy/xc-mcp'

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