MCPconceptHome

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.

MoreLess about this notice

Concept example A working example of the core library. It can change without notice. What concept means

Edit this page on GitHub

tmux MCP, built in C#

tmux terminal control for AI agents, built on libtmux for C# and MCP C# SDK. This server maps tmux's object hierarchy — sessions, windows, panes — into MCP tools grouped by the operation they request. The server enforces the selected groups at the MCP tool boundary.

tmux through MCP

Replay Hover a call to preview the tmux state after it. Use its pin button to hold it. With the replay focused, the arrow keys, Home and End step through the calls.

tmux before the first call.

tmux window of 1 pane
%0 sh
[checks] 0:sh*

tmux after create_session.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after split_window.

tmux window of 2 panes
%0 sh
%1 sh
[checks] 0:sh*

tmux after list_windows: unchanged, the call only reads.

tmux window of 2 panes
%0 sh
$ pytest -q
..                               [100%]
2 passed in 0.01s
%1 sh
[checks] 0:sh*

tmux after run_shell_command.

tmux window of 2 panes
%0 sh
$ pytest -q
..                               [100%]
2 passed in 0.01s
%1 sh
$ cat checks.log
2026-01-01 checks started
2026-01-01 checks finished
[checks] 0:sh*

tmux after run_shell_command.

No sessions

tmux after kill_session.

You

Create a tmux session called checks, split its window into two panes, run pytest -q in one and show checks.log in the other, show me the results, then remove the session.

AgentCreate the session.

create_session Execute {"name":"checks"}
Result
{
"changed": "Created session $0.",
"paneId": "%0",
"windowId": "@0",
"sessionId": "$0"
}

AgentSplit the pane the create result returned (%0) in two.

split_window Execute {"paneId":"%0","direction":"Right"}
Result
{
"changed": "Split %0; the new pane is %1.",
"paneId": "%1",
"windowId": "@0",
"sessionId": "$0"
}

AgentRead the window's layout.

list_windows Inspect {"session":"checks"}
Result
{
"result": [
{
"windowId": "@0",
"sessionId": "$0",
"index": 0,
"name": "sh",
"width": 80,
"height": 24,
"active": true,
"paneCount": 2,
"layout": "8205,80x24,0,0{40x24,0,0,0,39x24,41,0,1}"
}
]
}

AgentRun the tests in the pane the create result returned (%0).

run_shell_command Execute {"paneId":"%0","command":"pytest -q"}
Result
{
"paneId": "%0",
"exitStatus": 0,
"timedOut": false,
"output": {
"lines": [
".. [100%]",
"2 passed in 0.01s"
],
"truncated": false,
"droppedLines": 0,
"droppedBytes": 0
},
"elapsedSeconds": 0.48,
"effectiveTimeoutSeconds": 30,
"linesMissed": false,
"anchorLost": false,
"started": true,
"paneExited": false
}

AgentShow the log in the new pane the split returned (%1).

run_shell_command Execute {"paneId":"%1","command":"cat checks.log"}
Result
{
"paneId": "%1",
"exitStatus": 0,
"timedOut": false,
"output": {
"lines": [
"2026-01-01 checks started",
"2026-01-01 checks finished"
],
"truncated": false,
"droppedLines": 0,
"droppedBytes": 0
},
"elapsedSeconds": 0.025,
"effectiveTimeoutSeconds": 30,
"linesMissed": false,
"anchorLost": false,
"started": true,
"paneExited": false
}

AgentRemove the session once the result is read.

kill_session Teardown {"session":"checks"}
Result
{
"changed": "Killed session $0.",
"paneId": null,
"windowId": null,
"sessionId": "$0"
}
Agent

pytest printed 2 passed and checks.log ends with checks finished. I removed the checks session.

1/6

Install

Choose your client and configuration scope, then run the command or paste the configuration.

Terminal
Terminal
Terminal
Terminal
Terminal
Terminal
claude_desktop_config.json
claude_desktop_config.json
Terminal
.codex/config.toml
Terminal
.codex/config.toml
Terminal
Terminal
Terminal
Terminal
.cursor/mcp.json
~/.cursor/mcp.json
.cursor/mcp.json
~/.cursor/mcp.json
Terminal
Terminal
Terminal
Terminal
~/.gemini/config/mcp_config.json
~/.gemini/config/mcp_config.json
Terminal
Terminal
LibTmux.Mcp concept NuGet
$ claude mcp add tmux -- dnx LibTmux.Mcp --yes
$ claude mcp add tmux --scope user -- dnx LibTmux.Mcp --yes
$ claude mcp add tmux --scope project -- dnx LibTmux.Mcp --yes
First
$ dotnet tool install --global LibTmux.Mcp
$ claude mcp add tmux -- libtmux-mcp
First
$ dotnet tool install --global LibTmux.Mcp
$ claude mcp add tmux --scope user -- libtmux-mcp
First
$ dotnet tool install --global LibTmux.Mcp
$ claude mcp add tmux --scope project -- libtmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}
First
$ dotnet tool install --global LibTmux.Mcp
{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}
$ codex mcp add tmux -- dnx LibTmux.Mcp --yes
[mcp_servers.tmux]
command = "dnx"
args = ["LibTmux.Mcp", "--yes"]
First
$ dotnet tool install --global LibTmux.Mcp
$ codex mcp add tmux -- libtmux-mcp
First
$ dotnet tool install --global LibTmux.Mcp
[mcp_servers.tmux]
command = "libtmux-mcp"
$ gemini mcp add --scope user tmux dnx -- LibTmux.Mcp --yes
$ gemini mcp add --scope project tmux dnx -- LibTmux.Mcp --yes
First
$ dotnet tool install --global LibTmux.Mcp
$ gemini mcp add --scope user tmux libtmux-mcp
First
$ dotnet tool install --global LibTmux.Mcp
$ gemini mcp add --scope project tmux libtmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}
{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}
First
$ dotnet tool install --global LibTmux.Mcp
{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}
First
$ dotnet tool install --global LibTmux.Mcp
{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}
$ grok mcp add --scope user tmux -- dnx LibTmux.Mcp --yes
$ grok mcp add --scope project tmux -- dnx LibTmux.Mcp --yes
First
$ dotnet tool install --global LibTmux.Mcp
$ grok mcp add --scope user tmux -- libtmux-mcp
First
$ dotnet tool install --global LibTmux.Mcp
$ grok mcp add --scope project tmux -- libtmux-mcp
{
    "mcpServers": {
        "tmux": {
            "command": "dnx",
            "args": ["LibTmux.Mcp", "--yes"]
        }
    }
}
First
$ dotnet tool install --global LibTmux.Mcp
{
    "mcpServers": {
        "tmux": {
            "command": "libtmux-mcp"
        }
    }
}
$ opencode mcp add tmux -- dnx LibTmux.Mcp --yes
First
$ dotnet tool install --global LibTmux.Mcp
$ opencode mcp add tmux -- libtmux-mcp

Writes ~/.claude.json (this project).

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ~/.claude.json (all projects).

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes .mcp.json (in repo, version-controlled).

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ~/.claude.json (this project).

Installs the libtmux-mcp tool from NuGet.

Writes ~/.claude.json (all projects).

Installs the libtmux-mcp tool from NuGet.

Writes .mcp.json (in repo, version-controlled).

Installs the libtmux-mcp tool from NuGet.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Installs the libtmux-mcp tool from NuGet.

Writes ~/.codex/config.toml.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ~/.codex/config.toml.

Installs the libtmux-mcp tool from NuGet.

Codex's CLI doesn't support project scope yet — paste this into .codex/config.toml at the repo root.

Installs the libtmux-mcp tool from NuGet.

Writes ~/.gemini/settings.json.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes .gemini/settings.json (in repo).

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ~/.gemini/settings.json.

Installs the libtmux-mcp tool from NuGet.

Writes .gemini/settings.json (in repo).

Installs the libtmux-mcp tool from NuGet.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Installs the libtmux-mcp tool from NuGet.

Installs the libtmux-mcp tool from NuGet.

Writes ~/.grok/config.toml.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ./.grok/config.toml (in repo).

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ~/.grok/config.toml.

Installs the libtmux-mcp tool from NuGet.

Writes ./.grok/config.toml (in repo).

Installs the libtmux-mcp tool from NuGet.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Installs the libtmux-mcp tool from NuGet.

Writes ~/.config/opencode/opencode.jsonc.

Runs the server from NuGet without installing it; needs the .NET 10 SDK. Write LibTmux.Mcp@<version> to pin a version.

Writes ~/.config/opencode/opencode.jsonc.

Installs the libtmux-mcp tool from NuGet.

LibTmux.Mcp is a .NET tool package whose executable is libtmux-mcp. It serves tmux tools and a static capability resource over standard input and output.

The tool targets .NET 8 and .NET 10 and requires a POSIX host with tmux. Its registered operations include capture_pane, run_shell_command, and capture_since.

Toolsets

Use LIBTMUX_TOOLSETS=inspect for discovery and terminal reads. Additional toolsets enable changes, execution, and teardown. The tool-selection topic explains exact-name filters, defaults, and the capability resource. The complete examples include project files and cleanup for their owned tmux servers.

Workspace Manager is the separately packaged LibTmux.Workspace library. The MCP catalog does not include a workspace-file operation.

Package contract.

Tools by tier

The C# server groups its tools by what they request. A tier badge tells you how far a call reaches before you approve it. Set LIBTMUX_TOOLSETS to a comma-separated list of tiers, such as inspect,manage, to offer only those tools.

Inspect

Request tmux state and terminal output.

  • call_read_tools_batch Inspect Execute up to 16 declared inspect operations serially.
  • capture_pane Inspect Read the text a pane is showing, and optionally its scrollback.
  • capture_since Inspect Read only what a pane has printed since the last call.
  • find_pane_by_position Inspect Find the pane sitting at an index within a window.
  • get_pane_info Inspect Read one pane's size, title, running command, working directory, process ID, history size and limit, and whether it is active, dead, zoomed, in a mode or the pane this server runs in.
  • get_server_info Inspect Read the tmux server's version and how many sessions, windows and panes it holds.
  • get_session_info Inspect Read one session's name, ID, window count and whether a client is attached, without listing every session.
  • get_tmux_variables Inspect Expand named tmux format variables for a pane, such as session_name or window_width.
  • get_window_info Inspect Read one window's name, index, size, layout, pane count and whether it is its session's current window, without listing every window.
  • list_panes Inspect List tmux panes, optionally within one session or window.
  • list_sessions Inspect List the tmux sessions.
  • list_windows Inspect List tmux windows, optionally within one session.
  • search_panes Inspect Find which panes are showing text matching a regular expression.
  • show_environment Inspect Read the tmux environment.
  • show_hooks Inspect Read the hooks tmux will run on its own events.
  • show_option Inspect Read tmux options at the server, session, window or pane level.
  • snapshot_pane Inspect Read a pane's visible content together with its cursor position, size and running command, in one call.
  • wait_for_text Inspect Wait until a pane prints something matching one of these patterns, then return.

Manage

Change tmux structure or presentation.

  • move_window Manage Move a window to another index, or into another session.
  • rename_session Manage Rename a tmux session.
  • rename_window Manage Rename a tmux window.
  • resize_pane Manage Resize a pane, or zoom it to fill its window.
  • resize_window Manage Resize a window to a width and height in cells.
  • select_layout Manage Arrange a window's panes with a named layout — even-horizontal, even-vertical, main-horizontal, main-vertical, tiled — or a layout string read from list_windows.
  • select_pane Manage Make a pane the active one in its window.
  • select_window Manage Make a window the current one in its session.
  • set_history_limit Manage Set how many scrollback lines tmux keeps.
  • set_mouse_enabled Manage Turn tmux mouse support on or off.
  • set_pane_title Manage Set a pane's title.
  • signal_channel Manage Signal a tmux wait-for channel, releasing whatever waits on it.
  • swap_pane Manage Swap two panes' positions.
  • wait_for_channel Manage Block until something signals a tmux wait-for channel with 'tmux wait-for -S <channel>'. Use when you composed a shell command that signals it.

Execute

Start or drive pane processes, or store state that can control later execution.

  • create_session Execute Create a detached tmux session and return its ids.
  • create_window Execute Create a window in a tmux session and return its ids.
  • paste_text Execute Paste a block of text into exactly one pane through a tmux buffer.
  • respawn_pane Execute Only restarts a pane whose command has ALREADY EXITED.
  • run_shell_command Execute Run a shell command in a pane with your user's permissions.
  • send_keys Execute Send raw keystrokes to a pane and return immediately.
  • send_keys_batch Execute Send several keystrokes to one pane in order, in a single call.
  • set_synchronize_panes Execute Turn synchronize-panes on or off for a window.
  • split_window Execute Split a pane and return the NEW pane's id.

Teardown

Delete tmux objects or retained scrollback. Not reversible.

  • clear_pane_scrollback Teardown Delete a pane's scrollback history, keeping what the screen shows.
  • kill_pane Teardown Close a pane and end its program.
  • kill_session Teardown Close a session with all its windows and panes.
  • kill_window Teardown Close a window and every pane in it.

Browse every tool, with its arguments, result and protocol data.

Esc
Search in

Type to search.

Reference previewOpen reference