Skip to main content
Glama

swift_package_clean

Removes Swift Package build artifacts and derived data to free up storage and improve build performance. Specify the package root path to initiate the cleanup process.

Instructions

Cleans Swift Package build artifacts and derived data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packagePathYesPath to the Swift package root (Required)

Implementation Reference

  • Executes the 'swift package clean' command on the specified package path using a command executor. Handles success and error responses with formatted output.
    export async function swift_package_cleanLogic(
      params: SwiftPackageCleanParams,
      executor: CommandExecutor,
    ): Promise<ToolResponse> {
      const resolvedPath = path.resolve(params.packagePath);
      const swiftArgs = ['package', '--package-path', resolvedPath, 'clean'];
    
      log('info', `Running swift ${swiftArgs.join(' ')}`);
      try {
        const result = await executor(['swift', ...swiftArgs], 'Swift Package Clean', true, undefined);
        if (!result.success) {
          const errorMessage = result.error ?? result.output ?? 'Unknown error';
          return createErrorResponse('Swift package clean failed', errorMessage);
        }
    
        return {
          content: [
            { type: 'text', text: '✅ Swift package cleaned successfully.' },
            {
              type: 'text',
              text: '💡 Build artifacts and derived data removed. Ready for fresh build.',
            },
            { type: 'text', text: result.output || '(clean completed silently)' },
          ],
          isError: false,
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        log('error', `Swift package clean failed: ${message}`);
        return createErrorResponse('Failed to execute swift package clean', message);
      }
    }
  • Zod schema defining the input parameters for the tool: packagePath (string, required).
    const swiftPackageCleanSchema = z.object({
      packagePath: z.string().describe('Path to the Swift package root (Required)'),
    });
  • Registers the tool with name, description, schema, and wraps the handler using createTypedTool for MCP compatibility.
    export default {
      name: 'swift_package_clean',
      description: 'Cleans Swift Package build artifacts and derived data',
      schema: swiftPackageCleanSchema.shape, // MCP SDK compatibility
      handler: createTypedTool(
        swiftPackageCleanSchema,
        swift_package_cleanLogic,
        getDefaultCommandExecutor,
      ),
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Cleans' implies a destructive operation, the description doesn't specify whether this operation is reversible, what exactly gets deleted, whether it requires specific permissions, or what the expected outcome looks like. For a tool that appears to delete build artifacts, this is insufficient behavioral context.

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 gets straight to the point with zero wasted words. It's appropriately sized for a simple tool with one parameter and clearly states the tool's purpose without 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?

For a tool that performs cleanup operations (potentially destructive) with no annotations and no output schema, the description is inadequate. It doesn't explain what 'build artifacts and derived data' specifically includes, whether the operation is safe to run, what confirmation (if any) is provided, or what happens on success/failure. Given the context of sibling tools that perform similar operations on different targets, more differentiation would be helpful.

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?

The schema description coverage is 100%, with the single parameter 'packagePath' clearly documented as 'Path to the Swift package root (Required)'. The description doesn't add any additional parameter information beyond what the schema provides, which is acceptable given the complete schema documentation.

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 ('Cleans') and target ('Swift Package build artifacts and derived data'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'clean_proj' or 'clean_ws', which appear to clean different types of projects/workspaces rather than Swift packages specifically.

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 about when to use this tool versus alternatives. There are multiple cleaning tools (clean_proj, clean_ws) and Swift package tools (swift_package_build, swift_package_test, etc.), but the description doesn't indicate when this specific Swift package cleaning tool is appropriate versus other cleaning or Swift package operations.

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