create-session
Initiate a tmux session with a specified name to facilitate terminal interactions within the Tmux MCP Server environment, enabling AI assistants to manage and monitor terminal activities.
Instructions
Create a new tmux session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the new tmux session |
Implementation Reference
- src/index.ts:176-196 (handler)MCP tool handler function for 'create-session'. Invokes tmux.createSession(name), formats success/error text response, and returns structured content.async ({ name }) => { try { const session = await tmux.createSession(name); return { content: [{ type: "text", text: session ? `Session created: ${JSON.stringify(session, null, 2)}` : `Failed to create session: ${name}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating session: ${error}` }], isError: true }; } }
- src/index.ts:173-175 (schema)Input schema definition using Zod: requires a 'name' string parameter.{ name: z.string().describe("Name for the new tmux session") },
- src/index.ts:170-197 (registration)Registration of the 'create-session' tool on the MCP server instance.server.tool( "create-session", "Create a new tmux session", { name: z.string().describe("Name for the new tmux session") }, async ({ name }) => { try { const session = await tmux.createSession(name); return { content: [{ type: "text", text: session ? `Session created: ${JSON.stringify(session, null, 2)}` : `Failed to create session: ${name}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error creating session: ${error}` }], isError: true }; } } );
- src/tmux.ts:162-165 (helper)Core helper function that executes the tmux 'new-session' command and retrieves the created session details.export async function createSession(name: string): Promise<TmuxSession | null> { await executeTmux(`new-session -d -s "${name}"`); return findSessionByName(name); }