Skip to content

feat: add MCP server with stdio transport and project knowledge base - #6

Merged
superops-team merged 2 commits into
mainfrom
feat/mcp-server
Aug 27, 2026
Merged

feat: add MCP server with stdio transport and project knowledge base#6
superops-team merged 2 commits into
mainfrom
feat/mcp-server

Conversation

@superops-team

Copy link
Copy Markdown
Owner

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/)

  • protocol.go — Full JSON-RPC 2.0 message types and MCP protocol types (Initialize, Tools, Resources, Prompts)
  • tools.go — Tool registry with 7 core tools:
    • okf_load_bundle — Load knowledge bundle from directory
    • okf_bundle_stats — Get bundle statistics (types, status, trust tiers, stale count)
    • okf_list_concepts — List concepts with optional type filter
    • okf_get_concept — Get full concept details serialized as Markdown
    • okf_search — Full-text search with type/tag filters
    • okf_lint_bundle — Lint entire bundle with optional strict mode
    • okf_lint_concept — Lint single concept
  • server.go — stdio transport main loop with full message dispatching
  • convert.go — Type conversion helpers between okf and parser packages

CLI Integration

  • Added okf mcp --bundle <path> subcommand to start the MCP server

Project Knowledge Base (docs/knowledge/)

6 OKF v0.2 format documents documenting the project:

  • index.md — Knowledge base index
  • core-types.md — Core type system (v0.2)
  • parser.md — Markdown + YAML parser
  • lint.md — Lint rules and error codes
  • mcp-server.md — MCP server architecture and usage
  • cli.md — CLI command reference

Design Specification (openspec/changes/okf-mcp-server/)

  • proposal.md — Change proposal
  • design.md — Technical design
  • specs/okf-mcp-server/spec.md — MCP server specification

Testing

  • test_mcp.py — End-to-end test script with 11 test cases
  • All tests pass: initialize, tools/list, 7 tool calls, resources/list, prompts/list, ping

MCP 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 ./... passes
  • go test ./... passes
  • End-to-end MCP test: 11/11 tests pass
  • Knowledge base lint passes (0 errors)

superops-bot 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant