Skip to main content
Glama

build

Build iOS Xcode projects and workspaces to compile code and identify errors for debugging and deployment.

Instructions

Build the iOS Xcode workspace/project in the folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderYesThe full path of the current folder that the iOS Xcode workspace/project sits

Implementation Reference

  • The main handler function for the 'build' tool (and 'test'). It changes to the specified folder, finds the Xcode project/workspace, determines the scheme and simulator, constructs the xcodebuild command, runs it, and returns the command and result summary (errors/warnings or success).
    @server.call_tool()
    async def call_tool(name, arguments: dict) -> list[TextContent]:
        try:
            args = Folder(**arguments)
        except ValueError as e:
            raise McpError(ErrorData(code=INVALID_PARAMS, message=str(e)))
        os.chdir(args.folder)
        xcode_project_path = find_xcode_project()
        project_name = os.path.basename(xcode_project_path)
        project_type = ""
        if xcode_project_path.endswith(".xcworkspace"):
            project_type = "-workspace"
        else:
            project_type = "-project"
    
        scheme = find_scheme(project_type, project_name)
        destination = find_available_simulator()
        command = ["xcodebuild",
                   project_type,
                   project_name,
                   "-scheme",
                   scheme,
                   "-destination",
                   destination]
        if name == "test":
            command.append("test")
    
        result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False).stdout
        
        lines = result.decode("utf-8").splitlines()
        error_lines = [line for line in lines if "error:" or "warning:" in line.lower()]
        error_message = "\n".join(error_lines)
        if not error_message:
            error_message = "Successful"
        return [
            TextContent(type="text", text=f"Command: {' '.join(command)}"),
            TextContent(type="text", text=f"{error_message}")
            ]
  • Pydantic BaseModel defining the input parameters for the 'build' tool: the folder path containing the Xcode project/workspace.
    class Folder(BaseModel):
        """Parameters"""
        folder: Annotated[str, Field(description="The full path of the current folder that the iOS Xcode workspace/project sits")]
  • Registers the 'build' tool (and 'test' tool) with the MCP server, providing name, description, and input schema.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        return [
            Tool(
                name = "build",
                description = "Build the iOS Xcode workspace/project in the folder",
                inputSchema = Folder.model_json_schema(),
            ),
            Tool(
                name="test",
                description="Run test for the iOS Xcode workspace/project in the folder",
                inputSchema=Folder.model_json_schema(),
            )
        ]
  • Helper function to find the nearest Xcode workspace (.xcworkspace) or project (.xcodeproj) directory by walking the current directory tree.
    def find_xcode_project():
        for root, dirs, files in os.walk("."):
            dirs.sort(reverse = True)
            for dir in dirs:
                if dir.endswith(".xcworkspace") or dir.endswith(".xcodeproj"):
                    return os.path.join(root, dir)
        return None
  • Helper function to find the first available scheme for the Xcode project/workspace by running 'xcodebuild -list'.
    def find_scheme(project_type: str, project_name: str) -> str:
        schemes_result = subprocess.run(["xcodebuild",
                                        "-list",
                                        project_type,
                                        project_name],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE,
                                        check=False).stdout.decode("utf-8")
        
        schemes_lines = schemes_result.splitlines()
        schemes = []
        in_schemes_section = False
        for line in schemes_lines:
            if "Schemes:" in line:
                in_schemes_section = True
                continue
            if in_schemes_section:
                scheme = line.strip()
                if scheme:
                    schemes.append(scheme)
        
        if schemes:
            return schemes[0]
        else:
            return ""
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without disclosing behavioral traits. It doesn't mention whether this is a destructive operation, what permissions are needed, how long it takes, error handling, or output format. For a build tool with zero annotation coverage, this is inadequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a build operation, no annotations, and no output schema, the description is incomplete. It lacks crucial details like what 'build' entails (e.g., compilation, linking), success/failure indicators, or any behavioral context, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'folder' well-documented in the schema. The description adds no additional meaning beyond implying the folder contains an iOS Xcode workspace/project, which is already covered. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Build') and target resource ('iOS Xcode workspace/project in the folder'), making the purpose immediately understandable. However, it doesn't differentiate from the sibling tool 'test', which might also operate on similar resources, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like the sibling 'test' tool. The description implies usage for building iOS projects but offers no context about prerequisites, timing, or exclusions, leaving the agent with minimal direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ShenghaiWang/xcodebuild'

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