MCPconceptExamples

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

Edit this page on GitHub

Rust MCP examples

tmux-mcp 0.1.2 · Source

The session example includes the complete Cargo project, program, setup commands, and expected output. It creates its own tmux server. The connection guide configures an existing MCP client to launch the executable instead.

List sessions

Send this params object through a connected client’s MCP tools/call method:

{
"name": "list_sessions",
"arguments": {}
}

Check whether the result reports a tool error before reading its structured content. Use the returned IDs to choose a window or pane. The list_sessions reference describes the result.

Internals

The complete example embeds both protocol endpoints in one Rust process. They exchange JSON-RPC over an in-memory stream and perform normal tool discovery. An installed MCP client is not needed to run it.

Choose tools in Rust

The example supplies the inspect selection to the embedded server. It checks that discovery contains the session-listing tool and excludes pane input. The selection topic describes other combinations.

Run the program

Follow the complete setup in a fresh directory. The program prints both session names, closes the protocol endpoints, stops its tmux daemon, and verifies that the socket has closed. Operation and cleanup errors both produce a failing exit status.

Esc

Type to search.

Reference previewOpen reference