Shogi MCP Server

Shogi MCP Server

Enables AI agents to analyze shogi (Japanese chess) positions and moves by integrating with USI protocol engines. Provides position analysis, move evaluation, and game state assessment through HTTP API bridge and MCP tools.

Category
Visit Server

README

Shogi MCP Server

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

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

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

概要

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

  • HTTP API Bridge: HTTPエンドポイント経由での将棋局面解析
  • MCP Server: AIエージェント統合のためのModel Context Protocolサーバー

必要要件

  • 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured