Skip to content

MCP servers

ka is an MCP client. Every server you configure contributes its tools to ka’s Hands registry as <server>__<tool> (double underscore) at exec-tier clearance: the permission gate, rules, snapshots, and decomposition treat them exactly like any external execution. There is no separate trust path. The name is wire-safe by construction: providers reject tool names outside [a-zA-Z0-9_-], so the server__tool name collapses any other character to _.

# stdio server (spawned process)
[[mcp]]
name = "filesystem"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/srv/data"]
# env = { SOME_TOKEN = "…" }
# streamable HTTP server (legacy SSE is detected as a fallback)
[[mcp]]
name = "docs"
url = "https://mcp.example.com/mcp"
# headers = { Authorization = "Bearer …" }
# per-server policy (any server)
[[mcp]]
name = "github"
url = "https://api.githubcopilot.com/mcp"
enabled_tools = ["create_issue", "search_code"] # allowlist
disabled_tools = ["delete_repo"] # blocklist
approval = "writes" # "ask" (default) | "auto" | "writes"
tool_timeout_secs = 30
output_limit = 65536

The policy keys (config reference):

Key Meaning
enabled_tools / disabled_tools Filter the server’s catalog down to (or subtract) named tools
approval "ask" is the normal gate default; "auto" skips permission asks but deny-class verdicts and hardstops still apply; "writes" asks only for tools that advertise readOnlyHint = false
tool_timeout_secs Per-tool call timeout
output_limit Cap on a tool result’s size

Set oauth = true on an HTTP server and ka handles the whole flow: dynamic client registration (RFC 7591) and CIMD, a local loopback callback, and a token cache with refresh kept in the data dir, so you authenticate once per server.

For servers with a pre-registered client, oauth_client_id supplies it directly and oauth_scopes narrows the scopes requested. If a server has no OAuth at all, two static alternatives remain: bearer_token_env names an environment variable holding a bearer token, and headers_helper is a command whose output becomes the request headers, for derived or short-lived credentials.

Server-initiated traffic is not dropped:

  • Elicitation requests are routed to ka’s ask UI, so a server asking a question reaches you, not a dead queue.
  • Sampling requests are served by your default model.
  • roots are honored.
  • Server-initiated notifications apply live: tools/list_changed refreshes ka’s tool catalogs without a restart.

ka is also an MCP server: ka mcp-serve exposes its read hands (read, glob, grep, sessions_search, session_info) as a stdio MCP server for any MCP host. bash is deliberately excluded; the server is read-only by design.

Terminal window
ka mcp # probe every configured server, list its tools

In the TUI, /mcp shows server status and /prompt runs MCP prompts. Handshake, tools/list, and tools/call are the only RPCs used; server noise is ignored, and a failing server degrades to a per-server note, never a crash.

Tool lists are cached: after a server’s first successful handshake, its tools are remembered under $XDG_STATE_HOME/ka/mcp-tools.json, keyed by a hash of the server’s config. The next startup registers them from cache instantly, so a slow or dead server never blocks startup and the tool list stays byte-stable across runs (which keeps provider prompt caches stable too). A background verify re-checks the live server, swaps the list with a transcript note if it changed, then chains into the supervision watchdog, so two connects are never in flight. Reconnects and manual refreshes update the cache as well. Caches written by older versions (dotted server.tool names) are re-derived on load, so existing installs heal without deleting state.

  • [tools.mcp] discovery = "eager"|"lazy" (default eager, strict enum) controls when server tool catalogs are loaded.
  • Tools appear as <server>__<tool> (double underscore); allowlist rules in [[rules]] use that spelling.
  • Because MCP tools are exec-tier, they ask under ask mode like bash would; allowlist them with a [[rules]] entry or [permissions] allow if you trust one. A per-server approval policy can narrow this (see above).