Skip to main content
Glama
azumausu

Shogi MCP Server

by azumausu

Shogi MCP Server

将棋AIエンジンのHTTP APIブリッジおよびMCP(Model Context Protocol)サーバー実装です。

https://github.com/user-attachments/assets/cdff97b9-d60f-411b-b81f-9cabd8e62

将棋AIエンジンのREST APIおよびMCP(Model Context Protocol)サーバー実装です。
現時点のLLMとUSI形式の将棋AIの統合し、指し手の説明をさせるためのサンプルプログラムです。

概要

このプロジェクトは、ネイティブの将棋エンジンバイナリをラップし、以下の2つのインターフェースを提供します:

  • HTTP API Bridge: HTTPエンドポイント経由での将棋局面解析

  • MCP Server: AIエージェント統合のためのModel Context Protocolサーバー

Related MCP server: Stream MCP

必要要件

  • Node.js 18.0.0以上

  • USIプロトコル対応の将棋エンジン

  • 評価関数ファイル(nn.bin)

インストール

# リポジトリのクローン
git clone <repository-url>
cd shogi-mcp

# 依存関係のインストール
npm install

セットアップ

  1. 将棋エンジンバイナリを engine/engine に配置

  2. 評価関数ファイルを eval/nn.bin に配置

使用方法

Claude Desktop

claude_desktop_config.jsonに以下を追記

  "mcpServers": {
    "shogi-mcp": {
      "command": "ここにnodeのフルパスを追加",
      "args": ["ここにmcp-server.mjsのフルパスを追加"],
      "env": {
        "REST_BASE": "http://localhost:8787"
      }
    }
  }

ブリッジサーバーの起動

npm run start:bridge

デフォルトでポート8787で起動します。

APIエンドポイント

GET /health

  • ヘルスチェック用エンドポイント

GET /analyze

  • 局面解析エンドポイント

パラメータ:

  • sfen (必須): SFEN形式の局面

  • depth: 探索深さ(デフォルト: 30、最大: 30)

  • multipv: 候補手の数(デフォルト: 10、最大: 10)

  • threads: 使用スレッド数(デフォルト: 1、最大: 8)

  • forceMove: 指定した手を指した後の局面を解析

例:

curl "http://localhost:8787/analyze?sfen=lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL%20b%20-%201&depth=20&multipv=5"

MCPサーバーの起動

npm run start:mcp

MCPサーバーはstdio経由で通信し、以下のツールを提供します:

  • ping: 疎通確認

  • analyze: 局面の完全解析(MultiPV)

  • eval_at: 特定の手を指した後の局面評価

環境変数

変数名

説明

デフォルト値

ENGINE_PATH

将棋エンジンのパス

./engine/engine

PORT

ブリッジサーバーのポート

8787

REST_BASE

MCPサーバーが使用するブリッジAPIのベースURL

http://localhost:8787

DEBUG

エンジン通信のデバッグログを有効化("1"で有効)

-

EVAL_FILE

評価関数ファイルのパス

-

EVAL_DIR

評価関数ディレクトリのパス

-

プロジェクト構成

shogi-mcp/
├── src/
│   ├── core/
│   │   └── engine.js         # USIプロトコルエンジンラッパー
│   └── servers/
│       ├── bridge-server.js  # Express HTTP APIブリッジサーバー
│       └── mcp-server.mjs    # MCPサーバー実装
├── engine/
│   └── engine                # 将棋エンジンバイナリ
├── eval/
│   └── nn.bin               # 評価関数(NNUEで実装)
├── package.json
└── README.md        

開発

テスト

ブリッジAPIのテスト例:

# ヘルスチェック
curl http://localhost:8787/health

# 初期局面の解析
curl "http://localhost:8787/analyze?sfen=startpos&depth=15&multipv=3"

トラブルシューティング

評価関数が読み込めない場合

環境変数で明示的にパスを指定してください:

EVAL_FILE=./eval/nn.bin EVAL_DIR=./eval npm run start:bridge

エンジンが起動しない場合

  1. エンジンバイナリの実行権限を確認

chmod +x engine/engine
  1. エンジンパスを環境変数で指定

ENGINE_PATH=/path/to/engine npm run start:bridge

ライセンス

MIT

Available Tools

3 tools
analyzeEngine 解析C

SFENを解析して候補手(MultiPV)・評価値・PVを返す

ParametersJSON Schema
NameRequiredDescriptionDefault
depthNo
forceMoveNo
multipvNo
sfenYes
threadsNo

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool returns data (candidate moves, evaluations, PV) but doesn't describe performance characteristics (e.g., computation time, resource usage), error handling, or any side effects. For an analysis tool with 5 parameters and no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence in Japanese that efficiently conveys the core purpose. It's front-loaded with the main action ('analyze SFEN') and avoids any redundant information. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain the output format, how results are structured, or any limitations (e.g., depth/multipv constraints). While concise, it lacks the detail needed for an agent to effectively use this tool without additional context or trial-and-error.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It only mentions 'SFEN' implicitly and doesn't describe any of the 5 parameters (sfen, depth, multipv, threads, forceMove) or their effects on the analysis. The description adds no meaningful semantic information beyond what the parameter names suggest, failing to address the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: analyzing SFEN (Shogi Forsyth–Edwards Notation) to return candidate moves (MultiPV), evaluation values, and PV (principal variation). It uses specific verbs ('analyze' and 'return') and identifies the resource (SFEN positions). However, it doesn't explicitly differentiate from sibling tools like 'eval_at' or 'ping', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'eval_at'. It doesn't mention any prerequisites, constraints, or typical use cases (e.g., game analysis, move exploration). The agent must infer usage from the purpose alone, which is insufficient for effective tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

eval_at特定手の直後を評価C

現局面で特定の一手を指した先を解析して返す

ParametersJSON Schema
NameRequiredDescriptionDefault
depthNo
moveYes
multipvNo
sfenYes
threadsNo

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions analysis and returning results, but lacks details on computational behavior (e.g., performance impact, rate limits), error handling, or output format. For a tool with 5 parameters and no output schema, this is insufficient to inform safe and effective usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence that directly states the tool's function without any unnecessary words. It's front-loaded with the core purpose, making it efficient and easy to parse, though this conciseness comes at the cost of detail in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters, no annotations, no output schema), the description is incomplete. It doesn't cover parameter meanings, behavioral traits, or output details, leaving significant gaps for an AI agent to understand how to invoke and interpret results from this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the schema provides no parameter descriptions. The tool description adds no semantic information about parameters like 'sfen,' 'move,' 'depth,' 'multipv,' or 'threads.' It doesn't explain what these parameters mean or how they affect the analysis, failing to compensate for the low schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'analyze and return the evaluation after a specific move in the current position.' It specifies the verb ('analyze') and resource ('current position after a specific move'), making the function understandable. However, it doesn't explicitly differentiate from sibling tools like 'analyze' or 'ping,' which could provide similar or related functionality, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'analyze' or 'ping,' nor does it specify prerequisites, exclusions, or optimal contexts for usage. This lack of comparative or contextual advice limits its effectiveness in tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

pingPingB

ヘルスチェック(常に pong を返す)

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool always returns 'pong,' which implies a read-only, non-destructive operation, but it doesn't cover aspects like error handling, latency, or side effects. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence in Japanese that directly states the tool's function. It's front-loaded with the key information ('health check') and avoids any redundant or verbose language, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (0 parameters, no output schema, simple purpose), the description is adequate but minimal. It covers the basic purpose and behavior but lacks details on usage context or advanced behavioral traits. With no annotations or output schema, it meets the minimum viable standard but could be more informative.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter information is needed. The description doesn't add any parameter details, which is appropriate. Baseline is 4 for 0 parameters, as it avoids unnecessary repetition and focuses on the tool's purpose.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'ヘルスチェック(常に pong を返す)' translates to 'Health check (always returns pong).' This specifies the verb ('health check') and the resource/outcome ('always returns pong'), making it distinct from siblings like 'analyze' or 'eval_at.' However, it doesn't explicitly differentiate from potential similar tools (e.g., 'status' or 'health'), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention scenarios like system monitoring, connectivity testing, or prerequisites. Without any usage context, the agent must infer from the purpose alone, which is insufficient for optimal tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv1.0.0
    • First observedanalyze
    • First observedeval_at
    • First observedping

TDQS

B3.1/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: 'analyze' evaluates the current position, 'eval_at' analyzes a specific move from the current position, and 'ping' is a health check. There is no overlap in functionality, making tool selection unambiguous for an agent.

Naming Consistency4/5

The naming is mostly consistent with a verb-based pattern ('analyze', 'eval_at', 'ping'), though 'eval_at' uses an underscore while the others do not, and 'ping' is a simple verb rather than a descriptive action. This minor deviation keeps the set readable but not perfectly uniform.

Tool Count3/5

With only 3 tools, the set feels thin for a Shogi server, as it lacks operations like move generation, game state management, or board manipulation. While the tools cover core analysis, the count is borderline for the domain's potential scope.

Completeness2/5

The tool surface has significant gaps for a Shogi server: there are no tools for creating or modifying game states (e.g., making moves, resetting boards), accessing game history, or handling game rules. This incompleteness will likely cause agent failures in broader Shogi-related tasks.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers