okfsmith logo okfsmith Docs EN Open okfsmith
On this page

MCP

MCP server

MCP server

okfsmith mcp exposes your knowledge bundle as a read-only MCP (Model Context Protocol) server so AI agents — Claude Code, Claude Desktop, Cursor, Copilot, Gemini — can search and read your bundle directly. Agents get live answers; your bundle is never modified.

Quick start

pip install "okfsmith[mcp]"
okfsmith mcp ./kb

The server starts on stdio (the standard transport: your MCP client launches it as a subprocess) and exposes eight tools. Pick one:

okfsmith mcp ./kb --transport stdio            # default
okfsmith mcp ./kb --transport sse              # Server-Sent Events
okfsmith mcp ./kb --transport streamable-http  # streamable HTTP

The eight tools

Tool outputs are compact markdown (not giant JSON) — designed as an agent's reading UI. The intended flow is progressive disclosure: index → search → get.

ToolWhat it does
indexReturn the bundle's root index.md — the map of the whole knowledge base. Read this first to orient.
listList every concept: id, type, trust tier, title. Optional filter_type narrows by concept type; limit caps rows.
searchBM25-ranked keyword search over concept id, title, description, tags, and body. Title matches rank highest, body lowest; results carry excerpts.
getRead one concept in full: YAML frontmatter followed by its markdown body. Unknown ids produce an error — never fabricated content.
neighborsShow a concept's link graph neighborhood: outgoing links and incoming backlinks, so agents can walk the knowledge graph.
traverseBreadth-first neighborhood expansion over markdown links (depth ≤ 3, cycle-safe), with an optional relation_filter and currency-aware ordering — superseded concepts hidden by default.
provenanceTrace a concept's provenance chain: sources[] frontmatter → footnote references → the ingested-source manifest (sync-state.json) with source file and digest.
diffDiff the bundle against another bundle directory (against=) or the sync-state.json snapshot: added / removed / changed concepts with body SHA-256.

A typical agent session looks like this:

  1. index — "what's in this bundle?"
  2. search with "billing retries" — ranked hits with excerpts
  3. get with billing/retries — the full concept
  4. neighbors with billing/retries — related concepts via links
  5. traverse with billing/retries, depth=2 — the wider neighborhood
  6. provenance with billing/retries — where each claim came from

Evidence budgets

Every tool accepts three evidence-budget parameters so agents get bounded evidence instead of unbounded context:

ParameterMeaning
max_chunksMax items (or 50-line text chunks) per response — default 10 for search/traverse, 50 elsewhere; hard cap 50. Notes (e.g. hidden-superseded counts) and ## section headers sit outside the budget; …[truncated, N more] counts remaining items only.
max_tokensApproximate output budget (chars ÷ 4). None (default) = unbounded; 0 = no item content; negative or unparseable values are treated as unbounded. Truncation cuts at whole-item boundaries, never mid-item, and is marked …[truncated, N more].
continuation_tokenOpaque paging cursor from a truncated response — pass it back for the next page. Tokens are result-offset cursors, not tied to a query. An invalid or out-of-range token returns a clean error, never a traceback.

search and traverse are currency-aware: superseded concepts are hidden by default (reported as a count); pass include_superseded=True to reveal them. traverse depth is capped at 3.

Claude Desktop config

Add okfsmith as an MCP server in your Claude Desktop config file (claude_desktop_config.json):

{
  "mcpServers": {
    "okfsmith-kb": {
      "command": "okfsmith",
      "args": ["mcp", "/absolute/path/to/kb"]
    }
  }
}

Restart Claude Desktop and the eight tools (index, list, search, get, neighbors, traverse, provenance, diff) appear in its tool list.

Advanced: other clients and transports - **Claude Code** and **Cursor** accept the same stdio command shape (`okfsmith mcp `); check their MCP server docs for the exact config file location. - For **SSE** or **streamable-http** transports, point your client at the server's URL — the bundle is loaded once at server startup, and every tool call afterwards reads from the in-memory bundle, so responses are fast. - The same eight tools back the interactive chat's `/search` and `/read` commands, so chat and MCP rank identically.

Next →

Troubleshooting →