Skip to main content
Glama

kill

Stop one or more AI agents managed by the cmuxlayer terminal multiplexer. Specify agent IDs or use 'all' to terminate agents, with optional force kill capability.

Instructions

Stop one or more agents. Target can be a single agent ID, an array of IDs, or 'all'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesAgent ID, array of agent IDs, or 'all' to stop all agents
forceNoForce kill (SIGKILL) instead of graceful (Ctrl+C)

Implementation Reference

  • Implementation of the 'kill' MCP tool, which stops agents either gracefully or forcibly.
    server.tool(
      "kill",
      "Stop one or more agents. Target can be a single agent ID, an array of IDs, or 'all'.",
      {
        target: z
          .union([z.string(), z.array(z.string())])
          .describe(
            "Agent ID, array of agent IDs, or 'all' to stop all agents",
          ),
        force: z
          .boolean()
          .optional()
          .default(false)
          .describe("Force kill (SIGKILL) instead of graceful (Ctrl+C)"),
      },
      async (args) => {
        try {
          const killed: string[] = [];
          const errors: string[] = [];
    
          // Resolve target list
          let targetIds: string[];
          if (args.target === "all") {
            const agents = engine.listAgents();
            targetIds = agents
              .filter((a) => a.state !== "done" && a.state !== "error")
              .map((a) => a.agent_id);
          } else if (Array.isArray(args.target)) {
            targetIds = args.target;
          } else {
            targetIds = [args.target];
          }
    
          if (targetIds.length === 0) {
            return ok({ killed: [], message: "No agents to kill" });
          }
    
          // Kill each agent, collecting results
          for (const agentId of targetIds) {
            try {
              await engine.stopAgent(agentId, args.force);
              killed.push(agentId);
            } catch (e) {
              errors.push(
                `${agentId}: ${e instanceof Error ? e.message : String(e)}`,
              );
            }
          }
    
          if (killed.length === 0 && errors.length > 0) {
            return err(
              new Error(`Failed to kill any agents: ${errors.join("; ")}`),
            );
          }
    
          return ok({
            killed,
            errors: errors.length > 0 ? errors : undefined,
            force: args.force,

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/EtanHey/cmuxlayer'

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