Files
java-ai-agents/code-search-mcp/README.md
T

24 lines
1.3 KiB
Markdown

# code-search-mcp
A code-search MCP server for a Java monorepo, on the stateless MCP 2026-07-28 spec. JavaParser turns every
`src/main/java` folder under a root into one unit per type and method; an `Embedder` turns each unit into a vector;
three read-only tools (`search_code`, `find_usages`, `get_source`) are served over Streamable HTTP at `/mcp`.
```bash
export JAVA_HOME=/path/to/jdk-25
mvn test -pl code-search-mcp # tests write output/01..09
bash code-search-mcp/scripts/run-all.sh # also packages the jar and writes output/10 with curl
java -jar code-search-mcp/target/code-search-mcp.jar <monorepo-root> [port]
```
| Class | Role |
|---|---|
| `CodeIndexer` | JavaParser + one `CombinedTypeSolver` over every module's source folder |
| `Embedder`, `HashingEmbedder`, `OpenAiCompatibleEmbedder` | the seam: offline word-overlap vectors, or any `/v1/embeddings` endpoint |
| `VectorIndex` | brute-force cosine search |
| `UsageFinder` | name match vs symbol-solved usages, unresolved candidates kept and flagged |
| `CodeSearchTools`, `CodeSearchServer`, `Main` | the three MCP tools, Jetty wiring, the entry point |
`sample-monorepo/` is the four-module shop the tests index. It is deliberately not part of the build.
`output/` holds the transcripts the tests and `scripts/curl-demo.sh` write; the post quotes them verbatim.