Add MCP server implementation for ProcessGit repositories#87
Conversation
Implement a read-only MCP server that exposes structured repository data
(XML entities) via JSON-RPC 2.0 over Streamable HTTP transport. Repos
opt in by placing a processgit.mcp.yaml config file in their root.
MVP includes 8 tools: help, identify, describe_model, search, get_entity,
list_entities, validate, and generate_document. The XML parser extracts
entities using a code-attribute heuristic and builds an in-memory index
with per-commit caching.
New files:
- modules/setting/mcp.go — [mcp] app.ini settings
- modules/mcp/ — config parser, XML parser, entity index, tool registry,
JSON-RPC dispatcher, HTTP transport, and 8 tool implementations
- routers/web/repo/mcp.go — route handler wiring MCP to repo context
Route registered at /{username}/{reponame}/mcp (POST+GET) with
reqSignIn and reqUnitCodeReader middleware.
https://claude.ai/code/session_015eAF8G3GZ6iGuwL3WznqAB
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e8378ce39
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // MCP endpoint — Model Context Protocol server for repository | ||
| m.Group("/{username}/{reponame}/mcp", func() { | ||
| m.Post("", repo.MCPEndpoint) | ||
| m.Get("", repo.MCPEndpoint) | ||
| }, reqSignIn, context.RepoAssignment, reqUnitCodeReader) |
There was a problem hiding this comment.
Remove non-functional GET route for MCP
The router exposes GET /{user}/{repo}/mcp, but ServeHTTP only accepts POST and unconditionally returns 405 for any other method (see modules/mcp/transport.go around the method check). That means every GET to this endpoint will always fail despite being advertised, which breaks clients that try a GET-based MCP flow (e.g., streamable HTTP). Either drop the GET route here or add GET handling in the transport to avoid a guaranteed 405.
Useful? React with 👍 / 👎.
Summary
This PR introduces a complete Model Context Protocol (MCP) server implementation for ProcessGit repositories. The MCP server enables AI agents to query and interact with structured data stored in Git repositories through a standardized interface.
Key Features
config.go): Loads and validatesprocessgit.mcp.yamlconfiguration files from repository roots, supporting version 1 with XML data sourcesparser_xml.go): Parses XML files from Git commits, extracting entities based on a "code" attribute heuristic and building hierarchical relationshipsindex.go): Builds and caches entity indexes per repository+commit, supporting full-text search across entity names and attributesserver.go): Implements JSON-RPC 2.0 protocol handlers for MCP methods (initialize, tools/list, tools/call)help: Server capabilities and workflow guidanceidentify: Server identity and repository metadatadescribe_model: Data model overview with entity types and hierarchysearch: Full-text search across all entitiesget_entity: Retrieve detailed information for specific entitieslist_entities: List entities with optional type/parent filteringvalidate: XML validation and data statisticsgenerate_document: Generate Markdown/CSV formatted outputData Model
Entities are identified by
type:codeformat (e.g.,ministry:01,organization:0001) and support:nameattributes and<n>child elementsTesting
Comprehensive test coverage includes:
Validation
processgit.mcp.yamlschema validationTesting
All new code includes unit tests:
go test ./modules/mcp/...Tests cover:
https://claude.ai/code/session_015eAF8G3GZ6iGuwL3WznqAB