Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43214e9c49
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
Adds an MCP (Model Context Protocol) stdio server (phan-mcp) to expose Phan capabilities to AI agents, backed by (1) a read-only Phound SQLite database for fast symbol queries and (2) the Phan daemon for live analysis.
Changes:
- Introduces a Go-based MCP server with JSON-RPC/MCP protocol handling plus tool dispatch for SQLite- and daemon-backed operations.
- Extends
PhoundPluginto persist signature/parameter data into SQLite to support symbol/signature/file-based queries. - Updates Language Server diagnostics to populate LSP
Diagnostic.codewith Phan’s check name (string), and updates integration tests accordingly.
Reviewed changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tool/phan-mcp/main.go | MCP server entrypoint, stdio loop, flag parsing, SQLite/daemon initialization logging |
| tool/phan-mcp/protocol.go | JSON-RPC + MCP type definitions and helper result builders |
| tool/phan-mcp/tools.go | MCP tool schemas and dispatch routing to server handlers |
| tool/phan-mcp/sqlite.go | SQLite-backed tool implementations (references, signature, hierarchy, implementations, symbols, file_symbols, unused) |
| tool/phan-mcp/daemon.go | Daemon-backed tool implementations (analyze, type_at) and TCP request/response plumbing |
| tool/phan-mcp/go.mod | Go module definition and dependency on modernc.org/sqlite |
| tool/phan-mcp/go.sum | Go dependency lockfile for the MCP server |
| tool/phan-mcp/build.sh | Build wrapper that bootstraps Go and compiles phan-mcp |
| tool/phan-mcp/ensure-go.sh | Portable Go toolchain bootstrap/download script |
| src/Phan/Plugin/Internal/PhoundPlugin.php | Adds signatures/parameters tables and writes signature data during finalizeProcess |
| src/Phan/LanguageServer/LanguageServer.php | Includes check_name as LSP diagnostic code |
| src/Phan/LanguageServer/Protocol/Diagnostic.php | Allows Diagnostic.code to be `int |
| tests/Phan/LanguageServer/LanguageServerIntegrationTest.php | Updates expected diagnostics to include code as check name |
| .mcp.json | Adds repo MCP server config for Claude Code integration |
| .gitignore | Ignores generated phound DB, built binary, and cached Go toolchain |
Adds a Model Context Protocol (MCP) server that exposes Phan's analysis capabilities as tools for AI coding agents. The server is a small Go binary that routes queries to the Phound SQLite database (instant lookups) or the Phan daemon (live analysis).
Architecture
Tools (9)
analyzetype_atreferencessignaturehierarchyimplementationssymbolsfile_symbolsunusedNew files
tool/phan-mcp/main.go— Entry point, startup logging, NDJSON stdio looptool/phan-mcp/protocol.go— JSON-RPC 2.0 + MCP type definitionstool/phan-mcp/tools.go— Tool definitions (JSON Schema) and dispatchtool/phan-mcp/sqlite.go— 7 SQLite-backed toolstool/phan-mcp/daemon.go— 2 daemon-backed tools (analyze, type_at)tool/phan-mcp/build.sh— Build script (auto-downloads Go if needed)tool/phan-mcp/ensure-go.sh— Portable Go toolchain bootstrapper (Linux + macOS).mcp.json— Claude Code integration config.gitignore— Added generated artifacts (phound.sqlite, binary, .goroot/)Dependencies
modernc.org/sqlite— pure Go SQLite driver (no CGo, no C compiler)Usage
Startup output