mahjong-calculator
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mahjong-calculator手牌: 123m456p789s11z 和了牌: 1z の点数を教えて"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
麻雀点数計算 MCP サーバー
Claude ProjectsやClaude Desktopから麻雀の点数計算ができるMCPサーバーです。
特徴
テキスト形式で牌姿を入力(例:
123m456p789s11z)赤ドラ対応(
0で表現、例:50m= 赤5萬)点数、役、翻数、符を自動計算
Claude Desktopからツールとして直接呼び出し可能
stdio/SSE両方のトランスポートに対応
Related MCP server: musescore-mcp
MCPサーバーとは
MCP (Model Context Protocol) は、Claude DesktopとAIツール間の通信プロトコルです。MCPサーバーを作成することで、Claudeに新しい機能(ツール)を追加できます。
このプロジェクトでは、麻雀の点数計算をClaudeから呼び出せるようにしています。
トランスポート方式
MCPサーバーには2つの接続方式があります:
stdio(標準入出力): Claude Desktopがサーバープロセスを直接起動・管理(推奨)
SSE(Server-Sent Events): HTTPサーバーとして常駐し、Claude Desktopが接続
このプロジェクトでは、安定性と管理の容易さから stdio方式 を推奨しています。
セットアップ
1. 依存関係のインストール
uv sync2. Claude Desktop での設定
設定ファイルの場所:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Linux/macOS(ネイティブ環境)の場合
{
"mcpServers": {
"mahjong-calculator": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mahjong_calculator",
"run",
"python",
"-m",
"src.server"
]
}
}
}注意: /absolute/path/to/mahjong_calculator の部分は、このプロジェクトの絶対パスに置き換えてください。
Windows + WSL環境の場合(推奨設定)
Windows上のClaude DesktopからWSL内のMCPサーバーを起動する場合:
{
"mcpServers": {
"mahjong-calculator": {
"command": "wsl",
"args": [
"-e",
"bash",
"-c",
"export PATH=$HOME/.local/bin:$PATH && cd /home/your-username/projects/mahjong_calculator && exec uv run python -m src.server"
]
}
}
}重要:
/home/your-username/projects/mahjong_calculatorをWSL内の実際のプロジェクトパスに置き換えてくださいyour-usernameをWSLのユーザー名に置き換えてくださいこの設定は、一行のコマンドとして実行されるため、確実に動作します
3. Claude Desktopを再起動
設定を反映させるため、Claude Desktopを完全に終了してから再起動してください。
使用方法
Claude DesktopやClaude Projectsで以下のように質問してください:
基本的な使い方
手牌: 234m345p456s6677z
和了牌: 7z
の点数を教えて注意: 手牌(13枚)と和了牌(1枚)の合計14枚が正しい和了形(4面子1雀頭)である必要があります。
立直ツモの場合
手牌: 234m234p234s555z
和了牌: 5z
でツモ和了、立直ありの場合の点数を計算してドラありの場合
手牌: 234m456p678s3344s
和了牌: 5s
でロン和了、ドラ表示牌が1mの場合の点数は?入力形式
牌の表記
萬子:
1-9m(例:123m)筒子:
1-9p(例:456p)索子:
1-9s(例:789s)字牌:
1-7z1z= 東2z= 南3z= 西4z= 北5z= 白6z= 發7z= 中
赤ドラ:
0で表現(例:50m= 赤5萬)
例
牌姿 | 説明 |
| 一萬二萬三萬四筒五筒六筒七索八索九索東東南南 |
| 一萬二萬三萬赤五萬四筒五筒六筒七索八索九索東東 |
| 二萬三萬四萬二筒三筒四筒二索三索四索白白 |
パラメータ
MCPツール calculate_mahjong_score は以下のパラメータを受け付けます:
パラメータ | 型 | 必須 | デフォルト | 説明 |
| string | ✓ | - | 手牌 |
| string | ✓ | - | 和了牌 |
| string | "" | ドラ表示牌(カンマ区切り) | |
| string | "east" | 自風(east/south/west/north) | |
| string | "east" | 場風(east/south/west/north) | |
| boolean | true | ツモ和了かどうか | |
| boolean | false | 立直しているか | |
| boolean | false | 一発か | |
| boolean | false | 嶺上開花か | |
| boolean | false | 搶槓か | |
| boolean | false | 海底摸月か | |
| boolean | false | 河底撈魚か |
トラブルシューティング
Claude Desktopで認識されない
設定ファイルのパスと形式を確認
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonJSON構文エラーがないか確認(JSONLintで検証可能)
ファイルをUTF-8で保存しているか確認
プロジェクトのパスが絶対パスになっているか確認
相対パスは使用できません
WSL環境の場合:
/home/username/...形式
WSL環境での確認事項
uvコマンドが正しくインストールされているか確認:which uv uv --versionPATHが正しく設定されているか確認
Windows側から手動でコマンドを実行してテスト:
wsl -e bash -c "export PATH=$HOME/.local/bin:$PATH && cd /home/username/projects/mahjong_calculator && uv run python -m src.server"
Claude Desktopを完全に再起動
Windowsの場合: タスクマネージャーでプロセスが完全に終了していることを確認
設定変更後は必ず再起動が必要
サーバーを再起動すると接続できなくなる(WSL環境)
問題: ローカルでSSE形式のサーバーを起動した場合、再起動後にClaude Desktopから接続できなくなる
解決策: stdio形式を使用する(上記の「Windows + WSL環境の場合」の設定)
stdio形式の利点:
Claude Desktopがサーバープロセスのライフサイクルを管理
ポートの競合や接続問題が発生しない
設定が簡単で安定している
SSE形式を使いたい場合
どうしてもSSE形式を使いたい場合は、以下の手順で起動:
bash /home/miz/projects/mahjong_calculator/start_http_server.sh設定ファイル:
{
"mcpServers": {
"mahjong-calculator": {
"url": "http://localhost:8000/sse"
}
}
}注意: SSE形式は手動でサーバーを起動・停止する必要があり、管理が煩雑です。
計算結果がおかしい
入力形式が正しいか確認
萬子:
m, 筒子:p, 索子:s, 字牌:z数字は0-9のみ(0は赤ドラ)
例:
123m456p789s1122z
手牌が14枚になっているか確認
手牌13枚 + 和了牌1枚 = 合計14枚
正しい和了形(4面子1雀頭)である必要があります
和了っているか確認
向聴数が-1(テンパイを超えている状態)
Claude Desktopのログを確認
MCPサーバーのログは標準エラー出力に出力されます。Claude Desktopのログで詳細を確認できます:
macOS:
~/Library/Logs/Claude/Windows:
%APPDATA%\Claude\logs\
ログで以下を確認:
サーバーが正常に起動しているか
コマンドのパスが正しいか
実行時エラーが発生していないか
開発
ローカルでのテスト
MCPサーバーとして起動せずに、直接Pythonスクリプトとして動作確認できます:
# JSON出力のテスト
uv run python test_json_output.py
# エラーケースのテスト
uv run python test_error_cases.pyMCPサーバーのテスト
stdio形式で手動テスト:
bash start_stdio_server.shSSE形式で手動テスト(別ターミナルで実行):
# サーバー起動
bash start_http_server.sh
# 別ターミナルでアクセスを確認
curl http://localhost:8000/sseテストの実行
uv run pytest型チェック
uv run mypy src/コードフォーマット
uv run ruff check src/依存関係の更新
# 依存関係を追加
uv add package-name
# 依存関係を更新
uv sync --upgradeプロジェクト構成
mahjong_calculator/
├── pyproject.toml # プロジェクト設定・依存関係
├── uv.lock # 依存関係のロックファイル
├── README.md # このファイル
├── main.py # スタンドアロン実行用(MCP不使用)
├── start_http_server.sh # SSE形式でのサーバー起動スクリプト
├── start_stdio_server.sh # stdio形式でのサーバー起動スクリプト
├── test_json_output.py # JSON出力のテスト
├── test_error_cases.py # エラーケースのテスト
└── src/
├── __init__.py # パッケージ初期化
├── constants.py # 定数定義
├── tile_parser.py # 入力解析(テキスト→内部形式)
├── calculator.py # 点数計算ロジック
└── server.py # MCPサーバー(エントリーポイント)ファイルの役割
コアモジュール
server.py: MCPサーバーのエントリーポイント。Claude Desktopとの通信を担当
calculate_mahjong_score(): MCPツールとして公開される関数stdio/SSE両方のトランスポートに対応
calculator.py: 麻雀の点数計算ロジック
calculate_hand(): 手牌と和了牌から点数を計算GameContext: 対局状況(自風、場風、リーチなど)を管理役、符、点数の詳細を返す
tile_parser.py: テキスト形式の牌姿を解析
123m456p789s11zのような入力をmahjongライブラリの形式に変換赤ドラ(
0)の処理に対応
constants.py: 役名や符の理由の日本語翻訳など、定数を定義
起動スクリプト
start_stdio_server.sh: stdio形式でサーバーを起動(Claude Desktop推奨)
start_http_server.sh: SSE形式(HTTP)でサーバーを起動
テスト
test_json_output.py: 計算結果のJSON形式をテスト
test_error_cases.py: エラーハンドリングをテスト
アーキテクチャ
Claude Desktop
↓ (MCP stdio/SSE)
server.py (FastMCP)
↓
calculator.py (計算ロジック)
↓
tile_parser.py (入力解析)
↓
mahjong-python (外部ライブラリ)Claude Desktop が MCP プロトコルでリクエストを送信
server.py が
calculate_mahjong_scoreツールとしてリクエストを受信tile_parser.py が牌姿テキストを解析
calculator.py が mahjong-python ライブラリを使って計算
結果を JSON 形式で Claude Desktop に返却
ライセンス
このプロジェクトは個人用です。
Available Tools
1 toolcalculate_mahjong_scoreA
麻雀の点数を計算します
牌姿と和了牌、対局状況から点数と役を計算します。
Args:
tiles: 手牌(例: "123m456p789s1122z")
- 萬子: 1-9m(例: 123m)
- 筒子: 1-9p(例: 456p)
- 索子: 1-9s(例: 789s)
- 字牌: 1-7z(1=東, 2=南, 3=西, 4=北, 5=白, 6=發, 7=中)
- 赤ドラ: 0で表現(例: 50m = 赤5萬)
win_tile: 和了牌(例: "2z")
dora_indicators: ドラ表示牌(カンマ区切り、例: "1m,5p")
player_wind: 自風(east/south/west/north、デフォルト: east)
round_wind: 場風(east/south/west/north、デフォルト: east)
is_tsumo: ツモ和了かどうか(デフォルト: True)
is_riichi: 立直しているかどうか(デフォルト: False)
is_ippatsu: 一発かどうか(デフォルト: False)
is_rinshan: 嶺上開花かどうか(デフォルト: False)
is_chankan: 搶槓かどうか(デフォルト: False)
is_haitei: 海底摸月かどうか(デフォルト: False)
is_houtei: 河底撈魚かどうか(デフォルト: False)
Returns:
str: 計算結果(役、翻数、符、点数)
Examples:
calculate_mahjong_score("123m456p789s1122z", "2z")
→ 役牌の計算結果を返す
calculate_mahjong_score("234m345p456s55z", "5z", is_tsumo=True, is_riichi=True)
→ 立直ツモの計算結果を返す
| Name | Required | Description | Default |
|---|---|---|---|
| tiles | Yes | ||
| is_tsumo | No | ||
| win_tile | Yes | ||
| is_haitei | No | ||
| is_houtei | No | ||
| is_riichi | No | ||
| is_chankan | No | ||
| is_ippatsu | No | ||
| is_rinshan | No | ||
| round_wind | No | east | |
| player_wind | No | east | |
| dora_indicators | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
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 thoroughly explains the input format (including red dora notation), all boolean flags, and the exact return format. This makes the tool's behavior highly transparent for a calculation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
While the description is long, it is well-structured into a purpose statement, Args block, Returns, and Examples. Every sentence adds necessary information, and the formatting makes it easy to scan. There is no fluff or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers all 12 parameters, explains the return value in plain terms (yaku, han, fu, points), and provides two examples. Given the tool's complexity, this is a complete and self-contained description.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides no descriptions for parameters (0% coverage), but the description compensates fully by explaining each parameter in detail, including defaults, examples, and tile encoding conventions. This is exceptional parameter documentation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states it calculates mahjong score and yaku from tile arrangement and game situation. This is a specific verb+resource that clearly explains what the tool does, and since no siblings are listed, there is no need for further differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides clear context and practical examples of when to use the tool, but it does not explicitly mention when not to use it or alternatives. Given the absence of sibling tools, the guidance is sufficient and clearly implied.
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. Dates show when Glama detected each change.
1 tool update
v0.1.0- First observed
calculate_mahjong_score
TDQS
With only one tool, there is no potential for confusion or overlap. The single tool has a clearly defined purpose: calculating mahjong scores.
The tool name 'calculate_mahjong_score' follows a clear verb_noun pattern and is self-explanatory. With a single tool, naming consistency is trivially maintained.
A single tool is too few for a typical MCP server, even for a calculator domain. The tool is comprehensive, but the server feels thin and under-scoped.
The tool covers all necessary aspects of mahjong score calculation, including hand tiles, win tile, dora indicators, winds, and various special conditions. It provides a complete solution for its stated purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- GonkbotOAuthcom.gonkbot
Log golf rounds in ChatGPT/Claude; scorecards, trends, unofficial WHS math.
Chess MCP for Claude: engine analysis, attack maps, game review. One URL, no install.
Teamfight Tactics data & AI coaching for Claude and ChatGPT — 19 tools, built-in Riot key.
Exact Claude API cost calc with real cache economics, plus a tiktoken-misuse scanner.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables Magic: The Gathering players to manage decks and access card information through Claude, supporting gameplay actions like drawing cards and mulligans while providing Scryfall API integration for card lookups.15-
- FlicenseAqualityDmaintenanceEnables Claude AI to convert, edit, and analyze MuseScore files (.mscz, .musicxml, MIDI) through natural language commands, supporting format conversion, transposition, harmony analysis, and more.201-
- -licenseNot gradedqualityNot gradedmaintenanceEnables Claude to send you a Discord message through a Cloudflare Workers MCP server, triggering a notification with your Discord mention.-
- FlicenseNot gradedqualityDmaintenanceEnables AI-assisted gameplay for Slay the Spire by reading game state and providing strategy advice or automated actions via Claude Code.1-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zaqdaisuki/mahjong_calculator'
If you have feedback or need assistance with the MCP directory API, please join our Discord server