Context
Follow-up to #1028. With one_d4 deployed on the consolidated stack, mcpserver can proxy to it over the Docker network to expose chess indexing and querying to LLM agents.
Approach: HTTP Proxy (Option B)
mcpserver tools call one_d4's REST API over the Docker network (http://one_d4:8080). This keeps mcpserver lightweight with no DB dependencies, maintains a clean service boundary, and allows independent scaling.
New MCP Tools
index_chess_games
- Delegates to
POST http://one_d4:8080/index
- Input:
username, platform, start_month, end_month
- Returns request ID + status for polling
index_status
- Delegates to
GET http://one_d4:8080/index/{id}
- Input:
request_id
- Returns status, game count, error message
query_chess_games
- Delegates to
POST http://one_d4:8080/query
- Input:
query (ChessQL string), limit
- Rich description including ChessQL syntax reference so LLMs can construct queries
- Available motifs: pin, cross_pin, fork, skewer, discovered_attack
- Available fields: white.elo, black.elo, white.username, black.username, time.class, eco, result, num.moves
analyze_position (deferred)
- Requires new endpoint in one_d4 first (not yet implemented)
Implementation Steps
- Create
IndexerHttpClient.java in mcpserver tools — uses existing //domains/platform/libs/http_client, base URL from INDEXER_BASE_URL env var (default http://one_d4:8080)
- Create
IndexGamesTool.java, IndexStatusTool.java, QueryGamesTool.java implementing McpTool
- Wire in
McpModule.java — add IndexerHttpClient bean, register 3 new tools
- Update
BUILD.bazel — add source files and http_client dep
- Add
INDEXER_BASE_URL env var to mcpserver compose service
- Unit tests for each tool
Example Agent Flow
User: "Index hikaru's games from March 2024 and find forks"
Agent → index_chess_games(username="hikaru", platform="chess.com", start_month="2024-03", end_month="2024-03")
→ mcpserver → POST one_d4:8080/index → {"id":"abc-123","status":"PENDING"}
Agent → index_status(request_id="abc-123")
→ mcpserver → GET one_d4:8080/index/abc-123 → {"status":"COMPLETED","gamesIndexed":147}
Agent → query_chess_games(query="white.username=\"hikaru\" AND motif(fork)", limit=10)
→ mcpserver → POST one_d4:8080/query → {"games":[...],"count":7}
References
- Design doc:
domains/games/apis/one_d4/src/main/java/com/muchq/games/one_d4/docs/MCP_INTEGRATION.md
- mcpserver tool pattern:
domains/games/apis/mcpserver/src/main/java/com/muchq/games/mcpserver/tools/
Context
Follow-up to #1028. With one_d4 deployed on the consolidated stack, mcpserver can proxy to it over the Docker network to expose chess indexing and querying to LLM agents.
Approach: HTTP Proxy (Option B)
mcpserver tools call one_d4's REST API over the Docker network (
http://one_d4:8080). This keeps mcpserver lightweight with no DB dependencies, maintains a clean service boundary, and allows independent scaling.New MCP Tools
index_chess_gamesPOST http://one_d4:8080/indexusername,platform,start_month,end_monthindex_statusGET http://one_d4:8080/index/{id}request_idquery_chess_gamesPOST http://one_d4:8080/queryquery(ChessQL string),limitanalyze_position(deferred)Implementation Steps
IndexerHttpClient.javain mcpserver tools — uses existing//domains/platform/libs/http_client, base URL fromINDEXER_BASE_URLenv var (defaulthttp://one_d4:8080)IndexGamesTool.java,IndexStatusTool.java,QueryGamesTool.javaimplementingMcpToolMcpModule.java— addIndexerHttpClientbean, register 3 new toolsBUILD.bazel— add source files andhttp_clientdepINDEXER_BASE_URLenv var to mcpserver compose serviceExample Agent Flow
References
domains/games/apis/one_d4/src/main/java/com/muchq/games/one_d4/docs/MCP_INTEGRATION.mddomains/games/apis/mcpserver/src/main/java/com/muchq/games/mcpserver/tools/