Skip to main content
Glama
Tabby Copilot MCP
by annda7

Tabby Copilot MCP Plugin

An LLM MCP plugin for the Tabby terminal. It runs an MCP server inside Tabby, letting external agent clients (Claude Code, Codex, Gemini CLI, ZCode, etc.) connect over the MCP protocol and operate the real terminal sessions the user has already connected in Tabby. Multiple clients connecting sequentially or concurrently is an explicitly supported scenario.

Features

  • 6 MCP tools — list sessions, execute commands, read output, read the screen buffer, type raw keystrokes, abort a command

  • Clean execution mode — no marker injection, no automatic Ctrl+C, no subshell wrapping; the command is typed, its echo is verified, then Enter is sent; completion is determined by an output quiet period plus a hard timeout; every status honestly distinguishes "executed" from "not executed"

  • Stable session ids — session ids never drift as tabs come and go; every call re-validates that the session exists, is alive, and is connected

  • Bearer authentication — enabled by default; the token can be regenerated at any time

  • Controllable network exposure — binds to loopback 127.0.0.1 only by default; optional LAN listening (with a mandatory IPv4 allowlist — sources outside the allowlist always get 403 and are audited)

  • Dangerous-command policy engine — built-in block list (destructive commands + opaque/encoded execution), plus configurable custom allow/ask/block rules

  • Bounded approval — confirm-level commands raise a toast approval (Approve/Deny); timeout counts as denial; pending approvals stay visible in the MCP Console tab with inline actions

  • Audit log — execution-type calls, blocked/rejected attempts, approval decisions, and authentication rejections are all audited (viewable in the MCP Console)

  • MCP Console tab — a singleton tab opened from the toolbar button: call records, live output tailing, approval management, and one-click Terminate

Related MCP server: ChatGPT Gateway MCP Nyan

MCP Tools

Tool

Description

list_sessions

List currently connected terminal sessions (stable sessionIds that do not drift as tabs open/close)

exec_command

Execute a command in the given session (clean mode: no marker injection, no automatic Ctrl+C; the command is typed, its echo verified, then Enter is sent; completion is determined by a quiet period plus a hard timeout)

get_output

Read paginated output captured by exec_command (including output that arrives after the call has returned)

read_buffer

Read a snapshot of the terminal screen buffer (works for background tabs too)

send_input

Type raw keystrokes into the session as-is (interactive input, Ctrl+C, etc.)

abort_command

Send Ctrl+C to the session and stop tracking its active command

Installation

Build from Source

git clone <repository-url>
cd tabby-copilot-mcp

npm install
npm run build   # runs pug template validation first, then webpack (mirrors the official plugin recipe)

Install in Tabby

Tabby loads plugins from plugins/node_modules/ as npm packages. The plugin directory must be named tabby-copilot-mcp and contain both package.json and the built dist/ (the build is self-contained; no node_modules required):

plugins/
└── node_modules/
    └── tabby-copilot-mcp/
        ├── package.json          # from the repo root (keywords: ["tabby-plugin"], main: dist/index.js)
        └── dist/                 # the whole built folder

Windows:

C:\Users\<username>\AppData\Roaming\tabby\plugins\node_modules\tabby-copilot-mcp\

Linux:

~/.config/tabby/plugins/node_modules/tabby-copilot-mcp/

macOS:

~/Library/Application Support/tabby/plugins/node_modules/tabby-copilot-mcp/

Restart Tabby after copying.

Alternatively, use the deploy script scripts/deploy-to-tabby.sh: run it in Git Bash on Windows and it pulls package.json + dist/ from the build machine (Linux) and syncs them into the Windows directory above (connection parameters are configured in the script's CONFIG section; passing a local directory argument skips the pull and installs directly).

Usage

The service starts with Tabby (can be disabled in settings), listening on loopback 127.0.0.1:7777 by default, with Bearer authentication enabled by default.

Client Configuration

Every harness below connects to the same endpoint: Streamable HTTP at http://127.0.0.1:7777/mcp with a Bearer token. The generic shape (identical to the Client configuration preview on the settings page):

{
  "mcpServers": {
    "tabby": {
      "type": "http",
      "url": "http://127.0.0.1:7777/mcp",
      "headers": {
        "Authorization": "Bearer <your-token>"
      }
    }
  }
}

Claude Code

Project scope — put the JSON above in .mcp.json at the project root, or run:

claude mcp add --transport http tabby http://127.0.0.1:7777/mcp \
  --header "Authorization: Bearer <your-token>"

Add -s user for all projects, or -s project to write into the shared .mcp.json (typically committed — do not put a real token in it). Claude Code asks you to approve the server on first use.

Codex (OpenAI)

MCP servers live in ~/.codex/config.toml — the same path on Linux, macOS, and Windows (%UserProfile%\.codex\config.toml). Add one entry:

[mcp_servers.tabby]
url = "http://127.0.0.1:7777/mcp"

[mcp_servers.tabby.http_headers]
Authorization = "Bearer <your-token>"

http_headers is the officially documented way to attach static headers to every request of a streamable HTTP MCP server, so the token travels with the config file itself — no OS-level environment setup, identical on all platforms. Verify the entry with codex mcp list / codex mcp get tabby (header values are masked in the output). The token is stored in plain text in config.toml; if you prefer keeping it out of the file, bearer_token_env_var plus an OS environment variable is the alternative. Very old Codex versions additionally required experimental_use_rmcp_client = true at the top level of config.toml; add it if the server fails to connect.

Gemini CLI

Edit ~/.gemini/settings.json (global) or <project>/.gemini/settings.json (project):

{
  "mcpServers": {
    "tabby": {
      "httpUrl": "http://127.0.0.1:7777/mcp",
      "headers": {
        "Authorization": "Bearer <your-token>"
      }
    }
  }
}

httpUrl selects the Streamable HTTP transport and works on every released version (newest releases deprecate it in favor of url with "type": "http" — both connect to this server). Avoid a bare url without type: older versions select the legacy SSE transport for it and will not connect.

The CLI shortcut works too:

gemini mcp add --transport http tabby http://127.0.0.1:7777/mcp \
  --header "Authorization: Bearer <your-token>"

Add -s user for the global scope (default is project). Current versions write url with "type": "http", which connects correctly; if an older CLI writes url without type and the server fails to connect, edit the file to the httpUrl form above. Verify with /mcp inside the Gemini CLI.

ZCode

The generic JSON above works as-is in ~/.agents/mcp.json or a project-level .agents/mcp.json; in ZCode's own config file (~/.zcode/cli/config.json or a project-level .zcode/config.json), the server list lives under mcp.servers with the same fields. When both exist at the same scope, .zcode takes precedence.

Common notes

  • Same-machine clients: use http://127.0.0.1:7777/mcp. Note that 0.0.0.0 is the server-side bind address, not a client connection address.

  • LAN clients: first enable Listen on LAN in the Tabby settings page and configure the Allowed networks IPv4 allowlist (bare IPs or CIDR ranges; loopback is always allowed; the service refuses to start when the allowlist is empty or entirely invalid, and sources outside the allowlist always get 403 and are audited). Use the host machine's IP in the URL, e.g. http://192.168.0.78:7777/mcp; if a cross-machine connection fails, check the host firewall for inbound rules on that port first.

  • Token: view it in Tabby under Settings → Copilot MCP; it can be regenerated at any time (regeneration invalidates the old token immediately — update every client configuration accordingly). Never commit the real token to a repository or share it with untrusted parties — anyone holding the token can operate your terminals from any network the allowlist permits.

  • Tool list refresh: harnesses snapshot the MCP tool list when a session starts. After the plugin adds tools (e.g. a plugin upgrade), start a new client session — restarting Tabby alone is not enough.

To verify a token, send an initialize request (a wrong token returns 401, a correct one returns serverInfo; the Accept header is required, otherwise 406):

curl -s -X POST http://127.0.0.1:7777/mcp \
  -H "Authorization: Bearer <your-token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'

/health does not check the token and only tells you whether the port is reachable: curl http://127.0.0.1:7777/health (any JSON response means reachable; in LAN mode, sources outside the allowlist get 403).

Settings

Open Tabby settings (Ctrl+,) and go to the Copilot MCP page (changes save immediately; no Save button):

Setting

Description

Service status

Status badge + Start / Stop buttons (the service URL is shown alongside)

Start on boot

Start the service automatically when Tabby launches

Port

Listening port (default 7777; takes effect on next start)

Listen on LAN + Allowed networks

Bind 0.0.0.0 to listen on the LAN; an IPv4 allowlist (bare IPs or CIDR) is mandatory — the service refuses to start with an empty allowlist; authentication still applies on top

Authentication / Token

Bearer authentication toggle; view and Regenerate the token

Send raw input (send_input)

Enable/disable the send_input tool (when disabled, calls fail immediately with zero side effects)

Policy level

Built-in dangerous-command policy: relaxed (built-in dangerous commands always block) / moderate (they ask for approval instead) / strict (even commands matching no rule require approval); encoded execution is blocked at every level

Custom rules

Custom rules (regex + allow / confirm / block), evaluated in order with the first match winning; allow rules can override the built-in list

Quiet period (ms)

How long output must stay silent for a command to be considered finished (default 2000)

Hard timeout (ms)

Hard upper bound for a single exec_command (on timeout, the output captured so far is returned)

When the session is busy

When the session has a command in flight: reject (default) / queue (subject to the hard timeout) / abort (Ctrl+C the old command, then run)

Approval timeout (ms)

How long a confirm-level approval may stay pending (on timeout the command is denied and not executed)

Debug logging

Verbose plugin logging (automatic under --debug)

Debug endpoint

POST /api/tool/<name>: a debug channel that reaches every tool (same authentication/policy/audit pipeline; disabled by default)

Audit retention

Maximum number of audit log entries (oldest entries are evicted beyond the limit)

MCP Console

The MCP Console button on the right side of the Tabby toolbar (left of the settings gear) opens the MCP Console singleton tab: inspect call records and live output, manage pending approvals (inline Approve/Deny), and force-terminate in-flight commands (Terminate).

Security Model

Every feature in this project is designed with security as the baseline: the plugin operates real terminals, including SSH sessions and production servers. For the full rule set, see the "Security baseline" section of AGENTS.md.

  • Bearer authentication: enabled by default; every /mcp request must carry a valid token.

  • Network exposure: loopback-only by default; LAN listening mandates an IPv4 allowlist, layered on top of authentication.

  • Dangerous-command policy engine: exec_command and send_input share the same evaluation pipeline. The built-in block list covers destructive commands (rm -rf, mkfs, dd writing to devices, format, shutdown, etc.) and opaque execution (decoding via base64 etc. and piping the payload into a shell/interpreter, eval-ing decoded results, powershell -EncodedCommand, etc. — encoded payloads cannot be inspected by the policy and are always blocked; decoding data for non-execution purposes is unaffected). Custom rules are configurable; the first match wins, and allow rules can override the built-in list. The engine is a guardrail against mistakes, not a security boundary — it can still be bypassed by obfuscation.

  • Commands are sent in plain text: when the policy blocks a command or the user denies an approval, the client should ask the user — not rewrite, split, or encode the command to get around it.

  • Bounded approval: confirm-level commands (custom confirm rules, or any command matching no rule under the strict level) raise a toast approval (Approve/Deny); timeout counts as denial; pending approvals stay visible in the MCP Console tab with inline actions.

  • Audit: exec_command, send_input, and abort_command (including blocked and rejected attempts), list_sessions, approval decisions, and authentication rejections are all written to the audit log (viewable in the Console; entry count is bounded); read_buffer and get_output are read-only and are not logged.

  • Connected sessions only: there are no tools for creating sessions or initiating connections, and every call re-validates that the session exists, is alive, and is connected.

Development

Project Structure

src/
├── index.ts                       # Module entry point (provider registration, startup logic)
├── api.ts / config.ts / settings.ts / toolbar.ts
├── components/
│   ├── settingsTab.component.*    # Settings page UI
│   ├── consoleTab.component.*     # MCP Console tab
│   └── approvalToast.component.*  # Approval toast
├── services/
│   ├── mcpServer.service.ts       # HTTP service: transport, auth, allowlist, routing
│   ├── executor.service.ts        # Clean execution engine
│   ├── execPreflight.ts           # Pure pre-typing validation (multi-line / control characters)
│   ├── policy.ts                  # Dangerous-command policy engine
│   ├── approval.service.ts        # Bounded approval
│   ├── sessionRegistry.service.ts # Session registry (stable sessionIds)
│   ├── historyStore / outputStore / outputRing  # History, output capture, pagination
│   └── logger.service.ts          # Audit log
└── tools/                         # Registration and implementation of the 6 MCP tools

Build Commands

npm run build      # Production build (pug template validation first, then webpack)
npm run watch      # Watch mode for development
npm run test:pure  # Pure-logic unit tests (policy, preflight, status folding, etc.)
npm run smoke      # Transport-layer smoke tests (spins up a temporary service; covers concurrency, restart resilience, 401/405; no Tabby required)

Local Debugging

TABBY_PLUGINS=$(pwd) tabby --debug

Note: TABBY_PLUGINS does not work on Windows (the host splits the variable on :, and the drive-letter colon shreds the path) — on Windows hosts, use the deploy script above to install into %AppData%\tabby\plugins\. Changes touching terminal behavior must be verified on a Windows host.

Technical Details

  • Transport: MCP SDK stateless Streamable HTTP (a temporary Transport+McpServer pair per request, no session ids), so service restarts are transparent to authenticated clients; safe for concurrent multi-client use.

  • Execution semantics: every returned status answers "did this command actually run", with the boundary defined by whether Enter was sent — ok / timedOut / aborted / session-closed = submitted (may still be running or already in effect; never auto-retried); typing-failed / blocked / busy / rejected = zero execution, safe to retry. Submitted commands are never retried automatically.

  • Settings storage: written into Tabby's own configuration (the copilotMcp section of config.yaml), persisted through Tabby's configuration system.

  • Key dependencies: @modelcontextprotocol/sdk, express, zod; Angular 15 + rxjs 7 are provided by the host at runtime (webpack externals).

License

MIT

Acknowledgments

Documentation

All documents under docs/ are written in Chinese.

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
      Not graded
      quality
      D
      maintenance
      Provides secure, sandboxed terminal access for AI assistants via the Model Context Protocol, with multi-layer risk analysis and auditable command execution.
      22 npm
      8
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agent clients to safely connect to tools and execution resources through MCP with authorization, approvals, audit, chat-context isolation, SSH/Docker access, and long-running command session tracking.
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to interact with real terminal sessions across local and remote hosts, driving multi-turn interactive programs like TUIs, REPLs, and SSH prompts through MCP.
      76
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables external local AI agents to connect to VPS hosts, type into and read back from live SSH terminals, run commands, and trigger high-level plan-execute agent tasks over stdio or Streamable HTTP. Every write goes through a danger-command risk engine with configurable approval policies, capability toggles, and audited mcp provenance.
      MIT