MCP servers
A model can only use the tools it is given. Some come with zelk. Others live in other programs: an issue tracker, a database, a wiki. The Model Context Protocol, MCP, is an open standard for that gap. A program that speaks it is a server, and it offers a model tools, and also resources (things to read) and prompts (canned messages). An agent that connects to it is the client. zelk is a client.
Because the standard is open, the same server works with any agent that speaks it, and zelk needs no code of its own for the tracker or the database. This page says how the conversation goes, then what zelk does with it that is its own.
The conversation
Section titled “The conversation”Client and server exchange JSON-RPC messages: a request with an id that the server answers with a result or an error, and a notification with no id that nothing answers. There are two ways to carry them.
- stdio. The client starts the server as a process and writes messages to its standard input and reads them from its standard output. The server is local and lives as long as the client keeps it.
- Streamable HTTP. The server is a remote service at a URL. Each
message is a
POST, and the answer comes back as JSON or as an event stream. A session ID in a header ties the messages together.
A connection starts with a handshake. The client sends initialize, with
the newest protocol version it speaks and its name. The server answers
with the version it will speak, what it offers and its own name. The
client then sends the notification notifications/initialized, and asks
for the tools with tools/list, following its pages until none is left.
A tool is a name, a description the model reads, and an input schema: a JSON Schema for the arguments a call must carry.
{ "name": "search", "description": "Search the notes.", "inputSchema": { "type": "object", "properties": { "query": { "type": "string" } }, "required": ["query"] }}A call is a tools/call request naming the tool and giving its arguments.
The result is a list of content, which may be text, an image or an
embedded resource, and a flag, isError, for a tool that ran and failed.
{"jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": {"name": "search", "arguments": {"query": "retry policy"}}}
{"jsonrpc": "2.0", "id": 4, "result": {"content": [{"type": "text", "text": "3 notes match"}]}}That is all of it from the client’s side. The scenes below play it: the handshake and the tools arriving, a call over each transport, and a call cut off by a crash. zelk is on the left and the server on the right. A message is a packet on the wire. A stdio server sits inside the sandbox on the same machine, and an HTTP server is past the machine’s edge.
- Connecting. Connecting is a short conversation. zelk starts the server, says hello with initialize, and asks for its tools. Each one joins zelk’s list under a name that carries the server’s. Messages: to the server: initialize; back: result; to the server: notifications/initialized; to the server: tools/list; back: 2 tools. The log gains: session_started tools: mcp__notes__search, mcp__notes__add_note, origin mcp.
- A call over stdio. A stdio server is a process in the sandbox. The wire is its standard input and output, so the launcher confines it like any command. The call goes out under the server’s own name for the tool. Messages: to the server: tools/call search; back: result. The log gains: effect_started run_tool mcp__notes__search retry policy; effect_finished mcp__notes__search retry policy → ok.
- A call over HTTP. An HTTP server is across the network. The wire crosses the machine’s edge, where the network setting decides whether the host may be reached. What the server does on its own machine is beyond any sandbox. Messages: to the server: tools/call list_issues; back: result. The log gains: effect_started run_tool mcp__tracker__list_issues open; effect_finished mcp__tracker__list_issues open → ok.
- Cut off by a crash. A call cut off by a crash is unknown, not sent again. The log ends at the intent. The next process can’t tell whether the server opened the issue, so it records unknown and the model checks first. Messages: to the server: tools/call create_issue (lost on the wire). The log gains: effect_started run_tool mcp__tracker__create_issue bug; effect_reconciled unknown: verify before retrying.
What zelk makes of a server
Section titled “What zelk makes of a server”You list servers in a file, and zelk connects to them when it starts,
all at once. The MCP guide has the file’s format, the
zelk mcp commands and the tool search that keeps a server’s many schemas
out of the context. In Go, WithMCP takes the servers.
Each tool the server lists becomes one of zelk’s, named
mcp__server__tool: search of the notes server is
mcp__notes__search. A server’s name is up to 32 letters, digits, _ or
-. The model sees the zelk name, and zelk sends the server its own. A
tool whose schema zelk can’t use is left out with a warning, and the rest
are offered. A Go host can use Server.Offering to choose the tools the
model sees and withhold optional input properties. zelk rejects calls that
carry a withheld property before contacting the server.
Text returned by a server reaches the model inside an untrusted-data fence labelled with the tool and server. This includes embedded resource text, structured fallback output, resource links and server error messages. zelk escapes text that resembles a fence tag and keeps its own notices outside the fence.
zelk never takes a server’s word about what a tool does. A server can annotate a tool as read-only or idempotent, and zelk records the claim and ignores it. The consequences are the ones for any tool zelk can’t vouch for:
- A call never shares a wave. It runs alone, however many other calls the model asked for in the same turn.
- A call never gets the read-only grant, so in
defaultmode it asks until a rule allows it, and plan mode refuses it. - After a crash it is never run again.
Permission rules and hook matchers name MCP tools like any other:
mcp__github__* covers every tool of one server, and a hook matcher of
mcp__.* covers all servers (Permissions).
Where a server runs
Section titled “Where a server runs”The transport decides what confines it.
A stdio server is a process zelk starts through the same environment that runs the agent’s commands. zelk never spawns it by itself. So under a sandbox the launcher confines the server like any command: it sees the workspace and what the profile binds, and no more (Sandboxing).
An HTTP server is reached through the host’s own HTTP client. zelk
reads no proxy setting. In the CLI, under a sandbox, the request follows
the -network setting: with the network off there is no HTTP server, and
with an allowlist only the listed hosts are reached, redirects included.
The check is on where the request goes. Once it gets there, what the
server does on its own machine is beyond any sandbox.
Signing in
Section titled “Signing in”A remote server may require OAuth. zelk’s MCP client knows nothing of it: it takes an HTTP client, and the host gives it one whose transport adds the tokens. The transport sends a token only to the server’s own origin, only over HTTPS or loopback, and renews it before it expires.
Signing in is interactive, so it is yours to start, never the model’s:
zelk mcp login prints a link, and the flow is the one the MCP
authorization specification describes, with discovery, registration where
the server allows it, PKCE and a loopback redirect. Until a server that
needs a sign-in has one, zelk starts without it and says so.
When a call is cut off
Section titled “When a call is cut off”If the process dies while an MCP call runs, the log ends at the call’s
intent. The next process can’t tell whether the server acted: the request
may not have left, may be in flight, or may have been done. zelk doesn’t
send it again. It records the outcome as unknown and tells the model to
verify what the call would have changed before it tries again
(Durability and recovery). A Go tool that
declared itself read-only and idempotent, or one that deduplicates by an
idempotency key, may be run again; an MCP tool can’t make that promise to
zelk.
Within a running process the rule is the same: zelk resends a request
only when it can prove it never reached the server. A stdio server that
dies is restarted at most three times, the first at once and then after
one second and two, and only a request known not to have been written goes
to the new process. An HTTP request refused because its session has
expired, a 404 that came with a session ID, goes to a new session once.
A refusal with no such proof, or a dropped network, is never retried.
What zelk records
Section titled “What zelk records”The session’s first record, session_started, holds each tool’s spec: its
zelk name, its description, its input schema and its origin, MCP. Around
each call the log gains effect_started with the tool and its input, and
effect_finished with the result as zelk turned it into content for the
model, or effect_reconciled with unknown after a crash.
Replay folds the log with effects suppressed. It never contacts a server,
and it reads the specs as recorded data rather than asking the server what
they are now. When a server’s tools change, it tells zelk with
notifications/tools/list_changed. An idle session records the new list
with config_changed before its next run, and a run in progress keeps the
tools it began with, so a call’s schema never changes under it.
When a server won’t connect
Section titled “When a server won’t connect”A server that fails to connect removes only its own tools. The reason is
kept as the server’s status, and the session records a
mcp_server_unavailable warning. A server that needs a sign-in shows as
needing one, and the host can offer it. A stdio server’s recovery is
bounded, and when its restarts are used up it stays down until you
reconnect it, which the terminal UI does in place. The
durability contract has the exact rules under
“MCP connection diagnostics”.
What zelk supports
Section titled “What zelk supports”zelk implements the client’s side of MCP for these parts of the specification:
- Tools, which are the point: listing, with pagination, and calling.
Result content that is text, an image, an embedded resource or a resource
link reaches the model. Other content types are shown as a placeholder,
and a result with only
structuredContentis passed on as its JSON. - Resources, for reading. A server that offers them adds two built-in
tools,
ListMcpResourcesandReadMcpResource, which are zelk’s own, read-only and bounded. zelk doesn’t subscribe to resource changes. - Elicitation, in form mode, when the host can ask a person and says so. A server may ask a question in the middle of a call. URL mode isn’t supported.
- The protocol versions
2025-11-25,2025-06-18and2025-03-26, asking for the newest and accepting any.
zelk doesn’t support prompts: it never asks a server for them. Nor does
it support sampling or roots, and a server that asks for either
gets “method not found”. The code is in
core/mcp, with
core/mcp/oauth for the sign-in.
Where to go deeper
Section titled “Where to go deeper”- The MCP guide: the server file, the commands, signing in and tool search
- Extending zelk: where MCP tools sit beside Go tools, subagents and hooks
- Sandboxing: what a launcher and the network setting confine
- The tools contract and the embedding contract: how MCP tools are defined, deferred and handed to an agent
- In Go,
WithMCPconnects servers, and themcppackage is the client