mihoyo-mcp
mihoyo-mcp
独立したmiHoYo向け MCP Server —— **米游社(中国サーバー)**と **HoYoLAB(国際サーバー)**の両方に対応し、基盤はseriaati/genshin.py(MIT)を利用しています。どんな MCP クライアント(nahida-bot、Claude Desktop、Codex……)からでもそのまま利用できます。
設計の境界
MCP は「どう話すか」を担当し、クライアントは「いつ問い合わせるか、そしてその結果を誰に伝えるか」を担当します。
スケジュール(cron)、閾値ポリシー、メッセージ通知 → クライアント(nahida-bot には Scheduler / Channel が既に存在)
ログイン、クレデンシャル保存、API 呼び出し、アラート重複排除 → 本サービス
クレデンシャルは安全境界の外に一切出ない : Cookie は常にサービス内部のみに保存され(Fernet 暗号化)、ツールの結果に含まれるのは
account_idだけ。Agent の context にトークンが現れることはありません
┌─────────────────────┐
│ nahida-bot │
│ Cron / Scheduler │
│ │ │
│ ▼ │
│ MCP Client ───────────────┐
│ ▼ │ │ MCP (stdio)
│ QQ Channel │ ▼
└─────────────────────┘ ┌──────────────────┐
│ mihoyo-mcp │
│ QR login │
│ credential vault │
│ daily notes │
│ alert dedup state │
└────────┬──────────┘
│
genshin.py
│
米游社 / HoYoLAB APIRelated MCP server: Xiaohongshu MCP Server
現在の能力
能力 | 状態 |
米游社 QR スキャンログイン(非ブロッキング start/poll) | ✅ genshin.py の Web QR フローを再利用 |
複数アカウント + ゲームキャラクター(uid)の検出 | ✅ |
スターレールのリアルタイム便笺 | ✅ |
原神のリアルタイム便笺 | ✅ |
ゼンレスゾーンゼロのリアルタイム便笺 | ✅ |
スターレールのアラートチェック(複数ポーリング間の重複排除) | ✅ |
HoYoLAB ログイン | ⏳ 未対応(ロードマップ参照) |
ツール一覧
ツール | 説明 |
| QR スキャンログインを作成。 |
| スキャン状態をポーリング: |
| ログイン済みアカウント数、含まれる未完了ログインセッション |
| アカウントとそのゲームキャラクター(uid)を一覧表示。クレデンシャルは一切含まない |
| アカウント配下のゲームキャラクターを再検出 |
| 開拓力(予備含む)、毎日訓練、模擬宇宙、派遣 |
| 樹脂、洞天宝銭、デイリー待命、派遣 |
| バッテリー、活性度、ビデオ店など |
| 「通知する価値のある変化」のみを返す。空リスト=何も通知しない |
account_id はアカウントが1つだけの場合は省略可能です。
命名の経緯 : 設計案の時点では
mihoyo.auth.start_qr_loginのようなドット区切り命名でしたが、MCP 仕様(SEP-986)ではツール名が^[a-zA-Z0-9_-]{1,64}$に一致する必要があり、ドットがあると一部のクライアントが読み込みを拒否します。そのためフラットなスネークケースを採用し、auth_/accounts_/starrail_などのプレフィックスを名前空間代わりにしています。
なぜ check_alerts を MCP に入れているのか
体力閾値判断(217 >= 200 && recovery <= 1800)に LLM トークンを費やす必要はありませんし、「派遣から帰ってきた」という通知を毎回のポーリングで絶えず報告するのは許容できません。アラート重複排除の状態(armed/re-arm)は米游社連携の状態であり、本サービス側に置くのが自然です。クライアント側の cron は次のようにすれば良いだけです。
starrail_check_alerts() → alerts == [] → 静默
→ alerts != [] → 推送消息クイックスタート
uv sync # 安装依赖
uv run pytest # 运行测试
uv run python scripts/smoke_stdio.py # stdio 握手冒烟测试
uv run mihoyo-mcp # 启动 stdio serverクライアント設定例(Claude Desktop / その他 stdio MCP に対応したクライアント):
{
"mcpServers": {
"mihoyo": {
"command": "uv",
"args": ["run", "--directory", "D:/Projects/mihoyo-mcp", "mihoyo-mcp"]
}
}
}設定(環境変数)
変数 | デフォルト | 説明 |
|
| データディレクトリ(アカウント / クレデンシャル / アラート状態) |
| 自動生成 | クレデンシャル暗号化キー。本番ではシークレットストアに入れることを推奨 |
|
|
|
|
| ログレベル(ログは stderr へ出力。stdout は MCP プロトコル用に確保) |
データディレクトリの内容:
~/.mihoyo-mcp/
├── accounts.json # 公开账号元数据(无秘密)
├── credentials.enc # Fernet 加密的 Cookie/token 库
├── alert_state.json # 告警去重状态
└── fernet.key # 未设置环境变量时自动生成的 key(带告警日志)ディレクトリ構成
src/mihoyo_mcp/
├── server.py # MCPServer 装配 + stdio 入口
├── config.py # 环境变量配置
├── context.py # AppContext 单例装配
├── errors.py # 领域错误(映射为 MCP tool error)
├── accounts/ # 账号模型 / 注册表 / 加密凭据库
├── auth/ # 扫码登录(start/poll 会话)
├── games/ # genshin.py 客户端工厂 + 便笺获取/归一化
├── alerts/ # 告警去重状态机(纯逻辑,可测)
└── tools/ # MCP 工具注册(auth / accounts / notes)ログインフロー(米游社)
auth_start_qr_login("miyoforme")を呼び、qr_png_base64(またはlogin_url)から生成した QR コードをユーザーに渡しますユーザーは米游社アプリで QR コードをスキャンし、スマートフォンで確認します
auth_poll_qr_login(session_id)をconfirmedになるまでポーリングしますサービス内部で v2 cookies(
account_id_v2/account_mid_v2/ltoken_v2/cookie_token_v2…)を保存し、ゲームキャラクターを自動検出。以後 Agent が目にするのはmiyoushe:123456のようなaccount_idだけになります
ロードマップ
利用者側(nahida-bot #52 など)の優先度順:
✅ Account / Auth——米游社 QR スキャン、複数アカウント、キャラクター検出
✅ リアルタイムメモ + アラート——スターレイル / 原神 / ゼンレスゾーンゼロのメモ、
check_alerts⏳ HoYoLAB ログイン——メールアドレス + パスワード(genshin.py が対応済み)または海外向け QR スキャン(エンドポイントは要検証)
チェックイン / 引き換えコード(
check_in/codes.list/codes.redeem)プロフィール / キャラクター表示(Enka、パネル照会)
ゲームデータ / ビルド / 育成計算(hakush.in / Yatta / Ambr)
ガチャの取り込みと統計
Renderer(オプションの画像カード生成。ツールは構造化データを返し、レンダリング専用ツールを別途用意)
参考プロジェクトとライセンス
プロジェクト | ライセンス | 本プロジェクトでの役割 |
MIT | 直接依存:API ラッパー、データ構造、cookie、QR ログインフロー | |
GPL-3.0 | アーキテクチャ参考(アカウント / クレデンシャル / 通知)。コードはコピーしない | |
MIT | 中国サーバーでの挙動参考(エラーハンドリング、便笺フィールドの落とし穴) | |
CC BY-NC 4.0 | プロトコルにおける仕様を固め、参照検証にのみ使用(実装の転用はしない) | |
未記載 | 現代の中国サーバーQR スキャンログインの参考 |
このプロジェクトは MIT License を採用しています。
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 Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Discord using personal user tokens instead of bot applications, allowing for seamless message management and server exploration. It provides tools for reading history, sending messages, and searching across channels and DMs directly through MCP-compatible clients.6MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to interact with Xiaohongshu to publish image notes, search content, and manage account details. It uses Playwright to securely handle session authentication and API signatures through the platform's internal network context.2MIT
- FlicenseNot gradedqualityCmaintenanceAn MCP server enabling LLMs to interact with the NodeSeek forum, supporting account status retrieval, daily check-in, post browsing, reading, replying, and posting.4
- AlicenseNot gradedqualityCmaintenanceA MCP server that exposes QQ bot capabilities over Streamable HTTP, enabling clients to query bot status, read group and friend info, fetch chat history, and send group/private text messages.2MIT
Related MCP Connectors
MCP-native open-source Notion alternative: read & write pages, databases and kanban boards.
MCP server for GLM chat completions using Zhipu AI models via AceDataCloud
MCP server for AI dialogue using various LLM models via AceDataCloud
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/AI1379/mihoyo-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server