Skip to main content
Glama
nickgnd

Tmux MCP Server

by nickgnd

find-session

Locate a specific tmux session by its name to enable AI assistants to interact with terminal content and manage session control.

Instructions

Find a tmux session by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the tmux session to find

Implementation Reference

  • The primary handler function for the "find-session" MCP tool. It takes the session name, calls the tmux helper to find it, and returns formatted JSON or error text.
    async ({ name }) => {
      try {
        const session = await tmux.findSessionByName(name);
        return {
          content: [{
            type: "text",
            text: session ? JSON.stringify(session, null, 2) : `Session not found: ${name}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error finding tmux session: ${error}`
          }],
          isError: true
        };
      }
    }
  • Input schema using Zod for the tool's 'name' parameter.
    {
      name: z.string().describe("Name of the tmux session to find")
    },
  • src/index.ts:53-78 (registration)
    Registration of the "find-session" tool on the MCP server, specifying name, description, schema, and handler.
    server.tool(
      "find-session",
      "Find a tmux session by name",
      {
        name: z.string().describe("Name of the tmux session to find")
      },
      async ({ name }) => {
        try {
          const session = await tmux.findSessionByName(name);
          return {
            content: [{
              type: "text",
              text: session ? JSON.stringify(session, null, 2) : `Session not found: ${name}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Error finding tmux session: ${error}`
            }],
            isError: true
          };
        }
      }
    );
  • Supporting helper function that implements the session lookup logic by listing all sessions and filtering by name.
    export async function findSessionByName(name: string): Promise<TmuxSession | null> {
      try {
        const sessions = await listSessions();
        return sessions.find(session => session.name === name) || null;
      } catch (error) {
        return null;
      }
    }
  • TypeScript interface defining the structure of a TmuxSession object returned by the tool.
    export interface TmuxSession {
      id: string;
      name: string;
      attached: boolean;
      windows: number;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does ('find a tmux session by name') but doesn't describe how it behaves—e.g., whether it returns session details, an error if not found, or requires specific permissions. This leaves critical behavioral traits unspecified for a tool that likely queries system state.

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, efficient sentence that directly states the tool's purpose without any fluff. It's appropriately sized for a simple tool and front-loaded with the essential information, making it easy to parse quickly.

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 lack of annotations and output schema, the description is incomplete for a tool that interacts with system sessions. It doesn't explain what 'find' entails—e.g., whether it returns session properties, a boolean existence check, or requires tmux to be running. For a tool with potential complexity in system interactions, this leaves significant gaps in understanding.

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?

The input schema has 100% description coverage, with the 'name' parameter clearly documented. The description adds no additional parameter semantics beyond what the schema provides, such as format constraints or examples. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't enhance understanding.

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 ('find') and resource ('tmux session by name'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list-sessions', which also deals with tmux sessions, leaving room for potential confusion about when to use one versus the other.

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 'list-sessions'. It doesn't specify whether this is for checking existence, retrieving details, or filtering results, nor does it mention any prerequisites or exclusions. The agent must infer usage from the tool name 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