Skip to main content
Glama
LukeLamb

claude-sessions-mcp

has_session

Read-only

Check existence of a named tmux session to confirm it can be targeted by capture_pane, send_keys, or kill_session.

Instructions

Check whether a named tmux session exists. Cheap precondition for capture_pane, send_keys, or kill_session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesSession name. Cannot contain ".", ":", "|", or whitespace.

Implementation Reference

  • The main handler function for the 'has_session' tool. It validates tmux availability, validates the session name, runs 'tmux has-session -t =<name>' and returns whether the session exists based on the exit code.
    async function hasSession(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, ['has-session', '-t', `=${args.name}`]);
      // `=name` asks tmux for an exact match. Exit 0 = exists, 1 = no such session.
      return textResult({ name: args.name, exists: r.code === 0 });
    }
  • The tool registration metadata including name, description, annotations, and inputSchema (requires a 'name' string property).
    {
      name: 'has_session',
      description: 'Check whether a named tmux session exists. Cheap precondition for capture_pane, send_keys, or kill_session.',
      annotations: { title: 'Check session exists', readOnlyHint: true, destructiveHint: false, openWorldHint: false },
      inputSchema: {
        type: 'object',
        properties: {
          name: { type: 'string', description: 'Session name. Cannot contain ".", ":", "|", or whitespace.' },
        },
        required: ['name'],
        additionalProperties: false,
      },
    },
  • server.js:326-334 (registration)
    The HANDLERS map that registers the 'has_session' function to be called when the tool 'has_session' is invoked.
    const HANDLERS = {
      list_sessions: listSessions,
      has_session: hasSession,
      list_windows: listWindows,
      capture_pane: capturePane,
      new_session: newSession,
      send_keys: sendKeys,
      kill_session: killSession,
    };
Behavior4/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false. Description adds that the operation is 'cheap', which is valuable behavioral context beyond annotations.

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 sentences, no wasted words, front-loaded with purpose. Efficient and clear.

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?

Given the simplicity of the tool (one parameter, no output schema), the description is complete: it explains purpose, usage context, and constraint hints.

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 coverage is 100% with the parameter name described and constraints noted. Description does not add additional semantic meaning beyond what the schema provides, so baseline 3 is appropriate.

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?

Description clearly states the tool checks if a tmux session exists, using a specific verb and resource. It distinguishes itself from sibling tools by mentioning it's a precondition for three specific actions.

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?

Description explicitly states it's a cheap precondition for capture_pane, send_keys, or kill_session, providing clear usage context. No exclusions or alternatives are mentioned, but the context is 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