Add code-search-mcp module: JavaParser index, swappable embedder and three MCP tools on the 2026-07-28 stateless spec (MCP Java SDK 2.2.0)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6BHcz4muRH44T3br3
This commit is contained in:
Ankur
2026-11-25 13:29:50 +05:30
co-authored by Claude Sonnet 5.5
parent 26e0a3875a
commit e116c4d5a4
45 changed files with 2002 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Runs the packaged fat jar and talks to it with curl: the same three tools, no SDK, no test harness.
# Writes output/10-fat-jar-curl.txt.
set -eu
cd "$(dirname "$0")/.."
PORT=8791
OUT=output/10-fat-jar-curl.txt
META='"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"curl","version":"1"},"io.modelcontextprotocol/clientCapabilities":{}}'
java -jar target/code-search-mcp.jar sample-monorepo "$PORT" > /tmp/code-search-mcp.log 2>&1 &
PID=$!
trap 'kill $PID 2>/dev/null || true' EXIT
for _ in $(seq 1 60); do grep -q 'serving MCP' /tmp/code-search-mcp.log && break; sleep 0.5; done
call() { # $1 tool, $2 arguments json
curl -s -X POST "http://127.0.0.1:$PORT/mcp" \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-H 'MCP-Protocol-Version: 2026-07-28' -H 'Mcp-Method: tools/call' -H "Mcp-Name: $1" \
-d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"$1\",\"arguments\":$2,$META}}"
}
{
echo '# java -jar target/code-search-mcp.jar sample-monorepo 8791, then curl'
grep -E 'indexed|serving|HmacRequestStateCodec' /tmp/code-search-mcp.log | sed -E 's#/[^ ]*/sample-monorepo#sample-monorepo#; s#:[0-9]{4,5}/mcp#:<port>/mcp#'
echo
echo '$ curl ... -H "Mcp-Method: tools/call" -H "Mcp-Name: search_code" -d {"query":"cancel an order","k":2}'
call search_code '{"query":"cancel an order","k":2}' | python3 -c 'import sys,json; print(json.load(sys.stdin)["result"]["content"][0]["text"])'
} > "$OUT"
cat "$OUT"
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Regenerates every file in output/: the tests write 01-09, the jar plus curl writes 10.
set -eu
cd "$(dirname "$0")/.."
mvn -B -q -f ../pom.xml -pl code-search-mcp package
bash scripts/curl-demo.sh