libtmux-mcp 0.0.1-alpha.12-SNAPSHOT · Source
Connect the server using the setup guide, then call
list_sessions from your MCP client.
List sessionsLink to section
This is the params object for an MCP tools/call request. Send it
through the connected client:
{ "name": "list_sessions", "arguments": {}}Use the returned session IDs when choosing a window or pane. The tool reference describes this port’s result and optional arguments.
InternalsLink to section
The following examples are for applications that embed or extend the server. Installing and connecting an MCP client does not require this code.
The public Java entry point accepts an existing libtmux Server.
An application can supply a custom MCP transport or use the stdio
entry point that the launcher uses.
Supply a transportLink to section
This method exposes the public serving contract:
import io.github.libtmux.Server;import io.github.libtmux.mcp.TmuxMcpServer;import io.modelcontextprotocol.server.McpSyncServer;import io.modelcontextprotocol.spec.McpServerTransportProvider;
public final class EmbeddedTmux { private EmbeddedTmux() {}
public static McpSyncServer serve( Server server, McpServerTransportProvider transport) { return TmuxMcpServer.serving(server, transport); }}Ownership of the transport transfers on entry. The returned MCP server closes it, including on failed startup. Close the returned server when your application’s serving lifetime ends.
The method reads selection from the process environment. Set that environment before creating the server. For a subprocess that manages its own lifecycle, use the launcher guide.
Inspect command completionLink to section
On a disposable session, use an MCP client to discover a pane and invoke
run_shell_command. Read its typed exit status and output. Use
capture_since for later screen changes; the prompt redraw can arrive
after the command’s completion signal.
The port’s MCP tests exercise transport and real tmux behavior. The documentation tests cover the port’s collected snippets; this page’s embedding wrapper is a source-derived adaptation, not one of those collected snippets.