Skip to main content
Glama

swift_package_build

Compile Swift packages using specified configurations, architectures, and targets directly within XcodeBuildMCP to streamline project builds.

Instructions

Builds a Swift Package with swift build

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
architecturesNoTarget architectures to build for
configurationNoSwift package configuration (debug, release)
packagePathYesPath to the Swift package root (Required)
parseAsLibraryNoBuild as library instead of executable
targetNameNoOptional target to build

Implementation Reference

  • Core execution logic for building a Swift package using `swift build` with customizable options.
    export async function swift_package_buildLogic(
      params: SwiftPackageBuildParams,
      executor: CommandExecutor,
    ): Promise<ToolResponse> {
      const resolvedPath = path.resolve(params.packagePath);
      const swiftArgs = ['build', '--package-path', resolvedPath];
    
      if (params.configuration && params.configuration.toLowerCase() === 'release') {
        swiftArgs.push('-c', 'release');
      }
    
      if (params.targetName) {
        swiftArgs.push('--target', params.targetName);
      }
    
      if (params.architectures) {
        for (const arch of params.architectures) {
          swiftArgs.push('--arch', arch);
        }
      }
    
      if (params.parseAsLibrary) {
        swiftArgs.push('-Xswiftc', '-parse-as-library');
      }
    
      log('info', `Running swift ${swiftArgs.join(' ')}`);
      try {
        const result = await executor(['swift', ...swiftArgs], 'Swift Package Build', true, undefined);
        if (!result.success) {
          const errorMessage = result.error ?? result.output ?? 'Unknown error';
          return createErrorResponse('Swift package build failed', errorMessage);
        }
    
        return {
          content: [
            { type: 'text', text: '✅ Swift package build succeeded.' },
            {
              type: 'text',
              text: '💡 Next: Run tests with swift_package_test or execute with swift_package_run',
            },
            { type: 'text', text: result.output },
          ],
          isError: false,
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        log('error', `Swift package build failed: ${message}`);
        return createErrorResponse('Failed to execute swift build', message);
      }
    }
  • Zod schema defining the input parameters for the swift_package_build tool.
    const swiftPackageBuildSchema = z.object({
      packagePath: z.string().describe('Path to the Swift package root (Required)'),
      targetName: z.string().optional().describe('Optional target to build'),
      configuration: z
        .enum(['debug', 'release'])
        .optional()
        .describe('Swift package configuration (debug, release)'),
      architectures: z.array(z.string()).optional().describe('Target architectures to build for'),
      parseAsLibrary: z.boolean().optional().describe('Build as library instead of executable'),
    });
  • Tool registration exporting the name, description, schema, and wrapped handler for MCP integration.
    export default {
      name: 'swift_package_build',
      description: 'Builds a Swift Package with swift build',
      schema: swiftPackageBuildSchema.shape, // MCP SDK compatibility
      handler: createTypedTool(
        swiftPackageBuildSchema,
        swift_package_buildLogic,
        getDefaultCommandExecutor,
      ),
    };
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool builds but doesn't disclose behavioral traits like whether it's read-only or destructive, permission requirements, side effects (e.g., generates artifacts), error handling, or output format. For a build tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero waste. It's front-loaded with the core purpose and uses minimal words to convey the essential action. Every word earns its place without redundancy or unnecessary elaboration.

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 tool's complexity (build operation with 5 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't address what the build produces, success/failure indicators, or behavioral context needed for effective use. The 100% schema coverage helps with parameters but doesn't compensate for missing operational guidance.

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%, so the schema already documents all 5 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema (e.g., no examples, no clarification on default behaviors). Baseline 3 is appropriate when schema does the heavy lifting, though no extra value is added.

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 ('Builds') and resource ('a Swift Package'), specifying the implementation method ('with swift build'). It distinguishes from sibling tools like swift_package_clean, swift_package_run, and swift_package_test by focusing on building rather than cleaning, running, or testing. However, it doesn't explicitly differentiate from other build tools in the sibling list (e.g., build_dev_proj, build_mac_proj).

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?

The description provides no guidance on when to use this tool versus alternatives. With many sibling build tools (e.g., build_dev_proj, build_mac_proj, build_sim_id_proj), there's no indication of when swift_package_build is appropriate versus project/workspace-specific builds, or how it relates to swift_package_run for execution. Usage context is implied but not stated.

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

Related 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/getsentry/XcodeBuildMCP'

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