Skip to main content
Glama

swift_package_list

Monitor and list active Swift Package processes on the sl-test MCP server to enhance process management and optimize resource utilization.

Instructions

Lists currently running Swift Package processes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'swift_package_list' tool. It iterates over the activeProcesses map, formats a list of running Swift package processes with their PID, package path, executable name, and runtime, and returns a text response.
    async (): Promise<ToolResponse> => { const processes = Array.from(activeProcesses.entries()); if (processes.length === 0) { return { content: [ { type: 'text', text: 'ℹ️ No Swift Package processes currently running.' }, { type: 'text', text: '💡 Use swift_package_run to start an executable.' }, ], }; } const content = [ { type: 'text', text: `📋 Active Swift Package processes (${processes.length}):` }, ]; for (const [pid, info] of processes) { const executableName = info.executableName || 'default'; const runtime = Math.round((Date.now() - info.startedAt.getTime()) / 1000); content.push({ type: 'text', text: ` • PID ${pid}: ${executableName} (${info.packagePath}) - running ${runtime}s`, }); } content.push({ type: 'text', text: '💡 Use swift_package_stop with a PID to terminate a process.', }); return { content: content as Array<{ type: 'text'; text: string }> };
  • The registration function that registers the 'swift_package_list' tool on the MCP server using registerTool, including the tool name, description, empty input schema, and the handler function.
    export function registerListSwiftPackageTool(server: McpServer): void { registerTool( server, 'swift_package_list', 'Lists currently running Swift Package processes', {}, async (): Promise<ToolResponse> => { const processes = Array.from(activeProcesses.entries()); if (processes.length === 0) { return { content: [ { type: 'text', text: 'ℹ️ No Swift Package processes currently running.' }, { type: 'text', text: '💡 Use swift_package_run to start an executable.' }, ], }; } const content = [ { type: 'text', text: `📋 Active Swift Package processes (${processes.length}):` }, ]; for (const [pid, info] of processes) { const executableName = info.executableName || 'default'; const runtime = Math.round((Date.now() - info.startedAt.getTime()) / 1000); content.push({ type: 'text', text: ` • PID ${pid}: ${executableName} (${info.packagePath}) - running ${runtime}s`, }); } content.push({ type: 'text', text: '💡 Use swift_package_stop with a PID to terminate a process.', }); return { content: content as Array<{ type: 'text'; text: string }> }; }, ); }
  • Top-level registration entry in the toolRegistrations array that conditionally registers the swift_package_list tool via registerListSwiftPackageTool based on the XCODEBUILDMCP_TOOL_SWIFT_PACKAGE_LIST environment variable.
    { register: registerListSwiftPackageTool, groups: [ToolGroup.SWIFT_PACKAGE_WORKFLOW], envVar: 'XCODEBUILDMCP_TOOL_SWIFT_PACKAGE_LIST', },
  • The activeProcesses Map used by the swift_package_list handler (and other tools like run/stop) to track running Swift package processes.
    // Store active processes so we can manage them - keyed by PID for uniqueness const activeProcesses = new Map< number, { process: ChildProcess; startedAt: Date; packagePath: string; executableName?: string } >();

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