Skip to content

Add one_d4 analysis tools to mcpserver (MCP integration) #1030

@aaylward

Description

@aaylward

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

  1. 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)
  2. Create IndexGamesTool.java, IndexStatusTool.java, QueryGamesTool.java implementing McpTool
  3. Wire in McpModule.java — add IndexerHttpClient bean, register 3 new tools
  4. Update BUILD.bazel — add source files and http_client dep
  5. Add INDEXER_BASE_URL env var to mcpserver compose service
  6. 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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions