Skip to main content

MCP-first agent retrieval over Open Knowledge Format (OKF) bundles.

Project description

okf

Mount any Open Knowledge Format bundle as a retrievable knowledge source for LLM agents — over MCP.

OKF (announced by Google Cloud, June 2026) represents organizational knowledge as a directory of markdown files with YAML frontmatter. The format was designed for agent progressive disclosure: index.md listings, structured type/tags frontmatter, and a resolvable cross-document link graph.

okf turns a bundle into agent-ready retrieval. Point an MCP-capable agent (Claude Code, Claude Desktop, or the Messages API) at a bundle and it searches for stubs, fetches bodies, and walks the link graph on demand — instead of you flattening every doc into the context window.

pip install "okf-retrieve[mcp]"
okf serve-mcp ./sales          # serve the bundle to any agent over MCP (stdio)

Why MCP-first

The OKF link graph and frontmatter are exactly what an agent needs to navigate knowledge rather than be handed a wall of text. okf exposes that as four tools:

Tool Returns
search(query, type?, tags?, limit?) ranked document stubs (path, type, title, description) — not full bodies
get(path) one document's full content
neighbors(path, hops?) documents linked from/to a document (graph expansion)
list_types() / list_by_type(type) structured browse

search deliberately returns stubs so the agent decides what to read — the progressive-disclosure pattern OKF was built for.

Use it from Claude Code / Desktop

Add to your MCP config (claude_desktop_config.json or .mcp.json):

{
  "mcpServers": {
    "okf-sales": {
      "command": "okf",
      "args": ["serve-mcp", "/abs/path/to/sales"]
    }
  }
}

Use it from the Messages API

Run okf serve-mcp ./sales --transport streamable-http, then reference it with mcp_servers + mcp_toolset (beta mcp-client-2025-11-20) on client.beta.messages.create(...).

Library

The same retrieval is available directly in Python:

from okf import Bundle, StructuredRetriever, GraphExpandedRetriever, pack

bundle = Bundle.load("./sales")

doc = bundle["tables/orders.md"]
doc.type                       # "BigQuery Table"
doc.links                      # resolved internal links -> [Doc(customers), ...]
bundle.neighbors(doc, hops=2)  # graph expansion

# Keyword (BM25) retrieval with frontmatter filtering — no embeddings needed
hits = StructuredRetriever(bundle).search("weekly active users", type="Metric")

# Graph-expanded retrieval: surface structurally-related docs the query missed
graph = GraphExpandedRetriever(StructuredRetriever(bundle), bundle, hops=1)
hits = graph.search("weekly active users")

# Token-budgeted, citable context block, ready to drop into a prompt
ctx = pack(hits, max_tokens=4000)
ctx.text          # assembled markdown
ctx.citations     # ["metrics/weekly_active_users.md", ...]

Semantic (vector) retrieval

from okf import Bundle, SemanticRetriever
from okf.retrieve import VoyageEmbedder      # or SentenceTransformerEmbedder

bundle = Bundle.load("./sales")
retriever = SemanticRetriever(bundle, VoyageEmbedder())  # set VOYAGE_API_KEY
hits = retriever.search("which table has revenue per order")

Anthropic's Claude API has no embeddings endpoint, so the embedder is pluggable. The [semantic] extra ships Voyage AI (Anthropic's recommended embedding partner) and sentence-transformers (offline, no API key). Any object with embed_documents / embed_query works. Wrap a SemanticRetriever in GraphExpandedRetriever for vector + graph retrieval.

CLI

okf validate ./sales                 # lint against the OKF spec (exit 1 on errors)
okf search ./sales "orders"          # keyword (BM25) search
okf search ./sales "orders" --graph  # + graph expansion
okf search ./sales "orders" --semantic  # vector search (OKF_EMBEDDER=voyage|local)
okf graph ./sales --json             # emit the resolved link graph
okf serve-mcp ./sales                # serve the bundle as an MCP tool server

Install

pip install okf-retrieve              # core: model + graph + BM25 retrieval + CLI (PyYAML only)
pip install "okf-retrieve[mcp]"       # + MCP server
pip install "okf-retrieve[semantic]"  # + vector retrieval (numpy, Voyage, sentence-transformers)

Requires Python 3.10+. The distribution is okf-retrieve; you still import okf.

Status

0.1.0, early alpha. Implemented: bundle model + link graph, validation, BM25 / semantic / graph-expanded retrieval, context packing, the MCP server, and the CLI. Roadmap: a reference Claude agent, pluggable vector stores, and bundle generators.

Related projects

The OKF tooling space is young. okf-toolkit covers init/validate/search as a CLI; py-okf generates bundles from Python code; hermes-okf is an agent-memory layer. okf focuses specifically on the agent-native retrieval surface (MCP).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

okf_retrieve-0.1.1.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

okf_retrieve-0.1.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file okf_retrieve-0.1.1.tar.gz.

File metadata

  • Download URL: okf_retrieve-0.1.1.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for okf_retrieve-0.1.1.tar.gz
Algorithm Hash digest
SHA256 672dd542df0f7869c6741526a03d5098f0b75ae13ad97b77bc7650cdd3af72f2
MD5 4dba615f512cc84e012442a8250112b0
BLAKE2b-256 207b8401eb5535bb6ff22733adf8bbf691f1040fd52115c0a568f08c7d2c417b

See more details on using hashes here.

File details

Details for the file okf_retrieve-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: okf_retrieve-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for okf_retrieve-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94afd532ec69fdf8b8a354e85e863be9ca1fe9d7fc52d6c3a81cf0e68e33f2ae
MD5 9d09474f48cf30b77e785569e64328dd
BLAKE2b-256 b408a1f8e28727249d6c481c3cc91114f3f072f8196d79c721e78c8f0155d0ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page