feat(mcp): F-14 MCP-server — read-only KB tools for LLM clients #4

Merged
user2595 merged 3 commits from feat/F-14-mcp-server into main 2026-06-14 11:52:08 +00:00
Owner

Summary

  • codex/mcp_server.py: FastMCP server, 7 read-only tools (search, ask, wiki_read, wiki_list, discover_leads, provenance_verify, synthesis_browse)
  • stdio default + optional HTTP transport with token-auth
  • codex/config.py: MCP settings (mcp_transport, mcp_host, mcp_port, mcp_auth_token); F-13 duplicate block removed
  • pyproject.toml: mcp[cli]>=1.0 dep + codex-mcp console_script
  • README.md: Claude Code .mcp.json + Claude Desktop registration snippets
  • 28 new tests in tests/mcp/

Key properties (Review-Gate verified)

  • Read-only invariant: write-verb regex + frozen allowlist in test_readonly.py — fails if any write tool is added
  • HTTP token-auth: _require_http_token() raises before ASGI app starts; tested for missing + present token
  • Graceful degradation: all optional features (wiki, synthesis) return {"error": "not available"}, no crash
  • Provenance on every hit: SQL enforces p.bibkey IS NOT NULL; test asserts full key-set per result

Gate result

APPROVE — all 4 CRITICAL + 4 WARN checks PASS

243 tests total · ruff + mypy clean

## Summary - `codex/mcp_server.py`: FastMCP server, 7 read-only tools (search, ask, wiki_read, wiki_list, discover_leads, provenance_verify, synthesis_browse) - stdio default + optional HTTP transport with token-auth - `codex/config.py`: MCP settings (mcp_transport, mcp_host, mcp_port, mcp_auth_token); F-13 duplicate block removed - `pyproject.toml`: `mcp[cli]>=1.0` dep + `codex-mcp` console_script - `README.md`: Claude Code `.mcp.json` + Claude Desktop registration snippets - 28 new tests in `tests/mcp/` ## Key properties (Review-Gate verified) - **Read-only invariant**: write-verb regex + frozen allowlist in `test_readonly.py` — fails if any write tool is added - **HTTP token-auth**: `_require_http_token()` raises before ASGI app starts; tested for missing + present token - **Graceful degradation**: all optional features (wiki, synthesis) return `{"error": "not available"}`, no crash - **Provenance on every hit**: SQL enforces `p.bibkey IS NOT NULL`; test asserts full key-set per result ## Gate result **APPROVE** — all 4 CRITICAL + 4 WARN checks PASS 243 tests total · ruff + mypy clean
user2595 added 3 commits 2026-06-14 07:00:16 +00:00
Implements F-14: thin FastMCP wrapper over existing codex domain modules.
Seven read-only tools: search, ask, wiki_read, wiki_list, discover_leads,
provenance_verify, synthesis_browse. All optional-feature tools degrade
gracefully to {"error": "feature not available"} instead of crashing.
Adds mcp[cli]>=1.0 dependency and codex-mcp console_script entry-point.
28 new tests across test_server, test_search, test_readonly, test_graceful,
test_http_auth — all green; 0 regressions in existing 172 tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents MCP server setup for Claude Code (.mcp.json) and Claude Desktop
(claude_desktop_config.json), HTTP transport config, and available tools table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
F-13 settings (leads_dir, synthesis_llm_*, synthesis_top_k,
synthesis_min_grounded_ratio, synthesis_gap_min_coverage) appeared twice
due to independent commits on F-13 and F-14 branches. Kept the second
(more complete) block; removed the first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
user2595 merged commit 50e6bb8210 into main 2026-06-14 11:52:08 +00:00
user2595 deleted branch feat/F-14-mcp-server 2026-06-14 11:52:09 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: user2595/codex-py#4
No description provided.