MCP extension #
The MCP extensions provide session-owned connections and expose discovered
operations through Python. Configured servers and editor-provided servers have
separate host routes but share the mcp binding. See
MCP extension and
Python binding.
Configure servers #
The mcp settings section accepts stdio and http servers. Stdio requires
command and accepts args, cwd, and env. HTTP requires url and accepts
headers and bearerTokenEnvVar. Environment and header values can be literal
strings or environment references. Servers default to enabled. enabledTools
and disabledTools select tools. Startup and call timeouts default to 20,000
and 60,000 milliseconds. Both must be positive and at most 3,600,000
milliseconds. retryMs defaults to 30,000. See server_decoder and
config_section in
extension.gleam.
Tools and lifecycle #
The configured extension requires python and prepares an owned managed
contribution. It saves the last catalogue by server name and configuration
fingerprint. An unavailable server produces a warning. The session can refresh
when its catalogue changes. The host closes the connection when the contribution
closes. Cold clients monitor both the preparer and runtime before opening their
transport, through discovery and catalogue saving. Ownership transfers to a
connector before preparation returns. See prepare and initialise_catalogues
in extension.gleam.
Server names, descriptions, and results are untrusted data. A failed or
interrupted call may have had effects, so inspect those effects before retrying.
A server-reported error appears in isError. A host failure raises McpError.
See extension.gleam and
mcp.py.
Editor servers over ACP #
editor-mcp obtains the editor's session overlay and uses editor_mcp routes.
Its overlay and catalogues live in daemon memory. The editor cannot reuse a
configured server name. See editor_extension and prepare_editor in
extension.gleam, and
ACP.
From Python #
await mcp.tools() lists operations, await mcp.search(query) ranks them, and
await mcp.describe(name) returns a schema. await mcp.call(name, arguments)
calls an advertised name or server/tool. The binding also mints
mcp.<server>.<tool> methods from the catalogue at kernel boot. Operations
added later or whose names cannot be minted remain reachable through call. See
mcp.py.