Skip to main content
Glama

swift_package_stop

Terminate a running Swift Package executable by specifying its process ID (PID) using this tool. Integrates with XcodeBuildMCP for efficient process management.

Instructions

Stops a running Swift Package executable started with swift_package_run

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYesProcess ID (PID) of the running executable

Implementation Reference

  • Defines the Zod schema for input parameters (pid) of the swift_package_stop tool.
    const swiftPackageStopSchema = z.object({
      pid: z.number().describe('Process ID (PID) of the running executable'),
    });
  • Core handler function that stops the Swift Package process by PID: retrieves process info, sends SIGTERM/SIGKILL, removes from active list, and returns response.
    export async function swift_package_stopLogic(
      params: SwiftPackageStopParams,
      processManager: ProcessManager = getDefaultProcessManager(),
      timeout: number = 5000,
    ): Promise<ToolResponse> {
      const processInfo = processManager.getProcess(params.pid);
      if (!processInfo) {
        return createTextResponse(
          `⚠️ No running process found with PID ${params.pid}. Use swift_package_run to check active processes.`,
          true,
        );
      }
    
      try {
        processInfo.process.kill('SIGTERM');
    
        // Give it time to terminate gracefully (configurable for testing)
        await new Promise((resolve) => {
          let terminated = false;
    
          processInfo.process.on('exit', () => {
            terminated = true;
            resolve(true);
          });
    
          setTimeout(() => {
            if (!terminated) {
              processInfo.process.kill('SIGKILL');
            }
            resolve(true);
          }, timeout);
        });
    
        processManager.removeProcess(params.pid);
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ Stopped executable (was running since ${processInfo.startedAt.toISOString()})`,
            },
            {
              type: 'text',
              text: `💡 Process terminated. You can now run swift_package_run again if needed.`,
            },
          ],
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        return createErrorResponse('Failed to stop process', message);
      }
    }
  • Default export registering the tool with name, description, schema, and a thin handler that validates inputs and delegates to the core logic.
    export default {
      name: 'swift_package_stop',
      description: 'Stops a running Swift Package executable started with swift_package_run',
      schema: swiftPackageStopSchema.shape, // MCP SDK compatibility
      async handler(args: Record<string, unknown>): Promise<ToolResponse> {
        // Validate parameters using Zod
        const parseResult = swiftPackageStopSchema.safeParse(args);
        if (!parseResult.success) {
          return createErrorResponse(
            'Parameter validation failed',
            parseResult.error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', '),
          );
        }
    
        return swift_package_stopLogic(parseResult.data);
      },
    };
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. While it indicates this is a destructive operation (stopping a process), it doesn't disclose important behavioral traits such as whether this requires specific permissions, what happens if the PID is invalid, whether the stop is graceful or forceful, or any error conditions. The description is minimal and lacks operational 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 communicates the core purpose without any wasted words. It's appropriately sized for a simple tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive operation tool with no annotations and no output schema, the description is minimally adequate. It identifies the tool's purpose and relationship to swift_package_run, but lacks details about behavioral implications, error handling, or what constitutes successful execution. Given the complexity (stopping processes) and absence of structured safety information, it should provide more operational context.

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%, with the single parameter 'pid' clearly documented in the schema as 'Process ID (PID) of the running executable'. The description doesn't add any meaningful parameter semantics beyond what the schema already provides, so it meets the baseline of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Stops') and resource ('a running Swift Package executable'), and explicitly distinguishes it from its sibling tool 'swift_package_run' by mentioning that it stops executables started with that tool. This provides precise differentiation from other tools in the list.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('to stop a running Swift Package executable started with swift_package_run'), which implicitly suggests an alternative (using swift_package_run to start it). However, it doesn't explicitly state when NOT to use it or mention other potential alternatives among siblings like 'stop_app_device' or 'stop_mac_app'.

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