Skip to main content
Glama
nickgnd

Tmux MCP Server

by nickgnd

kill-session

Terminate a tmux session by its ID to free system resources and manage terminal sessions effectively.

Instructions

Kill a tmux session by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesID of the tmux session to kill

Implementation Reference

  • MCP tool handler function for "kill-session". Takes sessionId, calls tmux.killSession, returns success or error message.
    async ({ sessionId }) => {
      try {
        await tmux.killSession(sessionId);
        return {
          content: [{
            type: "text",
            text: `Session ${sessionId} has been killed`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error killing session: ${error}`
          }],
          isError: true
        };
      }
    }
  • Input schema for kill-session tool using Zod: requires sessionId as string.
    {
      sessionId: z.string().describe("ID of the tmux session to kill")
    },
  • src/index.ts:231-256 (registration)
    Registration of the "kill-session" tool on the MCP server with name, description, schema, and handler.
    server.tool(
      "kill-session",
      "Kill a tmux session by ID",
      {
        sessionId: z.string().describe("ID of the tmux session to kill")
      },
      async ({ sessionId }) => {
        try {
          await tmux.killSession(sessionId);
          return {
            content: [{
              type: "text",
              text: `Session ${sessionId} has been killed`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error killing session: ${error}`
            }],
            isError: true
          };
        }
      }
    );
  • Helper function killSession that executes the tmux 'kill-session' command via executeTmux.
    export async function killSession(sessionId: string): Promise<void> {
      await executeTmux(`kill-session -t '${sessionId}'`);
    }

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

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