okf-mcp-server

okf-mcp-server

Reusable, read-only MCP server that exposes a repo's knowledge files (backlog docs, decisions, design notes) as MCP resources over stdio.

Category
访问服务器

README

okf-mcp-server

Reusable, read-only MCP server that exposes a repo's knowledge files (backlog docs, decisions, design notes) as MCP resources over stdio. Files decide their own fate via OKF-style frontmatter — no per-source config, no kind/glob registry. One package, one process per owner repo, automatic URI namespacing from the repo basename.

Status: 0.2.0 — frontmatter-driven OKF source format.

What is this

okf-mcp-server ships a configurable MCP server (Server from the mcp SDK) and a CLI/Python entry point that:

  • resolves owner from git rev-parse --show-toplevel basename (fallback to cwd basename with a stderr warning);
  • resolves scan roots by precedence: --roots <csv> flag → OKF_MCP_ROOTS env (colon-separated, PATH-style) → built-in default [design/, backlog/docs/, backlog/decisions/];
  • recursively walks every root, parses frontmatter, and registers a file as an MCP resource iff export: true and type is non-empty (strict opt-in);
  • serves list_resources and read_resource over stdio for any MCP-aware client (Claude Code, Cursor, etc.).

It is read-only — no write_resource, no hot-reload, no search tool.

Frontmatter contract

Every exported file declares itself in its own frontmatter:

---
type: "Architecture Decision"   # required for export; free-form, OKF-semantic; slugified into URI
title: Knowledge Mesh foundation
export: true                    # required; opt-in — absent or false → file is invisible
description: ...                # optional; falls back to first non-heading paragraph (≤ 500 chars)
id: decision-2                  # optional; falls back to filename-derived id
---

Fields are read as-is; no schema validation beyond the strict export gate.

URI scheme

Every resource URI follows knowledge://{owner}/{type-slug}/{id}.

  • owner — basename of the git toplevel (stable contract).
  • type-slug — deterministic slug of frontmatter type: lowercase, non-alphanumeric runs collapsed to -, leading/trailing - trimmed ("Architecture Decision"architecture-decision). Mutable — editing type changes the slug; consumers must not pin to it.
  • id — frontmatter id if present; otherwise filename-derived: first whitespace-delimited token of the stem (doc-7 - Partner-...mddoc-7), or the full stem when no whitespace is present (c8-saas-...-brainstorm.mdc8-saas-...-brainstorm). Stable — this is the contract that consumers cite.

Per matched file, the resource carries: uri, name (frontmatter title or filename stem), description (frontmatter description or first non-heading paragraph, truncated to 500 chars), mimeType: text/markdown, and the full body (frontmatter stripped) as content.

Scan roots

Roots are resolved relative to the git toplevel, not cwd. A non-existent root is skipped with a stderr warning, not a fatal error. Files outside any configured root (e.g. presentations/, .git/) are invisible.

Precedence:

Source Separator Example
--roots flag , --roots design/,backlog/docs,backlog/decisions
OKF_MCP_ROOTS env : (PATH-style) OKF_MCP_ROOTS="design/:backlog/docs:backlog/decisions"
built-in default n/a design/, backlog/docs/, backlog/decisions/

The first non-empty source wins; lower precedence is ignored entirely (not merged).

In-repo adoption (PEP 723 shim)

When the owner repo lives in the same workspace as this package, the shim resolves okf-mcp-server from a local path — no publish step required. One file in the owner repo:

mcp/server.py:

# /// script
# requires-python = ">=3.10"
# dependencies = ["okf-mcp-server"]
#
# [tool.uv.sources]
# okf-mcp-server = { path = "../okf-mcp-server" }
# ///
from okf_mcp_server import run

if __name__ == "__main__":
    run()

Run it:

uv run mcp/server.py

uv resolves the path source and installs deps on first run. Wire it into Claude Code via a project-level .mcp.json entry pointing at uv run mcp/server.py.

Cross-repo adoption

When the owner repo lives in a different repo, install via git URL pinned to a release tag:

uv add 'okf-mcp-server @ git+https://example.invalid/okf-mcp-server.git@v0.2.0'

The host above is a placeholder — replace it with the canonical remote once the repository is published. The package lives at the repository root (no #subdirectory= is needed). Pin by tag (e.g. @v0.2.0) for reproducible federation across owner repos.

The shim then drops the [tool.uv.sources] block:

# /// script
# requires-python = ">=3.10"
# dependencies = ["okf-mcp-server"]
# ///
from okf_mcp_server import run

if __name__ == "__main__":
    run()

Known limitations

  • Single-process per owner. One running process serves exactly one git repo. Multi-owner federation is achieved by running one shim per owner; there is no built-in aggregator.
  • No hot-reload. Roots are walked once at startup. Edits to source files require restarting the server.
  • OKF index.md / log.md are not special. If they carry export: true + type, they become ordinary resources; otherwise invisible.
  • type-slug is not contractual. Editing type will silently change the URI's middle segment. Cite resources by id.

Linter

A companion CLI, okf-mcp-lint, enforces three frontmatter invariants over the same roots the server scans, so misconfigured files fail loud locally and in CI instead of silently disappearing from the served set.

Check Severity Behaviour
Duplicate id within owner error Non-zero exit; both file paths reported.
export: true with missing/empty type error Non-zero exit; file path reported.
Distinct type values that slugify to the same URI segment warning Zero exit; both type strings + slug reported.

id derivation and type-slug derivation are imported directly from the server module (extract_id, slugify_type) — the linter never reimplements them, so a verdict from the linter implies the same outcome at server load time.

Run it from the owner repo (the okf-mcp-lint console script is available once the package is installed):

okf-mcp-lint
# or, with overrides:
okf-mcp-lint --roots design/,backlog/docs

--roots and OKF_MCP_ROOTS precedence matches the server CLI.

Tests

Tests live in tests/. Run them from the repository root:

uv run pytest

tests/fixtures/sample-project/ is the worked example used by the smoke / contract / protocol tests; tests/conftest.py copies it into a fresh tmp dir and git inits it so the resolver behaves as in a real owner repo.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选