MCP (Model Context Protocol)
Ulmi speaks the Model Context Protocol to extend the agent’s tool registry with capabilities provided by external servers. MCP servers can expose anything from a filesystem under a sandboxed root to a wrapped HTTP API.
The package is internal/mcp.
This page is the canonical reference for MCP transports, tool names, and CLI. YAML field notes in Configuration link here instead of restating the contract.
Supported transports
type in YAML selects one of four clients. Aliases are exact strings
recognised by the manager — they are not interchangeable across
rows.
type in config | Aliases | Client | Use when |
|---|---|---|---|
local | stdio, "" (omitted) | stdio subprocess, JSON-RPC on stdin/stdout | The server is an executable (npx, uvx, a binary). |
remote | http | HTTP POST, JSON response body | A long-lived HTTP endpoint that replies in the POST body. |
sse | (none) | HTTP POST + Server-Sent Events stream | The server delivers responses on an SSE channel, not in the POST body. |
streamable-http | streamable | Streamable HTTP (MCP 2025-03-26) | The server speaks the streamable session protocol (optional session DELETE on close). |
Do not set type: remote and expect SSE or streamable behaviour.
ulmi mcp add --type currently accepts local (default) and
remote; set sse or streamable-http by editing YAML.
HTTP (remote) uses a 5-minute client timeout, the same bound as LLM
providers. SSE and streamable HTTP do not set http.Client.Timeout
(that would kill a live event stream); dial, TLS handshake, and response
headers are still bounded, and the request context cancels Do.
Each MCP server gets its own http.Client — they do not share a
process-global client.
Streamable HTTP session DELETE is cancelled by the parent context instead of waiting out the 5s timeout (TUI quit / SIGINT).
Configuring a server
mcp:
filesystem:
type: local
enabled: true
command: ["npx", "-y", "@modelcontextprotocol/server-filesystem", "."]
environment:
DEBUG: "false"
github:
type: local
enabled: false
command: ["npx", "-y", "@modelcontextprotocol/server-github"]
environment:
GITHUB_PERSONAL_ACCESS_TOKEN: ${GITHUB_TOKEN}
# Registration filters (which tools exist at all):
# allow_tools: [list_issues] # whitelist; wins over block_tools
# block_tools: [delete_issue]
# Per-tool permission levels (short names → mcp__github__<name>).
# "*" sets the default for every tool from this server.
permissions:
"*": ask
list_issues: allow
create_issue: ask
remote-tools:
type: remote # HTTP POST JSON
enabled: false
url: https://mcp.example.com
headers:
Authorization: Bearer ${MCP_TOKEN}
sse-tools:
type: sse # not an alias of remote
enabled: false
url: https://mcp.example.com/sse
streamable-tools:
type: streamable-http
enabled: false
url: https://mcp.example.com/mcpEach entry has:
type— one of the four transports above. Defaults tolocal.enabled— disabled servers are listed but not started. Defaultfalse.command— argv forlocalservers (the binary plus its arguments).environment— extra env vars passed to the subprocess.urlandheaders— forremote,sse, andstreamable-http.allow_tools/block_tools— filter which discovered tools are registered.allow_toolsis a whitelist and wins if both are set. These are not allow/ask/deny; that lives underpermissions.
Adding a server interactively:
ulmi mcp add --name filesystem \
--command npx -y @modelcontextprotocol/server-filesystem .
ulmi mcp add --name myhttp --type remote --url https://mcp.example.com
ulmi mcp list
ulmi mcp get filesystem
ulmi mcp remove filesystem # rewrites ulmi.yaml in cwdLifecycle
When the TUI launches:
- Each enabled server is connected. Connection failures are warnings on stderr — they never abort startup.
- The transport completes the MCP
initializehandshake. tools/list,resources/list, andprompts/listrun. Discovered tools are registered undermcp__<server-name>__<tool-name>. Resources and prompts are stored on the server state (see below).- The agent can now invoke the registered tools like any other tool.
When the TUI exits, all clients are closed gracefully (subprocesses are terminated, HTTP connections released). Streamable HTTP session DELETE is cancelled by the parent context instead of waiting out the 5s timeout.
The orchestrator is the Manager wired up
in internal/cli/tui.go.
Resources and prompts
The client implements resources/list, resources/read,
prompts/list, and prompts/get on every transport. Counts (and, on
ulmi mcp get, names/URIs) appear in the TUI /mcp overlay and the
CLI. They are not registered as model-visible tools or slash
commands yet — only tools enter the LLM tool registry.
Listing connected servers
ulmi mcp list
ulmi mcp get filesystemOutput includes both configuration-level metadata (transport, URL or command, enabled flag) and, for each connected server, the tools it exposes:
Configured MCP servers:
filesystem [local, enabled]
command: npx -y @modelcontextprotocol/server-filesystem .
Connected servers and their tools:
filesystem (4 tools):
• read_file Read a file from the sandboxed root
• list_directory List a directory's children
• write_file Write a file in the sandboxed root
• move_file Move or rename a fileNaming and collisions
Tools from MCP servers are registered as mcp__<serverName>__<toolName>,
following the same convention as Claude Code and Codex CLI. This namespacing
prevents two different servers (or a server and a built-in tool) from
clashing, and makes it obvious in the TUI which calls came from where.
Names are sanitized for LLM provider APIs (^[a-zA-Z0-9_-]+$). Invalid
characters in server or tool names are replaced with _. Names longer than
64 characters are truncated with a SHA-1 suffix to stay within provider limits.
When the model picks a tool, it sees the qualified name in the schema and
uses it verbatim. The adapter maps the qualified name back to the original
MCP tool name when calling tools/call.
Permissions
Prefer configuring MCP tool levels next to the server under
mcp.<server>.permissions (short tool names, or "*" for a server-wide
default):
mcp:
github:
enabled: true
command: ["npx", "-y", "@modelcontextprotocol/server-github"]
permissions:
"*": ask
list_issues: allow
create_issue: askThese feed the same evaluator as built-in tools (see Permissions). Priority relative to other sources:
permissions.rules/ agent overrides / presets (unchanged)permissions.tools.mcp__server__tool(escape hatch; wins over MCP section)mcp.<server>.permissions.<tool>thenmcp.<server>.permissions."*"- Hardcoded default (
allowfor non-bash tools)
Registration filters (allow_tools / block_tools) are separate: they
control which tools are exposed at all, not allow/ask/deny.
Errors
If a server returns a tools/call response with isError: true, the
adapter surfaces the text payload back to the agent loop and the LLM sees
it like any other tool error. Transport-level failures (subprocess exit,
HTTP timeout) are reported the same way; they do not crash the conversation.
References
- Model Context Protocol specification
- Reference servers under @modelcontextprotocol on npm
- Test fixtures and mocks live in
internal/mcp/mcp_test.go