Skip to main content
Glama

stop_agent

Stop AI agents in the cmuxlayer terminal multiplexer by sending Ctrl+C for graceful termination or force killing processes when needed.

Instructions

Stop an agent gracefully (Ctrl+C) or forcefully (kill process).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesAgent ID to stop
forceNoForce kill instead of graceful Ctrl+C

Implementation Reference

  • The core implementation of the stopAgent logic which handles checking if the agent exists, if it's already in a terminal state, and killing the process if force is true.
    async stopAgent(agentId: string, force?: boolean): Promise<void> {
      const agent = this.registry.get(agentId);
      if (!agent) {
        throw new Error(`Agent not found: ${agentId}`);
      }
    
      if (TERMINAL_STATES.has(agent.state)) {
        return; // Already stopped
      }
    
      if (force && agent.pid) {
        try {
          process.kill(agent.pid, "SIGKILL");
        } catch {
          // Process may already be dead — that's fine
        }
  • src/server.ts:835-855 (registration)
    Registration of the stop_agent MCP tool, including input schema validation and calling the engine's stopAgent method.
    server.tool(
      "stop_agent",
      "Stop an agent gracefully (Ctrl+C) or forcefully (kill process).",
      {
        agent_id: z.string().describe("Agent ID to stop"),
        force: z
          .boolean()
          .optional()
          .default(false)
          .describe("Force kill instead of graceful Ctrl+C"),
      },
      async (args) => {
        try {
          await engine.stopAgent(args.agent_id, args.force);
          const state = engine.getAgentState(args.agent_id);
          return ok({
            agent_id: args.agent_id,
            state: state?.state ?? "done",
            applied: "stop_agent",
          });
        } catch (e) {

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