okf-mcp
A project-agnostic Open Knowledge Format MCP server that indexes Markdown concepts with YAML frontmatter and provides CLI and MCP tools for search, validation, and graph navigation of structured knowledge.
README
okf-mcp
okf-mcp is a project-agnostic Open Knowledge Format CLI, graph index, generator runner, MCP stdio server, and optional HTTP authoring API.
It consumes one or more directories of Markdown files with YAML frontmatter, treats non-reserved Markdown files as OKF concepts, and exposes those concepts through CLI commands plus MCP resources and tools for structured search, validation, graph navigation, and proposal-based authoring.
The core intentionally has no runtime dependencies, no database, and no embeddings. Local bundle mode makes no network calls. Optional remote bundles can fetch public Markdown concepts from GitHub when configured. Generator plugins and accepted authoring proposals are the write paths, and both write only under configured project directories.
Install And Run
From this repository:
git clone https://github.com/mfdaves/okf-mcp.git
cd okf-mcp
npm test
node bin/okf-mcp.js --bundle ./okf/bundles/app --inspect
node bin/okf-mcp.js --bundle app=./okf/bundles/app
--bundle accepts either a path or id=path. Multiple --bundle flags are allowed.
--remote-bundle accepts id=https://github.com/<owner>/<repo>/tree/<ref>/<path>. It fetches public Markdown files from that GitHub tree and indexes them as a read-only bundle.
--inspect prints a compact graph summary and exits. Without --inspect and without an explicit command, the process starts a stdio MCP server.
The package also exposes an okf binary when installed.
Project Config
For project-agnostic use, create an okf.project.yaml at a repository root:
project: Example
bundles:
- id: app
root: okf/bundles/app
include: ["**/*.md"]
exclude: ["archive/**"]
- id: data
root: okf/bundles/data
relationTypes:
- deployed_by
remoteBundles:
- id: shared
url: https://github.com/example/okf-atlas/tree/main/bundles/shared
include: ["public/**"]
exclude: ["drafts/**"]
plugins:
- name: docs
type: filesystem
root: docs
output: okf/bundles/app/generated/docs
bundle: app
Run project commands:
node bin/okf-mcp.js --project okf.project.yaml validate
node bin/okf-mcp.js --project okf.project.yaml search "orders"
node bin/okf-mcp.js --project okf.project.yaml graph mermaid
node bin/okf-mcp.js --project okf.project.yaml generate
node bin/okf-mcp.js --project okf.project.yaml mcp
OKF_WRITE_TOKEN=change-me node bin/okf-mcp.js --project okf.project.yaml serve
node bin/okf-mcp.js --remote-bundle shared=https://github.com/example/okf-atlas/tree/main/bundles/shared --inspect
Commands:
mcpvalidategraph [json|dot|mermaid]search <query>concept <uri>neighbors <uri>paths <from> <to>generateserve
serve options:
--host <host>: bind host, default127.0.0.1--port <port>: bind port, default8765--write-token <token>: bearer token for write endpoints; defaults toOKF_WRITE_TOKEN--proposal-root <path>: proposal JSON directory; defaults to.okf-proposalsunder the project root
MCP Client Config
Example client configuration:
{
"mcpServers": {
"okf": {
"command": "node",
"args": [
"/absolute/path/to/okf-mcp/bin/okf-mcp.js",
"--bundle",
"app=/absolute/path/to/repo/okf/bundles/app"
]
}
}
}
Project config mode, including authoring tools:
{
"mcpServers": {
"okf": {
"command": "node",
"args": [
"/absolute/path/to/okf-mcp/bin/okf-mcp.js",
"--project",
"/absolute/path/to/repo/okf.project.yaml",
"mcp"
]
}
}
}
Concept Format
The server exposes one resource per Markdown document:
okf://<bundle-id>/<relative-path>
Resources use text/markdown. Reserved index.md and log.md files are resources, but they are not concept documents.
Concept files may use a path-derived URI or set a stable id:
---
id: okf://app/routes/order-status
type: API Route
title: Order Status Route
description: Serves order status state.
aliases: [order-status]
tags: [api, orders]
relations:
- type: consumes
target: okf://data/tables/order_status
- type: configured_by
target: repo://src/routes/order-status.js
---
# Order Status Route
okf:// relation targets must resolve to a known concept. Non-OKF targets such as repo:// are treated as external opaque references.
Tools
list_bundleslist_conceptsget_conceptsearch_conceptslist_typeslist_tagslist_relation_typesload_remote_bundlelist_remote_bundlesokf_validate_conceptokf_suggest_concept_pathokf_propose_conceptokf_list_proposalsokf_get_proposalokf_accept_proposalokf_reject_proposalget_graphget_neighborsget_subgraphfind_pathsgraph_summaryvalidate_bundlevalidate_projectexport_graph
Most MCP tools are read-only over the current index. load_remote_bundle mutates only the server's in-memory index by fetching a public GitHub tree; it does not write files.
The okf_* authoring tools are proposal-first. They are enabled when the server is started with --project, because the project config identifies writable local bundles. Proposing a concept writes only a proposal record. Accepting a proposal writes the Markdown concept into the configured bundle root and refreshes the in-memory index.
Authoring Concepts
Concept authoring is available through MCP tools and the HTTP API. Clients never need direct local file access.
MCP proposal flow:
{
"name": "okf_propose_concept",
"arguments": {
"bundle": "app",
"path": "tools/create-order.md",
"frontmatter": {
"type": "MCP Tool",
"title": "Create Order",
"relations": [
{
"type": "related_to",
"target": "okf://app/workflows/order-creation"
}
]
},
"body": "# Create Order\n\nCreates an order through the application MCP tool.",
"message": "Document create_order for agents."
}
}
Then call okf_accept_proposal with the returned proposal.id.
Safety rules:
- concept paths must be safe relative
.mdpaths inside a writable bundle - missing subdirectories are created only when a proposal is accepted
index.mdandlog.mdcannot be authored as concepts- duplicate paths and duplicate
okf://IDs are rejected - invalid IDs, invalid relation types, and broken internal OKF relations fail validation
- external relation targets such as
repo://...are allowed
HTTP API
Start the HTTP server:
OKF_WRITE_TOKEN=change-me node bin/okf-mcp.js --project okf.project.yaml serve --host 127.0.0.1 --port 8765
Read/validation endpoints:
GET /healthGET /v1/bundlesPOST /v1/concepts/validatePOST /v1/concepts/suggest-pathGET /v1/proposalsGET /v1/proposals/:id
Mutation endpoints require Authorization: Bearer <OKF_WRITE_TOKEN>:
POST /v1/proposalsPOST /v1/proposals/:id/acceptPOST /v1/proposals/:id/reject
The default file-backed proposal store writes proposal JSON under .okf-proposals in the project root. Accepted proposals write Markdown concepts into the configured bundle root.
POST /v1/concepts/validate and POST /v1/concepts/suggest-path do not persist anything. POST /v1/proposals persists only a proposal record. Only POST /v1/proposals/:id/accept writes a concept Markdown file.
Remote Bundles
Remote bundles let one project consume concepts published by another repository without cloning or vendoring them locally.
Supported source:
- Public GitHub repository tree URLs:
https://github.com/<owner>/<repo>/tree/<ref>/<path>
Remote loading:
- indexes only
.mdfiles - ignores non-Markdown files
- keeps each remote bundle under its configured bundle id
- supports
includeandexcludefilters - resolves Markdown links inside the remote bundle path
- enforces file count and byte limits
- does not execute code from the remote repository
CLI examples:
node bin/okf-mcp.js --remote-bundle shared=https://github.com/example/okf-atlas/tree/main/bundles/shared --inspect
node bin/okf-mcp.js --project okf.project.yaml --remote-bundle vendor=https://github.com/example/vendor-okf/tree/main/bundles/catalog validate
MCP runtime loading:
{
"name": "load_remote_bundle",
"arguments": {
"id": "shared",
"url": "https://github.com/example/okf-atlas/tree/main/bundles/shared",
"include": ["public/**"]
}
}
Use list_remote_bundles to inspect what was loaded.
Structured Search
search_concepts accepts:
querybundletypestagsAnytagsAllpathPrefixfrontmatterlinkedTolinkedFromrelationTypeorphanOnlylimitoffset
Tags and types are matched case-insensitively. Arbitrary frontmatter filters support exact scalar matching and array-contains matching.
Example:
{
"query": "catalog",
"types": ["API Route"],
"tagsAll": ["api", "orders"],
"limit": 10
}
Graph Behavior
Markdown links between OKF documents become markdown_link edges. Frontmatter relations become typed relation edges.
Graph tools return compact JSON:
{
"nodes": [
{
"id": "okf://app/routes/order-status",
"bundle": "app",
"path": "routes/order-status.md",
"type": "API Route",
"title": "Order Status Route",
"tags": ["api", "orders"],
"description": "Serves order status state."
}
],
"edges": [],
"warnings": []
}
Use graph_summary first for a compact overview, get_neighbors for local traversal, and get_subgraph for bounded expansion around seed concepts. export_graph supports json, dot, and mermaid. Pass includeExternal: true to graph tools when opaque external targets should appear as graph nodes.
Default relation types:
depends_onproducesconsumespersists_tomaterializes_toconfigured_bychecked_byowned_bysupersedesrelated_to
Add project-specific relation types with relationTypes in okf.project.yaml.
Project paths in bundles and plugins must be relative paths that stay inside the directory containing okf.project.yaml. Absolute paths and ../ escapes are rejected.
Bundle include and exclude filters use simple path patterns:
- exact file paths, such as
services/order-status.md - directory prefixes, such as
archive/ *for one path segment**for any nested path
Validation
validate_bundle and validate_project report:
- invalid or unsupported YAML frontmatter
- missing frontmatter on concept files
- missing non-empty
typeon concept files - duplicate OKF URIs
- broken internal Markdown links
- invalid relation types
- missing relation targets
- broken
okf://relation targets - duplicate bundle IDs
- invalid or escaping project paths
- links that resolve outside the configured bundle root
- missing bundle roots
The server keeps serving valid concepts from partial bundles.
Generator Plugins
Generator plugins are configured in okf.project.yaml and run with generate.
Built-in plugins:
filesystem: creates one concept per matching source file. Defaults to Markdown files.json-spec: creates one concept per JSON file and can emitpersists_torelations when a destination table is present.
Generated output is regular Markdown/YAML OKF and is validated by the same indexer as hand-authored concepts.
Limitations
- The YAML parser intentionally supports the simple frontmatter shape used by OKF concept metadata: scalar keys, inline arrays, block arrays, and arrays of objects.
- The MCP server implements the stdio JSON-RPC methods needed for resources and tools directly instead of using an SDK, so advanced SDK conveniences are out of scope.
- There is no file watcher. Restart the server after external file changes. Concepts accepted through MCP authoring refresh the MCP server index immediately.
- The HTTP API is a lightweight built-in server, not a full hosted multi-tenant service.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。