Skip to main content
Glama
nickgnd

Tmux MCP Server

by nickgnd

list-sessions

Retrieve all active tmux sessions to view, manage, and interact with terminal environments through the Tmux MCP Server.

Instructions

List all active tmux sessions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:27-50 (registration)
    Registers the MCP tool 'list-sessions' with server.tool(). The inline async handler fetches sessions using tmux.listSessions() and returns JSON-formatted text content or error.
    server.tool(
      "list-sessions",
      "List all active tmux sessions",
      {},
      async () => {
        try {
          const sessions = await tmux.listSessions();
          return {
            content: [{
              type: "text",
              text: JSON.stringify(sessions, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error listing tmux sessions: ${error}`
            }],
            isError: true
          };
        }
      }
    );
  • Core handler logic for listing tmux sessions: executes tmux 'list-sessions' with custom format, parses output into TmuxSession array.
    export async function listSessions(): Promise<TmuxSession[]> {
      const format = "#{session_id}:#{session_name}:#{?session_attached,1,0}:#{session_windows}";
      const output = await executeTmux(`list-sessions -F '${format}'`);
    
      if (!output) return [];
    
      return output.split('\n').map(line => {
        const [id, name, attached, windows] = line.split(':');
        return {
          id,
          name,
          attached: attached === '1',
          windows: parseInt(windows, 10)
        };
      });
    }
  • Type definition (schema) for TmuxSession objects returned by listSessions().
    export interface TmuxSession {
      id: string;
      name: string;
      attached: boolean;
      windows: number;
    }
  • Utility helper to execute arbitrary tmux commands, used by listSessions().
    export async function executeTmux(tmuxCommand: string): Promise<string> {
      try {
        const { stdout } = await exec(`tmux ${tmuxCommand}`);
        return stdout.trim();
      } catch (error: any) {
        throw new Error(`Failed to execute tmux command: ${error.message}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does ('List all active tmux sessions') but doesn't describe how it behaves: no information about output format (e.g., list of session names, IDs, statuses), whether it includes inactive sessions, error handling, or any side effects. For a tool with zero annotation coverage, this leaves significant gaps in understanding its operational characteristics.

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 a single, clear sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a simple listing tool. Every word earns its place by specifying 'all active tmux sessions' rather than just 'sessions'.

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

Completeness2/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally adequate but incomplete. It doesn't explain what 'active' means in this context, what format the listing returns, or how this differs from similar tools like 'find-session'. For a tool in a server with multiple session-related tools, more contextual guidance would be helpful despite the simple structure.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100% (though trivial since there are no parameters). The description doesn't need to compensate for any parameter documentation gaps. It appropriately doesn't discuss parameters since none exist, earning a baseline score of 4 for this dimension.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('active tmux sessions'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'find-session' or 'list-panes', but the specificity of 'active tmux sessions' provides adequate distinction. This is not tautological since it adds meaningful context beyond just the tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'find-session' (which might search for specific sessions) or 'list-panes' (which lists panes within sessions). There's no mention of prerequisites, timing considerations, or explicit exclusions. The agent must infer usage from the tool name and description alone.

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

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