Skip to main content
Glama

swift_package_clean

Removes Swift Package build artifacts and derived data to free up storage and maintain a clean development environment. Specify the package path to execute the cleanup.

Instructions

Cleans Swift Package build artifacts and derived data

Input Schema

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

Implementation Reference

  • The handler function for 'swift_package_clean' tool. It registers the tool and provides the logic to run 'swift package clean --package-path <path>', including input validation with Zod schema for packagePath.
    export function registerCleanSwiftPackageTool(server: McpServer): void { registerTool( server, 'swift_package_clean', 'Cleans Swift Package build artifacts and derived data', { packagePath: z.string().describe('Path to the Swift package root (Required)'), }, async (params: { packagePath: string }): Promise<ToolResponse> => { const pkgValidation = validateRequiredParam('packagePath', params.packagePath); if (!pkgValidation.isValid) return pkgValidation.errorResponse!; const resolvedPath = path.resolve(params.packagePath); const args: string[] = ['package', '--package-path', resolvedPath, 'clean']; log('info', `Running swift ${args.join(' ')}`); try { const result = await executeCommand(['swift', ...args], 'Swift Package Clean'); if (!result.success) { const errorMessage = result.error || result.output || 'Unknown error'; return createErrorResponse('Swift package clean failed', errorMessage, 'CleanError'); } 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)' }, ], }; } 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, 'SystemError'); } }, ); }
  • Input schema definition using Zod for the swift_package_clean tool, requiring packagePath.
    { packagePath: z.string().describe('Path to the Swift package root (Required)'), },
  • Registration entry for the swift_package_clean tool in the toolRegistrations array, calling registerCleanSwiftPackageTool if the environment variable is set.
    register: registerCleanSwiftPackageTool, groups: [ToolGroup.SWIFT_PACKAGE_WORKFLOW], envVar: 'XCODEBUILDMCP_TOOL_SWIFT_PACKAGE_CLEAN', },

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/SampsonKY/XcodeBuildMCP'

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