swift_package_list
Identify active Swift Package processes on XcodeBuildMCP to monitor and manage current tasks efficiently.
Instructions
Lists currently running Swift Package processes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Core handler function that implements the logic to list active Swift Package processes, calculating runtime and formatting the output.export async function swift_package_listLogic( params?: unknown, dependencies?: ProcessListDependencies, ): Promise<ToolResponse> { const processMap = dependencies?.processMap ?? activeProcesses; const arrayFrom = dependencies?.arrayFrom ?? Array.from; const dateNow = dependencies?.dateNow ?? Date.now; const processes = arrayFrom(processMap.entries()); if (processes.length === 0) { return { content: [ createTextContent('ℹ️ No Swift Package processes currently running.'), createTextContent('💡 Use swift_package_run to start an executable.'), ], }; } const content = [createTextContent(`📋 Active Swift Package processes (${processes.length}):`)]; for (const [pid, info] of processes) { // Use logical OR instead of nullish coalescing to treat empty strings as falsy // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const executableName = info.executableName || 'default'; const runtime = Math.max(1, Math.round((dateNow() - info.startedAt.getTime()) / 1000)); content.push( createTextContent( ` • PID ${pid}: ${executableName} (${info.packagePath}) - running ${runtime}s`, ), ); } content.push(createTextContent('💡 Use swift_package_stop with a PID to terminate a process.')); return { content }; }
- Zod schema definition for tool parameters (empty since no input parameters are required) and inferred TypeScript type.const swiftPackageListSchema = z.object({}); // Use z.infer for type safety type SwiftPackageListParams = z.infer<typeof swiftPackageListSchema>;
- src/mcp/tools/swift-package/swift_package_list.ts:78-89 (registration)Tool registration as default export, including name, description, schema, and a typed handler wrapper around the core logic.export default { name: 'swift_package_list', description: 'Lists currently running Swift Package processes', schema: swiftPackageListSchema.shape, // MCP SDK compatibility handler: createTypedTool( swiftPackageListSchema, (params: SwiftPackageListParams) => { return swift_package_listLogic(params); }, getDefaultCommandExecutor, ), };