Skip to main content
Glama
LukeLamb

claude-sessions-mcp

kill_session

Destructive

Terminate a named tmux session, ending all processes inside with SIGHUP. Use to stop long-running jobs or cleanup unused sessions.

Instructions

Terminate a named tmux session. Any processes running inside are sent SIGHUP by tmux. Errors if the session does not exist.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesSession name.

Implementation Reference

  • The kill_session tool handler: async function killSession(args) that validates tmux availability, validates the session name, runs 'tmux kill-session -t =<name>', handles 'session not found' errors, and returns a success result with killed: true.
    async function killSession(args) {
      const missing = requireTmux();
      if (missing) return errorResult(missing);
      const bad = validSessionName(args.name);
      if (bad) return errorResult(bad);
      const r = await run(BIN.tmux, ['kill-session', '-t', `=${args.name}`]);
      if (r.code !== 0) {
        if (/can't find session|session not found/i.test(r.stderr)) {
          return errorResult(`session "${args.name}" does not exist`);
        }
        return errorResult(`tmux kill-session failed: ${r.stderr || r.stdout}`);
      }
      return textResult({ session: args.name, killed: true });
    }
  • Tool registration entry for kill_session with name, description, annotations (destructiveHint: true), and inputSchema requiring a 'name' string property.
    {
      name: 'kill_session',
      description: 'Terminate a named tmux session. Any processes running inside are sent SIGHUP by tmux. Errors if the session does not exist.',
      annotations: { title: 'Kill tmux session', readOnlyHint: false, destructiveHint: true, openWorldHint: false },
      inputSchema: {
        type: 'object',
        properties: {
          name: { type: 'string', description: 'Session name.' },
        },
        required: ['name'],
        additionalProperties: false,
      },
    },
  • server.js:326-334 (registration)
    The HANDLERS map that wires the string 'kill_session' to the killSession function for JSON-RPC dispatch.
    const HANDLERS = {
      list_sessions: listSessions,
      has_session: hasSession,
      list_windows: listWindows,
      capture_pane: capturePane,
      new_session: newSession,
      send_keys: sendKeys,
      kill_session: killSession,
    };
  • validSessionName helper used to validate the session name argument before proceeding with kill-session.
    function validSessionName(name) {
      if (typeof name !== 'string' || !name.length) return 'name is required (non-empty string)';
      if (name.length > 100) return 'name too long (max 100)';
      if (/[.:\s|]/.test(name)) return "name cannot contain '.', ':', '|', or whitespace";
      return null;
    }
  • The run() utility that spawns a child process (used to execute tmux kill-session) and returns stdout/stderr/exit code.
    function run(cmd, args, opts = {}) {
      return new Promise((resolve) => {
        const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'pipe'], ...opts });
        let out = Buffer.alloc(0);
        let err = Buffer.alloc(0);
        child.stdout.on('data', (d) => { out = Buffer.concat([out, d]); });
        child.stderr.on('data', (d) => { err = Buffer.concat([err, d]); });
        child.on('error', (e) => resolve({ code: -1, stdout: '', stderr: e.message }));
        child.stdin.end();
        child.on('close', (code) => resolve({
          code,
          stdout: out.toString('utf8'),
          stderr: err.toString('utf8'),
        }));
      });
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Adds beyond annotations: details SIGHUP behavior and error condition if session does not exist. Matches destructiveHint.

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?

Two concise sentences, front-loaded with primary purpose. No wasted words.

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

Completeness5/5

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

Complete for a simple kill tool with one parameter and no output schema. Covers purpose, behavior, and error case.

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 has 100% coverage but only a minimal description for the 'name' parameter. No additional semantics added in tool description.

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?

Clearly states 'Terminate a named tmux session' with a specific verb-resource pair. Distinct from sibling tools like capture_pane or list_sessions.

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?

Conveys when to use (to terminate a session) and mentions consequences (SIGHUP, error if missing). Could note alternatives but sufficient.

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

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/LukeLamb/claude-sessions-mcp'

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