Skip to main content
Glama

Kill tmux Pane

tmux_kill_pane
DestructiveIdempotent

Close a specific pane in a tmux terminal session to terminate its running process and free up terminal space.

Instructions

Kill (close) a pane in a tmux window.

Args:

  • session (string, required): Name of the session

  • window (string or number, optional): Window index or name

  • pane (number, required): Pane index

WARNING: This will terminate the process running in the pane.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionYesName of the session
windowNoWindow index or name
paneYesPane index

Implementation Reference

  • The handler function for tmux_kill_pane tool. It constructs the target from session, window, and pane, then executes the tmux kill-pane command via runTmux utility.
    async ({ session, window, pane }) => {
      try {
        const target = formatTarget(session, window, pane);
        await runTmux(`kill-pane -t "${target}"`);
    
        return {
          content: [{ type: "text", text: `Pane ${pane} killed successfully.` }],
          structuredContent: { success: true, session, window, pane },
        };
      } catch (error) {
        return {
          content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
          isError: true,
        };
      }
    }
  • Input schema validation for the tmux_kill_pane tool using Zod, defining parameters session, window (optional), and pane.
    inputSchema: z
      .object({
        session: z.string().min(1).describe("Name of the session"),
        window: z.union([z.string(), z.number()]).optional().describe("Window index or name"),
        pane: z.number().int().min(0).describe("Pane index"),
      })
      .strict(),
    annotations: {
  • src/index.ts:528-570 (registration)
    Full registration of the tmux_kill_pane tool with McpServer, including title, description, schema, annotations, and handler function.
    server.registerTool(
      "tmux_kill_pane",
      {
        title: "Kill tmux Pane",
        description: `Kill (close) a pane in a tmux window.
    
    Args:
      - session (string, required): Name of the session
      - window (string or number, optional): Window index or name
      - pane (number, required): Pane index
    
    WARNING: This will terminate the process running in the pane.`,
        inputSchema: z
          .object({
            session: z.string().min(1).describe("Name of the session"),
            window: z.union([z.string(), z.number()]).optional().describe("Window index or name"),
            pane: z.number().int().min(0).describe("Pane index"),
          })
          .strict(),
        annotations: {
          readOnlyHint: false,
          destructiveHint: true,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ session, window, pane }) => {
        try {
          const target = formatTarget(session, window, pane);
          await runTmux(`kill-pane -t "${target}"`);
    
          return {
            content: [{ type: "text", text: `Pane ${pane} killed successfully.` }],
            structuredContent: { success: true, session, window, pane },
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }],
            isError: true,
          };
        }
      }
    );
  • Helper function used by tmux_kill_pane to format the tmux target string (session:window.pane).
    function formatTarget(session?: string, window?: number | string, pane?: number): string {
      let target = "";
      if (session) {
        target = session;
        if (window !== undefined) {
          target += `:${window}`;
          if (pane !== undefined) {
            target += `.${pane}`;
          }
        }
      }
      return target;
    }
  • Utility function to execute tmux commands asynchronously, handling common tmux errors gracefully.
    async function runTmux(args: string): Promise<string> {
      try {
        const { stdout } = await execAsync(`tmux ${args}`);
        return stdout.trim();
      } catch (error: unknown) {
        if (error instanceof Error && "stderr" in error) {
          const stderr = (error as { stderr: string }).stderr;
          if (stderr.includes("no server running")) {
            throw new Error("tmux server is not running. Start a session first with tmux_create_session.");
          }
          if (stderr.includes("session not found")) {
            throw new Error("Session not found. Use tmux_list_sessions to see available sessions.");
          }
          if (stderr.includes("window not found")) {
            throw new Error("Window not found. Use tmux_list_windows to see available windows.");
          }
          if (stderr.includes("can't find pane")) {
            throw new Error("Pane not found. Use tmux_list_panes to see available panes.");
          }
          throw new Error(`tmux error: ${stderr}`);
        }
        throw error;
      }
    }
Behavior4/5

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

Annotations already indicate destructiveHint=true and idempotentHint=true, but the description adds valuable context beyond this: it explicitly warns that 'This will terminate the process running in the pane,' clarifying the destructive nature in practical terms. It doesn't contradict annotations and provides meaningful behavioral insight.

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 efficiently structured: a clear purpose statement followed by parameter details and a critical warning. Every sentence serves a distinct purpose with no redundancy, making it easy to parse and front-loaded with essential information.

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

Completeness4/5

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

Given the tool's complexity (destructive operation with 3 parameters), annotations cover safety and idempotency, and the description adds crucial behavioral context (process termination). However, without an output schema, it doesn't describe return values or error conditions, leaving a minor gap in completeness.

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 each parameter clearly documented in the schema. The description's Args section repeats this information without adding significant semantic context beyond what's already in the schema, meeting the baseline 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 ('Kill (close)') and resource ('a pane in a tmux window'), distinguishing it from sibling tools like tmux_kill_session and tmux_kill_window which target different resources. The verb+resource combination is precise and unambiguous.

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 terminate a pane), and the WARNING section implies it should be used cautiously. However, it doesn't explicitly state when NOT to use it or name specific alternatives among siblings (e.g., tmux_select_pane for navigation instead of termination).

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/audibleblink/tmux-mcp-server'

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