Skip to main content
The mcp_servers.json file defines which MCP servers ChatCLI should connect to. It is loaded automatically at session startup.

Location

In client mode (TTY), simply create the file at ~/.chatcli/mcp_servers.json — ChatCLI auto-detects and initializes servers without needing environment variables.

Auto-Enable (detection rules)

ChatCLI initializes the MCP subsystem — manager + hot-reload watcher — automatically when any of the conditions below holds:
The third rule keeps hot-reload working from first use. If you open ChatCLI before having an mcp_servers.json (typical first-install scenario), the watcher on ~/.chatcli/ is already running — just create the file and servers come up on the spot, no chatcli restart needed.

Hot-Reload and Error Tolerance

The mcp_servers.json watcher reconciles the live state with what’s on disk via fsnotify. Create, Write, Rename and Remove events are debounced at 400 ms to avoid mid-write reloads when editors rewrite via rename.
Saving an invalid JSON does not crash ChatCLI: the manager stays registered and the watcher keeps running. Fix the file in your editor, save it, and the next event triggers Reload normally. Useful when editing live during a session.

Format


Fields

Core (required)

Tier 1 — direct runtime effect

Tier 2 — additional capabilities

Tier 3 — Catch-all (Extensions)

Any JSON key that isn’t one of the fields above is preserved verbatim when chatcli rewrites the file. Useful for pasting configs from other clients (AWS EKS MCP, Cline, Cursor) without losing vendor-specific annotations. Important:
  • Unknown keys are ignored by the chatcli runtime — they only survive the save/load round-trip.
  • They cannot shadow a typed field: a hand-edited JSON with Extensions["command"] will never override the real command.
  • When a key is promoted to a typed field in a future release (e.g. oauth2), the content already in Extensions migrates automatically.

Environment Variables (env)

The env field accepts a key-value object that is merged with the parent process environment (os.Environ()). Two important rules:

1. PATH and cache inheritance

The MCP process inherits ChatCLI’s full environment before the env overrides apply. Without that inheritance, launchers like npx, uvx, docker and pipx wouldn’t find their binaries or per-user caches.
The child server receives PATH + HOME + FS_LOG_LEVEL=debug — not FS_LOG_LEVEL in isolation. If a key in env collides with the inherited environment, the env value wins (Unix semantics: last assignment in cmd.Env takes precedence).

2. ${VAR} / $VAR expansion

Values in env go through os.Expand against the parent environment before reaching the child. This lets you keep secrets out of the JSON — in shell variables, or in .env files loaded via source / direnv / mise / asdf.
If the shell has GH_TOKEN=ghp_xxx exported, the MCP server receives GITHUB_TOKEN=ghp_xxx. If the referenced variable doesn’t exist, the result is the empty string — same behavior as the shell. Lint your shell before assuming the token made it through.
Always prefer ${VAR} over literal values ("GITHUB_TOKEN": "ghp_xxx"). Plaintext tokens in JSON end up in git history, logs, backups and screenshots. The ${VAR} expansion is the idiomatic form — parity with Claude Desktop and OpenCode.
Expansion happens once at process spawn. If you change GH_TOKEN in the shell during a session, an MCP server already running keeps the old value. Use /mcp restart <name> to force re-resolution.

Auto-approval and Trust

ChatCLI’s tool-execution pipeline emits an audit log for every MCP invocation that autoApprove, alwaysAllow or trust covers. The Manager.ShouldAutoApprove(toolName) helper consulted by the pipeline is already in place for the future interactive approval gate on the coder-mode MCP path.

autoApprove / alwaysAllow

Lists of tool names that bypass the approval gate. Accept "*" (any tool on the server). Names can be used with or without the mcp_ prefix — "read_file" and "mcp_read_file" both match.
alwaysAllow is an alias popularized by Cline — chatcli folds the two lists into the same runtime set, so copy-pasting a Cline config works without renaming.

trust: true

Auto-approves every tool on the server, no need to list them one by one:
trust: true is intended for servers the operator has separately vetted (audited code, immutable container, etc.). ChatCLI emits a warning at startup every time it connects with trust: true so the choice is visible in logs — a trust config committed by accident never goes silent.

Audit log

Every auto-approved call produces an info-level entry:
Grep the chatcli log (CHATCLI_LOG_LEVEL=info or higher) to audit everything that took the bypass.

Tool filtering

When a server exposes dozens of tools but the workflow only uses a subset, hiding the rest saves tokens on every LLM turn.

disabledTools (blocklist)

Accepts "*" (hides everything — useful to mute a server without removing the entry).

enabledTools (allowlist — takes precedence)

When non-empty, only the listed tools are exposed. disabledTools on the same server is ignored. /mcp status shows the count of hidden tools (blocklist) or the total tool count when the allowlist is active.

Timeouts

Defaults cover the common case (npx -y cold start). Override when a server takes longer by design.

timeout (seconds)

Cap per RPC call. Default 60s. Applies to both tools/call and tools/list.

initTimeout (seconds)

Cap on the MCP initialize handshake — and, in SSE, on the endpoint-event wait. Default 10s. Bump for servers that load credentials, perform an auth handshake, or set up the environment at startup:
SSE: the http.Client.Timeout is set to max(timeout, initTimeout) so a short timeout does not kill the SSE GET (which stays open for the lifetime of the connection).

Working directory (cwd) — stdio

  • Accepts ${VAR} / $VAR expansion (same lookup as env).
  • Accepts leading ~/ expanded against HOME.
  • Validated at spawn: a missing path or non-directory fails the connection with an actionable error instead of silently inheriting chatcli’s CWD.
  • Empty = inherits chatcli’s CWD (legacy behavior).
Ignored for SSE.

HTTP headers and authentication — sse / http

Both HTTP transports (sse and http) share the same custom-header and typed-auth machinery.

headers

Extra headers attached to every HTTP request the transport makes:
  • sse: GET on the stream + POSTs of JSON-RPC messages.
  • http: every JSON-RPC POST to the Streamable HTTP endpoint.
Values go through ${VAR} expansion (same lookup as env).

HTTP Authentication (auth)

Typed block with three modes:

bearer

Produces Authorization: Bearer <token>.

basic

Produces Authorization: Basic base64(user:pass).

header (custom)

Produces X-API-Key: <token>. When header is omitted, the default is X-API-Key.
Safety rails: empty type is no-op even with token/username populated (so a half-completed config does not leak credentials). A token whose env var is undefined suppresses the header entirely instead of sending an empty Authorization: Bearer (which would pass a naive auth-presence check on the server).
Authorization/custom headers are re-applied on every request, so rotating the env var at runtime makes the next call carry the fresh token — no /mcp restart needed.

OAuth 2.1 (interactive, no config)

The three auth modes above are for pre-minted tokens. When a remote server instead challenges with 401 + an OAuth flow (e.g. the AWS MCP server), you do not configure auth at all — ChatCLI discovers the authorization server, registers a client dynamically, runs a PKCE browser flow, and stores/refreshes the token in the encrypted auth store automatically. Authorize with /mcp login <name> or let the agent call @mcp-login. See OAuth 2.1 authorization. Optional env var: CHATCLI_MCP_OAUTH_PORT (loopback callback port, default 8765).

Metadata (description, tags, category)

Cosmetic fields rendered in /mcp status so it’s easy to tell servers apart when many are connected:
Each output line is opt-in: configs without any of these fields render exactly like before v1.115.

Channel subscriptions (channels)

When an MCP server emits push notifications (JSON-RPC messages without id), ChatCLI forwards them to the MCP Channels ring — a durable structure that feeds the system prompt, the inbox banner, and the trigger engine. The channels field on the server config is an allow-list of channel names: only literally listed channels are accepted for that server. Useful when a server is chatty across multiple categories (e.g. emits both ci-pipeline and deploys/staging and metrics/raw) but your workflow only cares about a slice.
Matching is literal (no glob support here). "channels": ["alerts"] does not match "alerts/critical". Use the exact channel name the server emits. Globs (alerts/*) only exist in trigger rules (triggers.json), which run after this filter.
Filtering happens at receive time — before the in-memory ring and before persistence. Rejected channels do not consume the ring budget and do not appear in /channel list. Works across all three transports: sse (via stream), http (via GET listener) and stdio (via notifications on stdout). See MCP Channels for what happens after the filter.

Trigger rules (~/.chatcli/mcp/triggers.json)

Separate file from mcp_servers.json, opt-in, describes how ChatCLI should react to channel events. Without this file, channels work only as a passive inbox. With it, you define rules that fire banners, yes/no prompts or autonomous agent runs.

Location

Auto-loaded on startup when MCP is enabled. Manual reload: /channel rules reload.

Schema

Fields

Modes — summary

Validation

Parse failures reject the entire file (atomic apply — either all rules land, or nothing changes). On reload with an error, ChatCLI keeps the previous rules active and shows the error in the output. Typical errors:

Ready-to-use examples

Passive CI watcher

Prod alerts with confirmation

Autonomous canary deploys

Ring persistence

Separate from rules, ChatCLI keeps a durable JSONL file at ~/.chatcli/mcp/channels.jsonl with every received message. Rotates at 10 MiB to channels.jsonl.1 (one backup). Automatic replay on boot (last 200 messages). Full details: MCP Channels — Persistence.

Examples by Transport

Local servers communicating via stdin/stdout with JSON-RPC 2.0:
ChatCLI manages the process lifecycle: starts on init, kills on shutdown. Content-Length framing (LSP-style) is used for communication.

Testing with curl

Useful for isolating proxy / CA / handshake issues before involving ChatCLI. The wire shape is the same the http transport emits:
Key flags:
  • -i prints response headers (for the Mcp-Session-Id).
  • -N disables buffering — if the server replies with SSE, you see events arriving in real time rather than waiting for the body to close.
If curl works but ChatCLI hangs for 10s, it’s almost always a corporate proxy that isn’t exported (Go honors HTTPS_PROXY/HTTP_PROXY/NO_PROXY from the shell — curl reads ~/.curlrc, Go does not) or an internal CA missing from the trust store Go sees (SSL_CERT_FILE=/path/corp-ca.pem resolves it).

Full Examples

Multiple Servers

Never commit tokens or passwords in the config file. Use the ${VAR} syntax (documented above in Environment Variables) so secrets come from the shell — never from the JSON.

Protocol

ChatCLI speaks MCP Protocol v2024-11-05 (advertised on initialize) over three transports:
  • stdio — JSON-RPC 2.0 over the child process’s stdin/stdout (newline-delimited).
  • sse — HTTP+SSE shape from the original spec (GET /sse + POST /messages).
  • http — Streamable HTTP from the 2025-03-26 spec revision (single POST to the configured endpoint).
Supported methods:

Tool Naming

The mcp_ prefix is added automatically to avoid collisions with native tools (plugins, @coder, @webfetch, etc.).

Check modelcontextprotocol.io for the complete list of available MCP servers.

Troubleshooting

Check:
  1. The command exists and is in PATH (which npx)
  2. Config file is at ~/.chatcli/mcp_servers.json
  3. enabled is true
  4. Use /mcp status to see connection errors
  5. Use /mcp logs <name> to see the server’s recent stderr (npm 404, panic, missing executable)
  6. Check logs with CHATCLI_LOG_LEVEL=debug
The cause is almost always one of two things:
  1. Variable not exported in the shell${GH_TOKEN} in the config expands to empty if GH_TOKEN isn’t in os.Environ(). Confirm with echo $GH_TOKEN before starting ChatCLI.
  2. Token rotated mid-session — expansion happens at spawn. After exporting the new variable, run /mcp restart <name> to force a re-spawn with the updated environment.
To inspect what the server actually received, open /mcp logs <name> — MCP servers usually log “missing token” / 401 to stderr.
With the hot-reload fixes, the watcher starts when the parent directory exists — even without the file. If you never created ~/.chatcli/, there is no watcher.Fix: create the directory once (mkdir -p ~/.chatcli) and restart ChatCLI. From then on, creating/editing mcp_servers.json triggers reload automatically.To force a manual reload at any time: /mcp reload.
No. When LoadConfig fails (0 bytes, invalid JSON), ChatCLI logs a warning but keeps the manager + watcher running. Fix the JSON in your editor, save it, and the next event triggers Reload normally — no session restart needed.
  1. The server may not support tools/list
  2. Use /mcp tools to list discovered tools
  3. Restart with /mcp restart
Default per-call timeout is 60s (covers npx -y cold start). If a specific server takes longer:
  1. Bump timeout (seconds) on that server’s config only — see Timeouts.
  2. If failure is during the handshake (not the call), bump initTimeout separately.
  3. For long-running servers (LLM proxies, slow agents), prefer SSE — the stream stays open while the server processes.
Check:
  1. autoApprove or alwaysAllow in the config lists the tool name (or "*") — see Auto-approval.
  2. trust: true on the server is a full bypass. Every auto-approved call emits an info-level log MCP tool auto-approved by config tool=<name>. Grep the chatcli log to audit.
  3. To remove the bypass, edit the JSON (hot-reload reapplies) or run /mcp reload.
  1. Confirm the env var referenced by auth.token/headers is exported in the shell. ${UNSET_VAR} expands to an empty string and ChatCLI suppresses the entire header instead of sending Authorization: Bearer (empty) — so the server reports 401 as if no auth was attempted.
  2. Rotated the token in the shell? Headers are re-applied on every request, no /mcp restart needed. But confirm the shell that started ChatCLI has the new variable (export, source, etc.).
  3. For type: "header" with a custom name, confirm the server expects exactly the configured name (ChatCLI sends literally what’s in auth.header).
Returned by Streamable HTTP servers that check the first media type in Accept as the client’s preference (FastMCP, some MCP gateways). ChatCLI sends Accept: text/event-stream, application/json in that exact order since the first release with transport: "http" — so this error only appears if you override Accept via headers in the config. Remove the Accept entry from headers and the transport falls back to the default.
Almost always one of three causes (in probability order):
  1. Corporate proxy not exported. Curl reads ~/.curlrc (with proxy=...), Go does not. Export HTTPS_PROXY, HTTP_PROXY and NO_PROXY in the shell that runs ChatCLI — our http.Client uses http.DefaultTransport, which honors those three variables natively.
  2. Missing trailing slash in url. FastMCP / Starlette / FastAPI servers 307-redirect /mcp to /mcp/. Go follows the 307 on POST, but proxies in the path frequently break the redirect (body or headers dropped). Configure url with the slash exactly as the server answers 200 OK in curl.
  3. Corporate CA outside the trust store Go sees. On macOS especially, CAs added via a mobile-config profile are sometimes not picked up. Export SSL_CERT_FILE=/etc/ssl/certs/corp-ca.pem pointing to the same bundle curl uses.
To distinguish, bump initTimeout to 60 or 120 in the config — if it goes from “hangs at 10s” to “responds in 30s”, it’s a slow proxy; if it keeps hanging, it’s (1) or (2).
Likely hidden by config:
  1. disabledTools lists its name — remove it or flip to enabledTools.
  2. enabledTools is populated but the tool isn’t in the allowlist — add it or clear enabledTools to return to the default “all visible”.
  3. /mcp status shows the hidden-tool count (blocklist).
Check:
  1. The name in overrides exactly matches the plugin name, including the @ (e.g., "@webfetch", not "webfetch")
  2. The MCP server is connected (/mcp status)
  3. The server’s enabled field is true
  4. If the server crashed and reconnected, the override resumes automatically on the next conversation turn
The overrides field only hides the built-in — it does not validate whether the MCP server actually provides an equivalent tool. If you set "overrides": ["@webfetch"] but the MCP server has no web_fetch tool, the LLM simply won’t have that capability. Remove the override or add the tool to the MCP server.
Remove the built-in from the MCP server’s overrides list. Both tools (MCP and built-in) will be visible simultaneously and the LLM will choose based on each tool’s name and description.