Skip to content
MCP (Model Context Protocol)

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 configAliasesClientUse when
localstdio, "" (omitted)stdio subprocess, JSON-RPC on stdin/stdoutThe server is an executable (npx, uvx, a binary).
remotehttpHTTP POST, JSON response bodyA long-lived HTTP endpoint that replies in the POST body.
sse(none)HTTP POST + Server-Sent Events streamThe server delivers responses on an SSE channel, not in the POST body.
streamable-httpstreamableStreamable 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/mcp

Each entry has:

  • type — one of the four transports above. Defaults to local.
  • enabled — disabled servers are listed but not started. Default false.
  • command — argv for local servers (the binary plus its arguments).
  • environment — extra env vars passed to the subprocess.
  • url and headers — for remote, sse, and streamable-http.
  • allow_tools / block_tools — filter which discovered tools are registered. allow_tools is a whitelist and wins if both are set. These are not allow/ask/deny; that lives under permissions.

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 cwd

Lifecycle

When the TUI launches:

  1. Each enabled server is connected. Connection failures are warnings on stderr — they never abort startup.
  2. The transport completes the MCP initialize handshake.
  3. tools/list, resources/list, and prompts/list run. Discovered tools are registered under mcp__<server-name>__<tool-name>. Resources and prompts are stored on the server state (see below).
  4. 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 filesystem

Output 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 file

Naming 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: ask

These feed the same evaluator as built-in tools (see Permissions). Priority relative to other sources:

  1. permissions.rules / agent overrides / presets (unchanged)
  2. permissions.tools.mcp__server__tool (escape hatch; wins over MCP section)
  3. mcp.<server>.permissions.<tool> then mcp.<server>.permissions."*"
  4. Hardcoded default (allow for 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