feat: add MCP server with stdio transport and project knowledge base - #6
Merged
Conversation
added 2 commits
August 27, 2026 10:40
- proposal.md: MCP Server 提案(动机、需求、影响、风险) - design.md: 架构设计(分层架构、工具集模块化、安全模型、性能考虑) - specs/okf-mcp-server/spec.md: 完整规范(7 工具集 31 工具、6 资源类型、6 提示词模板、配置、错误处理、测试策略) 参考 GitHub MCP Server 实现模式,支持 stdio/HTTP 传输, 兼容 OKF SPEC v0.2 所有字段,向后兼容 v0.1。
- Implement MCP protocol types (JSON-RPC 2.0 over stdio) - Add 7 core tools: load_bundle, bundle_stats, list_concepts, get_concept, search, lint_bundle, lint_concept - Add resources and prompts capabilities - Add 'okf mcp' CLI subcommand - Create project knowledge base (docs/knowledge/) with 6 OKF v0.2 documents - Add end-to-end test script (test_mcp.py) - all 11 tests pass - Type conversion helpers between okf and parser packages
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add Model Context Protocol (MCP) server support to OKF, enabling AI agents to load, query, search, and lint knowledge bundles through standard MCP tools over stdio transport.
Changes
MCP Server Implementation (
pkg/mcp/)okf_load_bundle— Load knowledge bundle from directoryokf_bundle_stats— Get bundle statistics (types, status, trust tiers, stale count)okf_list_concepts— List concepts with optional type filterokf_get_concept— Get full concept details serialized as Markdownokf_search— Full-text search with type/tag filtersokf_lint_bundle— Lint entire bundle with optional strict modeokf_lint_concept— Lint single conceptCLI Integration
okf mcp --bundle <path>subcommand to start the MCP serverProject Knowledge Base (
docs/knowledge/)6 OKF v0.2 format documents documenting the project:
index.md— Knowledge base indexcore-types.md— Core type system (v0.2)parser.md— Markdown + YAML parserlint.md— Lint rules and error codesmcp-server.md— MCP server architecture and usagecli.md— CLI command referenceDesign Specification (
openspec/changes/okf-mcp-server/)proposal.md— Change proposaldesign.md— Technical designspecs/okf-mcp-server/spec.md— MCP server specificationTesting
test_mcp.py— End-to-end test script with 11 test casesMCP Client Configuration
{ "mcpServers": { "okf": { "command": "okf", "args": ["mcp", "--bundle", "/path/to/knowledge"] } } }Dependencies
This PR depends on the v0.2 spec upgrade (OKF v0.2 types: TrustTier, ConceptStatus, Sources, Verified, Attested Computation, etc.).
Verification
go build ./...passesgo test ./...passes