Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Edit this page on GitHub

tmux-mcp 0.1.0-alpha.13 · 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 crate includes a complete stdio server with its tool selection chosen in Rust code. Use it when the offered surface is part of the embedding application’s policy.

Embed a read-only surfaceLink to section

//! Serve tmux over MCP, offering only the inspect toolset.
//!
//! The shipped binary reads `LIBTMUX_TOOLSETS` at startup. Building the server
//! yourself is how you decide it in code instead, which is
//! what you want when the surface is a property of the program rather than of
//! how someone launched it.
//!
//! ```console
//! $ cargo run --example readonly
//! ```
//!
//! Then talk MCP to it on stdin and stdout.
use libtmux::Server;
use rmcp::ServiceExt as _;
use rmcp::transport::stdio;
use tmux_mcp::{Selection, TmuxTools};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tools = TmuxTools::builder(Server::new()?)
.selection(Selection::parse(Some("inspect"), None, None)?)
.build();
// stdout carries the protocol, so this goes to stderr.
eprintln!("serving {} inspect tools", tools.offered().len());
tools.serve(stdio()).await?.waiting().await?;
Ok(())
}

The example waits until the transport ends. It selects libtmux’s ambient server, so choose the tmux environment before launching it. Application code can instead construct a Server for its own endpoint.

Run the source exampleLink to section

From the Rust repository with its toolchain and tmux installed:

Terminal window
$ cargo run \
-p tmux-mcp \
--example readonly

The process speaks MCP on stdin and stdout. It writes the selected tool count to stderr.

To inspect the configured tools and output schemas without starting a tmux server:

Terminal window
$ cargo run \
-p tmux-mcp \
--example surface

The readonly source and surface source are shipped crate examples. The crate’s test suite also drives an isolated real tmux server. Rendering this source is not an execution of the example.

See Topics for command deadlines and tool selection.

Esc

Type to search.