Skip to main content
Glama

clarvis-mcp

clarvis-mcp is an MCP server that lets Claude on claude.ai (through a custom connector) read and drive the Claude Code sessions you run in tmux on your own machine. From a chat you can see what each tab is doing, read its conversation, type prompts, answer permission prompts and question menus, switch modes and open new sessions.

Warning: this lets a remote AI type into terminals on your machine. Anything you can type into a Claude Code tab, the connected chat can type too, and Claude Code runs commands. Anyone who gets your passphrase or a valid token can do the same. Read SECURITY.md before you install it, set up the allow-list, and keep the passphrase in a password manager.

Install

You need Python 3.11 or newer, tmux 3.2 or newer, and Claude Code. Install the command with uv or pipx:

uv tool install clarvis-mcp
# or
pipx install clarvis-mcp

From a checkout of this repository, uv tool install . works too.

Related MCP server: claude-mux.mcp

Quick start

  1. Create the config and the passphrase:

    clarvis-mcp init --public-url https://your-host.example

    This creates ~/.config/clarvis-mcp/ (with config.toml) and ~/.local/state/clarvis-mcp/, both mode 0700, and prints a new passphrase once. Put it in your password manager now.

  2. Edit ~/.config/clarvis-mcp/config.toml:

    • public_url: the https address your tunnel or reverse proxy publishes (see Tunnels), without /mcp.

    • [allow]: the tabs and directories clarvis-mcp may touch. It starts empty, and empty allows nothing: every tab tool refuses until you add something here.

  3. Run your Claude Code sessions as windows of a tmux session named main (or set tmux_session), for example tmux new -s main, then claude in each window.

  4. Check the install, then start the server:

    clarvis-mcp doctor
    clarvis-mcp serve

    The server listens on http://127.0.0.1:8766 and serves MCP at /mcp. doctor checks the public URL through your tunnel, so that line passes only once the tunnel and the server are both up; run clarvis-mcp doctor --offline to skip it.

Connect from Claude

Custom connectors are not available on every Claude plan, and where they live in the settings can change; check what your plan offers.

  1. In Claude, open Settings, then Connectors, and add a custom connector.

  2. Give it a name and the URL https://your-host.example/mcp (your public_url followed by /mcp).

  3. Connect it. A sign-in page headed "Authorize Claude to use clarvis-mcp?" opens; enter your passphrase.

  4. Turn the connector on in a chat. The tools listed under Tools appear.

Too many wrong passphrases lock the sign-in page for a while (see [limits] under Configuration); clarvis-mcp unlock clears a lockout.

Tunnels

clarvis-mcp listens only on 127.0.0.1:8766 by default. Something else has to publish it over https so claude.ai can reach it. Only these seven paths need to be public: /mcp (the MCP endpoint), /.well-known, /register, /authorize, /token, /revoke (OAuth) and /consent (the sign-in page).

Tailscale Funnel

Funnel publishes the server at https://<machine>.<tailnet>.ts.net. Publish each of the seven paths and nothing else:

tailscale funnel --bg --set-path /mcp http://127.0.0.1:8766/mcp
tailscale funnel --bg --set-path /.well-known http://127.0.0.1:8766/.well-known
tailscale funnel --bg --set-path /register http://127.0.0.1:8766/register
tailscale funnel --bg --set-path /authorize http://127.0.0.1:8766/authorize
tailscale funnel --bg --set-path /token http://127.0.0.1:8766/token
tailscale funnel --bg --set-path /consent http://127.0.0.1:8766/consent
tailscale funnel --bg --set-path /revoke http://127.0.0.1:8766/revoke

Then set public_url = "https://<machine>.<tailnet>.ts.net" in config.toml. tailscale funnel status shows what is published.

Cloudflare Tunnel

Create a tunnel for one hostname (cloudflared tunnel login, cloudflared tunnel create clarvis-mcp, cloudflared tunnel route dns clarvis-mcp clarvis.example.com) and point it at the local server. This config.yml forwards only the seven paths and answers 404 for everything else:

tunnel: <tunnel-id>
credentials-file: /path/to/<tunnel-id>.json

ingress:
  - hostname: clarvis.example.com
    path: ^/(mcp|\.well-known|register|authorize|token|consent|revoke)
    service: http://127.0.0.1:8766
  - service: http_status:404

Run it with cloudflared tunnel run clarvis-mcp and set public_url = "https://clarvis.example.com".

Any other HTTPS reverse proxy

Any reverse proxy with a valid certificate works (Caddy, nginx, and so on): forward the seven paths to http://127.0.0.1:8766 and keep the original Host header. The server accepts requests only for the host named in public_url (plus 127.0.0.1 and localhost), so public_url must be exactly the address the proxy serves.

Configuration

Settings live in ~/.config/clarvis-mcp/config.toml (more precisely $CLARVIS_CONFIG_DIR, else $XDG_CONFIG_HOME/clarvis-mcp, else ~/.config/clarvis-mcp). The file is read every time it is needed, so most edits (the allow-list, projects, limits, confirm) apply without a restart; public_url, host and port take effect when serve starts. Unknown keys and wrong types are refused with a message naming the key, so a typo fails loudly. clarvis-mcp init writes a commented template; this is every key it accepts:

# The https address the connector uses (your tunnel or reverse proxy), without /mcp. Required by `serve`.
public_url = "https://clarvis.example.com"

# Where the server listens. Keep it on loopback and let the tunnel publish it.
host = "127.0.0.1"
port = 8766

# The tmux session whose windows are the tabs.
tmux_session = "main"

# Project aliases for open_session and run_plan. One table per project; only path is needed to use the alias.
[projects.api]
path = "~/code/api"                  # the project directory
mode = "plan"                        # default, plan, auto, accept-edits or bypass
model = "opus"                       # passed to claude as --model
effort = "high"                      # low, medium, high, xhigh or max
prompt = "Run the plan at {plan}"    # run_plan's first prompt; {plan} becomes the plan path

# Which tabs and directories clarvis-mcp may touch. Empty or missing allows nothing.
[allow]
tabs = ["api", "web-*"]              # window names, exact or shell-style globs; never window numbers
dirs = ["~/code"]                    # a tab whose pane is in one of these is allowed; also where
                                     # open_session, open_window and run_plan may start

# Sign-in limits and token lifetimes (these are the defaults). All must be at least 1.
[limits]
per_address = 5                      # wrong passphrases from one address within the window lock it out
global = 20                          # wrong passphrases from all addresses within the window lock everyone out
window_seconds = 900                 # the counting window
lockout_seconds = 900                # how long a lockout lasts
access_token_seconds = 900           # access token lifetime
refresh_token_days = 30              # refresh token lifetime; the connector must sign in again after this

# Hold every acting call on a tab in bypass-permissions mode until confirm_action gets its code.
[confirm]
bypass_tabs = false

What the keys mean:

  • public_url, host, port, tmux_session: the environment variables CLARVIS_PUBLIC_URL, CLARVIS_HOST, CLARVIS_PORT and CLARVIS_TMUX_SESSION override them.

  • [projects.<alias>]: path, mode, model, effort and prompt are per-project defaults that the open_session and run_plan arguments override. Tools also accept any absolute directory instead of an alias. If CLARVIS_PROJECTS_FILE names a separate TOML file, its [projects] tables are used instead.

  • [allow]: a tab is allowed if its window name matches a tabs entry or its working directory is inside a dirs entry (~ is expanded; symlinks cannot escape). Window numbers are refused because they shift when windows close. roster shows only allowed tabs, plus a count of hidden ones.

  • [limits]: per_address, global, window_seconds and lockout_seconds control the sign-in limiter, which survives restarts; access_token_seconds and refresh_token_days set token lifetimes.

  • [confirm]: with bypass_tabs = true, an acting tool aimed at a tab in bypass-permissions mode does nothing and returns a six-digit code with a summary of the call (answering a question menu is exempt); confirm_action with that code runs the call once, within 120 seconds, from the same chat.

Other files:

  • Passphrase: ~/.config/clarvis-mcp/passphrase (0600; CLARVIS_PASSPHRASE_FILE overrides).

  • State, in ~/.local/state/clarvis-mcp/ ($CLARVIS_STATE_DIR, else $XDG_STATE_HOME/clarvis-mcp): oauth.json (clients and tokens), limiter.json (sign-in failures), audit.jsonl (the audit log; CLARVIS_AUDIT_PATH overrides) and summaries/ (saved handoffs; CLARVIS_SUMMARIES_DIR overrides).

  • Artifact registry: ~/.config/clarvis-mcp/artifacts.json (CLARVIS_ARTIFACTS_FILE overrides).

Commands

  • clarvis-mcp init [--public-url URL] [--force] [--import-tether]: creates the config and state directories (0700), writes the commented config.toml template unless one exists, and generates the passphrase if there is none, printing it once. Safe to run again. --public-url fills in public_url when the template is written. --force rewrites config.toml from the template; it never touches the passphrase. --import-tether copies the passphrase and OAuth state from an earlier install under the old name tether ($CLARVIS_TETHER_DIR, default ~/.config/tether) when they exist and are not already in place, so the connector stays signed in.

  • clarvis-mcp serve [--insecure-local]: runs the server. It refuses to start, with a message, when init has not been run, when public_url is missing or not https, when the port is taken, or when CLARVIS_ALLOW_ALL (a test-only switch that allows every tab) is set. --insecure-local allows a missing or http public_url when host is a loopback address, for local testing only.

  • clarvis-mcp doctor [--offline]: prints PASS, WARN or FAIL for: tmux installed and at least 3.2, the tmux session exists, Claude panes found, config valid, passphrase present and 0600, directories 0700, public_url is https, the port is free or held by clarvis-mcp itself, the allow-list is not empty, and (unless --offline) the public URL answers. Exits 0 only when nothing FAILs.

  • clarvis-mcp passphrase --rotate: writes a new passphrase, prints it once, and revokes every OAuth client and token. Every connector has to sign in again. Use this if the passphrase may have leaked.

  • clarvis-mcp revoke-all: revokes every OAuth client and token and prints how many were removed. The passphrase stays the same.

  • clarvis-mcp unlock: clears every sign-in lockout and failure count and prints what it cleared. (revoke-all does not do this.)

  • clarvis-mcp --version: prints the version.

Tools

A tab is a window of the configured tmux session, named by its number or its name. Every tool that touches a tab needs the tab named in the call: there is no current tab and no broadcast. Tools refuse tabs that are not allowed. Tools that act, and the reads that need Claude Code, also refuse panes that are not running Claude Code and screens they cannot read, and say why. Every tool that types, presses keys or opens a window writes a line to the audit log, refusals included.

Read

Tool

What it does

roster

Lists the allowed tabs: number, name, directory, whether it runs Claude Code, mode, busy or idle, draft present, tmux pane mode and any open question menu, plus a count of hidden tabs.

read_tab

Returns a tab's recent screen text, cleaned (40 lines by default).

tab_status

Reports a tab's mode, model line, idle or working, draft, pending permission prompt and question menu.

read_draft

Returns the text waiting in a tab's input box, without changing anything.

pending_permission

Returns a tab's permission prompt and its options, verbatim.

read_plan

Returns the tab's latest plan file (plan mode), read only from Claude Code's plans folder.

read_transcript

Returns the tab's conversation from its Claude Code session file: paged, searchable, optionally back through /clear.

Act

Tool

What it does

send_prompt

Types a message into a tab and presses Enter. Refuses if a different draft is waiting in the box.

write_draft

Types text into the input box without submitting, so you can review it. Refuses over an existing draft.

replace_draft

Clears the input box and types new text; never submits.

append_draft

Adds text to the end of the existing draft; never submits.

submit_draft

Presses Enter only if the box holds exactly the text you reviewed.

clear_draft

Empties the input box.

send_slash

Drafts (or with draft=false, sends) /model, /effort, /compact, /clear, /caveman:caveman or an installed skill or command.

set_manager_mode

Drafts (or sends) /manager-mode <text>; needs a manager-mode skill or command installed.

set_caveman_mode

Drafts (or sends) /caveman:caveman <level>; it switches the level and never sends a message.

interrupt

Presses Escape: stops the current turn or cancels a question menu.

answer_permission

Answers a permission prompt with allow (Enter) or deny (Escape).

choose_option

Picks an option on a question menu by number, label or free text (toggles it on a multi-select menu).

menu_next

Moves to the next or previous question of a multi-question menu.

menu_submit

Moves to the menu's Submit row and opens the review screen; with confirm=true also submits the answers.

set_mode

Switches a tab to default, plan, auto, accept-edits or bypass with Shift+Tab, checking after each press; errors if the mode is not reached.

confirm_action

Runs a call that [confirm] held back, given its code: once, within 120 seconds, from the same chat.

Open

Tool

What it does

list_projects

Lists the project aliases from config.toml.

open_session

Opens a new tmux window in a project (alias or absolute directory) and starts Claude Code there with an optional mode, model and effort. Returns the new tab.

open_window

Opens a new tmux window with a plain shell in a directory.

run_plan

Opens a session like open_session, then sends Run the plan at <plan_path> (or the project's or the call's own prompt). Returns the new tab.

Artifacts

Tool

What it does

list_artifacts

Lists the registered artifacts: URL, title, source file, last update and description.

read_artifact

Returns an artifact's description and its source file's text (up to 20000 characters).

register_artifact

Adds an artifact to the registry: URL, title, description and an optional source file (a regular file under your home directory).

Handoffs

Tool

What it does

compact_chat

Saves a markdown summary of the chat (goal, decisions, open items, what each tab is doing, known bugs, recap) plus facts the server adds, so a new chat can pick up.

list_handoffs

Lists the saved summaries, newest first.

load_handoff

Returns a saved summary (the latest by default), paged by characters.

Running as a service

Templates for both platforms are in deploy/. Each runs clarvis-mcp serve and restarts it on failure; all settings stay in config.toml. Run clarvis-mcp init and clarvis-mcp doctor first. The install steps are also in the comments at the top of each file.

Linux, systemd user service (deploy/clarvis-mcp.service):

mkdir -p ~/.config/systemd/user
cp deploy/clarvis-mcp.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now clarvis-mcp
loginctl enable-linger $USER          # optional: keep it running while you are logged out
journalctl --user -u clarvis-mcp      # its log

The unit expects the command at ~/.local/bin/clarvis-mcp; if which clarvis-mcp says otherwise, change ExecStart.

macOS, launchd LaunchAgent (deploy/com.clarvis-mcp.plist): launchd does not expand ~, so first replace YOUR_USER in the file's paths with your account name, check the command path against which clarvis-mcp, and make sure the PATH entry includes the folder that holds tmux. Then:

cp deploy/com.clarvis-mcp.plist ~/Library/LaunchAgents/
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.clarvis-mcp.plist
# stop and remove:
launchctl bootout gui/$(id -u)/com.clarvis-mcp

Its log is ~/Library/Logs/clarvis-mcp.log.

Supported versions

  • Operating systems: Linux and macOS.

  • tmux 3.2 or newer.

  • Python 3.11 or newer.

  • Claude Code: tested with Claude Code 2.1.332. clarvis-mcp reads Claude Code's screen, which can change between releases. The screen parser fails closed: on a layout it does not recognise, tools refuse to act and say so rather than guess.

Troubleshooting

  • Run clarvis-mcp doctor first. It checks tmux, the session, the config, the passphrase, permissions, the port, the allow-list and the public URL, and says what to fix.

  • A tab is "not allowed". Add its window name or its directory to [allow] in config.toml. No restart is needed.

  • A tab was left in tmux copy-mode (for example after scrolling with the mouse wheel). This is handled automatically: text is delivered through tmux buffers, which work in copy-mode, and every key press first leaves copy-mode. If a tmux call hangs, it is stopped after a timeout and the pane is taken out of the mode.

  • The connector shows no tools. Refresh the chat; if that does not help, remove the connector in Claude's settings and add it again. Check that serve is running and that the tunnel publishes all seven paths.

  • Lost passphrase. It cannot be shown again. Run clarvis-mcp passphrase --rotate for a new one, then sign in again from Claude.

  • Locked out of the sign-in page after wrong passphrases. Wait for lockout_seconds, or run clarvis-mcp unlock.

  • serve will not start. It prints the reason: run clarvis-mcp init, set an https public_url, or free the port.

  • A tool refuses with "not recognised" on a Claude tab. The screen did not match a layout the parser knows (an unusual state or a newer Claude Code). Look at the tab yourself; clarvis-mcp will not guess.

Development

uv sync
uv run pytest -q        # the full suite; tmux tests use a throwaway tmux server, never yours
scripts/smoke.sh        # builds the wheel and runs the CLI in a fresh venv with its own HOME

TESTING.md describes the test harness. CI runs the suite on Linux (tmux 3.2a and newer) and macOS with Python 3.11 to 3.13, runs the smoke test on the built wheel, and scans the history for secrets.

License

MIT. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables Claude Desktop to interact with and view tmux session content, allowing AI assistants to read from, control, and observe terminal sessions.
      13
      410 npm
      307
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Gives Claude Code full control over tmux sessions, windows, and panes, with an optional Sonnet-based safety classifier for destructive commands.
      11
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes interactive Claude Code CLI sessions running inside tmux across one or more machines as MCP tools, enabling agents to list, create, read, and drive those sessions over stdio.
      1
      MIT