桥牌双明手计算MCP服务

一个通过REST API暴露Endplay桥牌双明手计算的MCP服务,可返回单个或多个牌局的完整赢墩表,适用于桥牌AI助手与牌局分析工具。

  • by BSalita
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 BSalita/endplay-dd-mcp-server

使用说明

endplay-dd-mcp-server

MCP server exposing endplay double-dummy calculations through a first-party REST API. The MCP process is an HTTP client and never imports Endplay directly.

Tools

  • double_dummy(pbn: str)
    Returns a full 20-cell trick table (N/E/S/W declarer x C/D/H/S/NT strain).
  • double_dummy_batch(pbns: list[str])
    Same result shape for multiple deals in one call.

Setup

cd c:/sw/bridge/ML-Contract-Bridge/src/endplay-dd-mcp-server
python -m venv .venv
.venv/Scripts/activate
pip install -e .

Run

Start the first-party API, then the MCP client:

endplay-dd-api
# In another terminal:
endplay-dd-mcp

The MCP server runs over stdio by default. Configure its API endpoint with ENDPLAY_DD_API_BASE_URL (default http://127.0.0.1:8001).

Example input

N:9642.95.AKQT4.K7 KJ3.K3.98.T98654 AQT85.Q862..AQJ2 7.AJT74.J76532.3

Example output (shape)

{
  "ok": true,
  "pbn": "<input>",
  "table": {
    "denom_order": ["C", "D", "H", "S", "N"],
    "player_order": ["N", "E", "S", "W"],
    "by_declarer": {
      "N": {"C": 8, "D": 8, "H": 7, "S": 7, "N": 9},
      "E": {"C": 5, "D": 5, "H": 6, "S": 0, "N": 4},
      "S": {"C": 8, "D": 7, "H": 7, "S": 7, "N": 9},
      "W": {"C": 5, "D": 6, "H": 5, "S": 0, "N": 4}
    }
  }
}

Cursor MCP config example

Ensure endplay-dd-api is running, then add this server in your MCP config:

{
  "mcpServers": {
    "endplay-dd": {
      "command": "c:/sw/bridge/ML-Contract-Bridge/src/endplay-dd-mcp-server/.venv/Scripts/python.exe",
      "args": [
        "-m",
        "endplay_dd_mcp.server"
      ]
    }
  }
}