Codumentor logo Codumentor Enterprise

MCP (Model Context Protocol)

Connects Codumentor to MCP servers so the
agent can use their tools — a filesystem browser, a clock, a web fetcher, your
issue tracker, anything published as an MCP server. The plugin ships with
Codumentor; you only need the server itself (often just npx or uvx, which
download it on first use). Each plugin entry is one server: a local process
(executable) or a remote endpoint (url), never both. Add one entry per
server.

Quick start

  1. Open your config file. On a community install that is ~/.codumentor/config.yaml (Windows: C:\Users\<you>\.codumentor\config.yaml; $CODUMENTOR_HOME/config.yaml if you set that variable). The first start — or codumentor init — writes it as a full copy of the bundled defaults, so it already has a plugins: list, with a commented-out MCP example in it. On a server install, edit the instance's own YAML.
  1. Add an entry to that plugins: list. This one starts the official test server, which needs only Node.js:

```yaml
plugins:
# … the entries already there stay as they are …

Your file has no plugins: list (a hand-written overlay)? Do not start
one — it would replace the built-in list and switch every other extension
off. Use plugins_overrides: with the same entry instead; see
Several servers and plugins_overrides.

  1. Restart Codumentor. Servers are started at startup; a config change is not picked up by a running instance.
  1. Check it connected. The log (~/.codumentor/logs/ on a community install) has one line per server:

``
MCP client for everything started with 22 tools; …
``

Then ask the agent: "Use the echo tool to say hello." If the line is
missing or says the start failed, see Troubleshooting.

Recipes

Each block is one entry for the plugins: list; only args: differs, so the
module:/class: lines are shown once:

  - module: codumentor.plugins.mcp
    class: MCPPlugin
    args:
      # … one of the args blocks below …

Test server — every protocol feature, harmless (npm package
@modelcontextprotocol/server-everything):

    args:
      name: everything
      executable: npx
      args: ["-y", "@modelcontextprotocol/server-everything"]

Filesystem — read and edit files under the directories you list
(@modelcontextprotocol/server-filesystem; the directories on the command line
are the whole allow-list):

    args:
      name: notes
      executable: npx
      args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/you/notes"]

Use absolute paths. When the server runs sandboxed it sees your
repos at /workspace (read-only unless sandbox.workspace: rw) and nothing
else of the host, so point it at /workspace or add the directory to
sandbox.ro_binds / rw_binds.

Time — current time and timezone conversion (Python, via
uv):

    args:
      name: time
      executable: uvx
      args: ["mcp-server-time", "--local-timezone", "Europe/Budapest"]

Fetch — fetch a web page as Markdown. It refuses private and loopback
addresses unless given --allow-private-ips:

    args:
      name: fetch
      executable: uvx
      args: ["mcp-server-fetch"]

Remote server with a token — GitHub's hosted MCP server takes a personal
access token as a bearer header. With ${secret:…} every user supplies their
own token (Settings → User Secrets; requires the user_secrets plugin):

    args:
      name: github
      url: "https://api.githubcopilot.com/mcp/"
      headers:
        Authorization: "Bearer ${secret:github_token}"

A token shared by the whole instance can instead come from an environment
variable: Authorization: "Bearer ${GITHUB_TOKEN}".

Remote server with OAuth — each user signs in in their own browser. Works
with servers that support dynamic client registration, for example Linear's:

    args:
      name: linear
      url: "https://mcp.linear.app/mcp"
      oauth: true

Users then connect it in Settings → Extensions → MCP Servers; see
OAuth. (GitHub's server does not offer dynamic registration — use the
token recipe above for it.)

SSE server — an older server on the deprecated HTTP+SSE transport. A URL
ending in /sse is detected automatically; set transport only when it is not.
To try it locally, run the test server in SSE mode
(PORT=3001 npx @modelcontextprotocol/server-everything sse) and add:

    args:
      name: everything-sse
      url: "http://127.0.0.1:3001/sse"
      transport: sse        # optional here: "auto" already picks SSE for /sse

The same server's Streamable HTTP mode (… server-everything streamableHttp)
answers at http://127.0.0.1:3001/mcp.

Coming from Claude Desktop, Cursor or VS Code

Those clients describe servers in JSON (mcpServers in Claude Desktop and
Cursor, servers in VS Code's mcp.json). Each JSON entry becomes one plugin
entry:

JSONCodumentor args:
the entry's key, e.g. "filesystem"name: filesystem
commandexecutable
argsargs (same list)
envenv (same map)
urlurl
headersheaders
type: "stdio"nothing — implied by executable
type: "http" / "streamable-http"nothing (or transport: streamable_http)
type: "sse"transport: sse (automatic when the URL ends in /sse)
${env:VAR} (VS Code)${VAR}
${input:…} prompts (VS Code)${secret:…} — a per-user secret

Claude Desktop:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/you/notes"],
      "env": { "NODE_OPTIONS": "--max-old-space-size=512" }
    }
  }
}

Codumentor:

plugins:
  - module: codumentor.plugins.mcp
    class: MCPPlugin
    args:
      name: filesystem
      executable: npx
      args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/you/notes"]
      env:
        NODE_OPTIONS: "--max-old-space-size=512"

One difference matters: a server is started with a minimal environment
(PATH, HOME, LANG, TERM) plus what env: sets — not your whole shell
environment. An API key the server reads from the environment must be listed
under env: (e.g. BRAVE_API_KEY: "${BRAVE_API_KEY}").

Configuration reference

Exactly one of executable or url must be set.

Local (stdio) servers

Remote servers

Both

What the agent sees

Tools keep the names the server gives them (plus tool_prefix, if set); logs
show them with an [MCP] prefix, e.g. [MCP] read_file(path='/notes/todo.md').
A name is offered once: a built-in Codumentor tool keeps its name, and when two
servers offer the same name, the one configured first gets it — the other's
tool is withheld, with a warning in the log. Text results are passed
through (up to response_truncate_length). Images a tool returns reach the
model as images when it is a vision model; audio and other binary content is
named in the result rather than shown; embedded text resources are included as
text.

Who gets which half

Two gates: target_agents (default all) decides whether this server's tools
are offered at all; write_target_agents (default main) then decides who
gets the write tools.

Which tools are writes is the server's own answer, read from the
readOnlyHint annotation each tool carries:

What the server saysTreated as
readOnlyHint: truea read — offered wherever target_agents admits
readOnlyHint: falsea write — offered only where write_target_agents admits
no annotationa write (the MCP specification's default)

So a server that annotates none of its tools is invisible to subagents; the
main agent is unaffected. The startup log line gives the tally per server. To
give subagents an unannotated server you trust, set
write_target_agents: all on that entry; target_agents: main does the
reverse and keeps the whole server off subagents.

The same answer decides which calls ask for approval (below). It is still the
server's own claim: it guards you against a cooperative server's writes, not
against a server that labels a destructive tool read-only. Only run servers
you trust.

Approvals

A call to a tool the server declares readOnlyHint: true runs without asking.
Every other call — a declared write, or a tool with no annotation — goes
through the normal approval gate, like a Gitea comment or a Redmine issue: in
Ask mode the dialog shows the server's name, the tool (as the agent sees it,
with tool_prefix) and the arguments. It is the same request an
MCP App raises when it calls that tool, so **Allow All in
this Conversation** on either covers both.

To allow a tool permanently, use Create Rule in the dialog, or write the
rule yourself — in Settings, or for everyone in the instance config. Rules
name an MCP tool by the name the agent sees:

permissions:
  allow:
    - "MCP(gh_create_issue)"   # one tool
    - "MCP(notes_*)"           # every tool of the entry with tool_prefix notes_
  deny:
    - "MCP(gh_delete_repo)"

A bare MCP matches every MCP tool of every server. In print mode (-p)
nothing can ask, so an MCP write is refused unless --allowed-tools names it
— again by the name the agent sees: --allowed-tools gh_create_issue.

How the modes treat an MCP write is how they treat any plugin write:

ModeMCP write
Ask (strict), Ask (acceptEdits)asks — acceptEdits covers file edits, and an MCP call is not one
Autothe judge decides between running it and asking; it never denies
Always allow (bypassPermissions)runs; deny rules still apply
Planrefused
Scheduled runs, goals, webhook triggersscheduler.permission_mode (default: Always allow); a call that would ask is refused instead

A subagent's calls go through the same gate as its parent's — though by default
a subagent is not offered write tools at all (write_target_agents).

Several servers and plugins_overrides

In a file that has the full plugins: list, add one entry per server. In an
overlay that only adjusts inherited config (extends: children, a
hand-written user overlay), add servers with plugins_overrides: and give each
a name:

plugins_overrides:
  - module: codumentor.plugins.mcp
    class: MCPPlugin
    args:
      name: time
      executable: uvx
      args: ["mcp-server-time"]

plugins_overrides matches entries by module + class, and for MCP also by
args.name: an override naming a server that is not inherited is added,
and one with the same name as an inherited server edits exactly that server
(e.g. args: {name: time, enabled: false}). Without names, a second MCP server
would be merged into the inherited one instead.

Sandboxing

A local MCP server is a third-party program that receives model-written
arguments on every call, so when the workspace_isolation plugin is enabled it
is confined the same way the agent's own shell is: in a
bubblewrap sandbox. Without that
plugin (the community edition's default) servers run directly on the host.
Remote (url) servers spawn no process and ignore this section.

      sandbox:
        mode: auto          # auto | on | off
        network: true       # share the host network namespace
        workspace: ro       # ro | rw | none — how the repos appear
        ro_binds: []        # extra read-only binds, "HOST" or "HOST:SANDBOX"
        rw_binds: []        # extra read-write binds
        env_pass: []        # host env var names to forward by name

Inside, the server gets a private, persistent $HOME
(~/.codumentor/mcp-homes/<server>/), so its tokens and package caches
survive restarts while your real home (~/.ssh, ~/.gnupg, …) is invisible.
It runs in its own PID namespace and dies with Codumentor. The seccomp filter
configured on workspace_isolation applies too.

What changes for an existing server: the working directory is
/workspace, so relative paths in args: stop resolving — use absolute ones.
Files outside the repos (a config file, a data directory) need a bind. The
command is looked up on the host PATH and its directory is mounted; system
locations (/usr, /bin, …) are always there, but a runtime installed under
your home (nvm's node/npx, for example) may need its install prefix in
ro_binds.

      executable: "/opt/mcp/bin/server"
      args: ["--config", "/etc/mcp/server.toml"]
      sandbox:
        network: false
        ro_binds: ["/etc/mcp"]
        rw_binds: ["/var/cache/mcp"]

A server that must be sandboxed and cannot be — bubblewrap missing, a bind
path that does not exist, a seccomp filter that will not load — **fails to
start** instead of silently running unconfined; the log says why. mode: off
accepts running it unconfined.

Per-user secrets

Use ${secret:<name>} in a remote server's headers so each user
authenticates with their own key. The value comes from that user's
User Secrets at request time and never appears in config or
the transcript; the User Secrets pane lists the names under "Needed by
plugins". Requires the user_secrets plugin.

      url: "https://api.example.com/mcp"
      headers:
        Authorization: "Bearer ${secret:my_service_token}"

A local server is started once and shared by everyone, so its env cannot
carry a per-user credential — use a remote server (or a native plugin such as
Redmine) when each user needs their own.

Such a server does not connect at startup — the secret only exists inside a
user's turn. It connects during that user's first turn (overlapping prompt
assembly), and its tools appear once that completes. Each distinct credential
gets its own connection.

Log lineMeaning
connection deferred to the first turn because it authenticates with per-user secret(s): … (INFO, startup)Normal.
MCP server … not connected: this user has not set the secret(s) … (INFO)The user has not stored the secret yet. Nothing was sent.
MCP server … rejected the credential built from secret(s) … (ERROR)The secret is set and the server refused it (401/403): expired, revoked or wrong.
Failed to start MCP client: … (ERROR)Anything else: unreachable endpoint, protocol error.

OAuth

For a server whose 401 invites a sign-in rather than a token. Set oauth and
nothing else:

      url: "https://mcp.example.com/mcp"
      oauth: true

The MCP authorization specification has the server publish where its
authorization server is and accept clients that
register themselves, so there
is no app to create and no client id to copy. Codumentor discovers it all on
the first connect, registers itself, and runs authorization-code with PKCE. A
server whose authorization server does not support dynamic registration cannot
be used this way — give it a token header instead. Two optional knobs:

      oauth:
        enabled: true
        scopes: []                 # empty = ask the server what it needs
        client_name: "Codumentor"  # the name on the consent screen

Leave scopes empty unless the server documents scopes it does not advertise.
oauth requires url. An Authorization header set alongside it is ignored
(with a startup warning).

api.external_url must be right. Codumentor registers one callback,
<external_url>/mcp/oauth/callback, with each authorization server. Unset, it
falls back to http://<api.host>:<api.port>/mcp/oauth/callback — correct for a
local install, wrong behind a reverse proxy. Forwarded headers are not
consulted. The settings pane prints the callback in force.

Connecting

Each user connects each server once, in **Settings → Extensions → MCP
Servers (TUI: Settings → Plugins → MCP Servers**). The pane shows each
OAuth server's state (not connected, connected, or "no longer accepts your
authorization"), its tools when a connection is open, and Connect /
Disconnect. Connect opens the sign-in page in a new tab; the user has ten
minutes to finish. The TUI cannot receive the browser redirect, so it prints
the authorization URL and asks you to paste back the address the browser landed
on (or just its code=… value).

The same flow is available over HTTP (all but the callback require the
oauth:manage permission):

RouteWhat it does
GET /ui/plugins/mcp/oauth/serversservers that authorize per user, this user's state, and the callback URL
POST /ui/plugins/mcp/oauth/flows {"server_id": "…"}starts a flow; answers with login_url (or complete with none when already connected)
GET /ui/plugins/mcp/oauth/flows/{flow_id}poll: awaiting_callback → complete or failed
DELETE /ui/plugins/mcp/oauth/servers/{server_id}disconnect
GET /mcp/oauth/callbackthe authorization server's redirect target; public, authenticated by its state

Where the authorization is kept

In the user's User Secrets store (encrypted with a key
derived from auth.jwt_secret — set it, or the store falls back to plaintext),
one row per server named mcp_oauth_<host>_<digest>. The row is host-only, so
no ${secret:…} or shell binding can carry the token into a turn. Deleting it
in the User Secrets pane disconnects the server. It also holds the client
registration and token expiry, so a restarted Codumentor refreshes an expired
token instead of asking for consent again. Disconnecting does not revoke the
grant upstream; do that at the provider.

Log lineMeaning
connection deferred to the first turn because it authenticates as the calling user (OAuth) (INFO, startup)Normal.
MCP server … not connected: this user has not authorized … yet (INFO)The user has not connected it.
MCP server …: this user's authorization is missing or no longer accepted (INFO)Revoked, or expired past refreshing. Connect again.
MCP server … authorized by user=…; it offers N tool(s) (INFO)A flow completed and the connection works.

MCP Apps (web UI)

Some servers ship an interactive view for a tool — a chart, a form, a small
app — as an HTML resource (the MCP Apps extension
io.modelcontextprotocol/ui, 2026-01-26). The web UI renders it next to the
tool's ordinary text result; the TUI, exports and shared links stay text-only.
The view runs in a sandboxed frame on a second origin, so it can never read
Codumentor's cookies or call its API; the MCP connection and credentials stay
on the backend. An app reaches only the server that created it; its tool calls
without readOnlyHint: true go through the normal approval dialog — the same
one the model's call of that tool raises (see Approvals) — and
messages it wants to send need your confirmation.

Apps are off until api.mcp_apps.sandbox_origin names that second origin. A
production deployment uses a separate HTTPS hostname pointing at the same
process — see api.mcp_apps.

On a local install two loopback HTTP origins are accepted, so the two
spellings of your own machine are enough:

api:
  mcp_apps:
    sandbox_origin: "http://localhost:2638"   # your api.port

Then open the UI as http://127.0.0.1:2638, never as localhost.
Requests whose Host is the sandbox origin are answered only for
/mcp-app-sandbox.html — and only when the frame was opened from the main
origin — with a strict CSP (no network access, framable only by the main
origin, no caching). Every other path on that host, the UI and the API
included, answers 404, so http://localhost:2638/app shows nothing. If you set
api.external_url, it is the main origin and must differ from the sandbox
origin; a custom api.content_security_policy must list the sandbox origin in
frame-src.

When anything in the chain fails — the resource, the server, the browser — the
text result stays usable. api.mcp_apps.enabled: false turns the feature off.

For server authors: return meaningful text in every result; point
_meta.ui.resourceUri at an exact ui:// URI serving one
text/html;profile=mcp-app resource; use _meta.ui.visibility for model-only
or app-only tools; declare readOnlyHint: true only for side-effect-free
tools; keep _meta.ui.csp domain lists minimal. The deprecated
_meta["ui/resourceUri"] is accepted. Draft features, picture-in-picture,
direct browser-to-server transports and optional browser permissions are not
supported.

Troubleshooting

SymptomCause and fix
No MCP client for … started line at allThe entry is not loaded: wrong file, enabled: false, or Codumentor was not restarted after the edit. A hand-written overlay with its own plugins: list replaced the built-in one — use plugins_overrides:.
Server fails to startThe log line quotes the server's last stderr lines; read them first. command not found / "not on PATH": install the runtime (Node.js for npx, uv for uvx) or give an absolute executable. A missing API key: set it under env: — the server does not inherit your shell environment.
Fails only when sandboxedRelative paths in args: (the working directory is /workspace), files outside the repos without a bind, or a runtime under your home that needs ro_binds. See Sandboxing.
First start of an npx/uvx server times outThe first run downloads the package; connecting is given 30 seconds. Run the same command once in a terminal to fill the cache, then restart. A failed start is retried no sooner than about a minute later.
Remote server: 401 / 403Wrong or expired token; for ${secret:…} the log says whether the secret is unset or rejected. A server that wants a browser sign-in needs oauth: true.
Old server hangs or answers 404/405 on connectIt may still speak SSE at a URL not ending in /sse: set transport: sse.
Tools work for the main agent but subagents do not get themThe server's tools carry no readOnlyHint, so they count as writes. Set write_target_agents: all if you trust it. See Who gets which half.
A tool from one server is missingAnother server configured earlier, or a built-in tool, has the same name; the log warns MCP server … offers a tool named '…' once. Give one server a tool_prefix, or hide the duplicate with disabled_tools.
Tools missing or stale after a config changeRestart Codumentor. Changes on the server side are followed automatically.
Two MCP servers in an overlay become one, or fail validationplugins_overrides merged them; give each a distinct args.name.
A per-user server's tools appear only from the second message onExpected: it connects during the user's first turn.

To see everything a server writes to stderr, raise the log level to DEBUG.

How it works

Protocol revisions. The client is the official
mcp Python SDK. It speaks the
current revision (2026-07-28: stateless, no sessions, no initialize) and
the handshake era before it, detected per server: it probes server/discover
once and falls back to initialize. The startup log names the negotiated
revision.

Connections. One process (or remote connection) per distinct server
config — per credential, where the config carries one — reused for the life of
the process. Opening a connection is given 30 seconds and every request 30
seconds, so a silent server fails the tool call rather than the turn. A failed
start is retried no sooner than ~60s later. A stdio server's stderr is drained
continuously (a full pipe would block the server) and logged at DEBUG. A
server that exits or drops its connection is logged once at WARNING (a stdio
server with its exit status and last stderr lines) and restarted by the next
prompt or tool call; a call that was in flight when it died fails and is not
retried.

Per-user connections are keyed by the server config plus a digest of the
resolved credential: a pre-2026-07-28 server binds its session to the token
presented at initialize, so sharing a connection between credentials would be
unsafe. At most 16 are kept per server, least-recently-used evicted first; an
evicted user reconnects on the next turn.

Keeping the tool list current

SignalWhat it isWhen it applies
tools/list_changedthe server saying its tools changedat once on a 2026-07-28 server; at the next prompt on an older one
ttlMshow long the server says its list stays freshat the next prompt after it expires
a reconnecta new connection lists for itselfserver restarted, replaced, or reached with a new credential

On a change the list is refetched and the agent's tools rebuilt: new tools
appear, removed ones stop being offered and resolving, changed schemas reach the
model. watch_tool_changes: false ignores change notifications (and opens no
subscriptions/listen stream) for a server whose event stream misbehaves.
ttlMs: 0 is read as "no freshness promise", not "refetch every prompt".
cacheScope: public lets a list fetched for one credential be reused for the
next; private (the default) never shares it. Paginated lists are followed to
the end (restarted once if the cursor is refused, stopped with a warning after
50 pages).

See also