find-session
Locate a specific tmux session by its name to enable interaction and control within the Tmux MCP Server, facilitating terminal session management.
Instructions
Find a tmux session by name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the tmux session to find |
Implementation Reference
- src/index.ts:53-78 (registration)Registration of the find-session tool, including description, Zod input schema, and inline handler function that delegates to tmux.findSessionByName.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 }; } } );
- src/index.ts:56-58 (schema)Zod schema defining the 'name' parameter for the find-session tool.{ name: z.string().describe("Name of the tmux session to find") },
- src/index.ts:59-77 (handler)The tool handler logic: calls tmux helper, formats response as JSON or error message.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 }; } }
- src/tmux.ts:102-109 (helper)Core helper implementation: lists all sessions and finds the one matching the 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; } }
- src/tmux.ts:8-13 (schema)TypeScript interface defining the structure of a TmuxSession object returned by the tool.export interface TmuxSession { id: string; name: string; attached: boolean; windows: number; }