MCP

Servers are configured in .oi/mcp.json or ~/.config/oi/mcp.json. A server with command speaks stdio; a server with url speaks streamable HTTP (MCP 2025-06-18; servers answering 2025-03-26 are accepted too):

{ "servers": {
    "github": { "command": "github-mcp", "args": ["stdio"],
      "env": { "GITHUB_TOKEN": { "keychain": "github" }, "GH_HOST": "github.com" } },
    "docs": { "url": "https://mcp.example.com/mcp",
      "headers": { "X-Api-Key": { "env": "DOCS_KEY" }, "X-Tenant": "acme" } },
    "tracker": { "url": "https://tracker.example.com/mcp",
      "oauth": { "scopes": ["issues:read"] } } } }
  • Credentials: plaintext credentials are rejected at load time. Env values and HTTP headers must be {"keychain": name} (stored with oi secret set name) or {"env": "VAR"}, optionally with a "prefix" such as "Bearer ". Injected values are tracked and redacted from all output.
  • Lazy start: a server starts only when tool_search needs its catalog (then cached in SQLite) or when one of its tools, resources or prompts is used. A server's notifications/tools/list_changed drops its cached catalog.
  • Sandbox: stdio servers run under the same OS sandbox as bash. HTTP servers are reached in-process, only over https (plain http for localhost), and not at all while network access is off (--no-net).
  • Sessions: oi sends MCP-Protocol-Version and the server's Mcp-Session-Id, reads plain JSON and event-stream replies, re-initializes once when a session expires (404), and ends the session with DELETE on exit.
  • Server requests: oi answers ping and roots/list (the workspace as a file:// root) and declines sampling and elicitation.
  • Tool results: text blocks are joined; images (PNG, JPEG, GIF, WebP) are passed to the model as images; audio, binary resources and resource links become short text placeholders.
  • OAuth: a remote server that answers 401 is authorized with oi mcp login <server>. oi discovers the authorization server from the server's protected-resource metadata (RFC 9728, RFC 8414 / OpenID discovery), registers itself dynamically (RFC 7591) unless oauth.client_id is set (with an optional client_secret ref), and runs the authorization-code flow with PKCE (S256), state and the resource indicator through a loopback redirect (http://127.0.0.1:<port>/callback; oauth.redirect_port pins the port). It opens the browser and always prints the URL; OI_NO_BROWSER=1 only prints it. Tokens are stored in the OS keychain as mcp-oauth:<server>, redacted from output, and refreshed when they expire or the server answers 401. When refreshing is not enough, the tool call fails with a message to run oi mcp login again.
oi mcp list                          servers, transport, catalog cache, auth status
oi mcp login <server>                OAuth browser flow
oi mcp logout <server>               forget stored tokens
oi mcp resources [server]            list resources (JSON)
oi mcp read <server> <uri>           read a resource
oi mcp prompts                       list prompts
oi mcp prompt <server> <name> [arg=value ...]

OI_KEYCHAIN_FILE=<path> replaces the OS keychain with a private JSON file, for tests and machines without a secret service.