Borrowing it
Nothing to install: this file belongs to AI1379/mihoyo-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/AI1379/mihoyo-mcp/main/AGENTS.mdgit clone --depth 1 https://github.com/AI1379/mihoyo-mcpWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/ai1379/mihoyo-mcp/agents-md)<a href="https://agentmods.dev/instructions/ai1379/mihoyo-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/ai1379/mihoyo-mcp/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/ai1379/mihoyo-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/ai1379/mihoyo-mcp/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.01763 | $0.01763 |
| Opus 5 | $0.00881 | $0.00881 |
| Sonnet 5 | $0.00353 | $0.00353 |
| Haiku 4.5 | $0.00176 | $0.00176 |
Grade A, and why
mihoyo-mcp AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 104 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
给在本仓库工作的 coding agent 的指令。改代码前先读完本文。
项目是什么
mihoyo-mcp 是一个独立的 MCP Server,统一封装米哈游账号能力,同时面向米游社(国服)
与 HoYoLAB(国际服)。底层 API 封装直接依赖 genshin.py
(MIT,PyPI 包名 genshin),不要自己手写米哈游 endpoint / DS / cookie 处理。
主要消费方是 nahida-bot(通过 MCP client 调用),但服务本身不绑定任何 bot。
不可违反的边界(改设计前先想清楚)
- 凭据永不出服务边界。 Cookie/token 只存在
accounts/vault.py的 Fernet 加密库里, 只交给 genshin.py 客户端。工具结果、日志、异常消息里绝不能出现 cookie 字段值; Agent 能看到的只有account_id(形如miyoushe:123456)和公开的游戏角色信息。 新增任何工具时自查一遍返回结构。 - 本服务不管调度和推送。 "什么时候轮询、问完告诉谁"是客户端(nahida-bot 的 cron/channel)的事。这里只提供"怎么和米哈游说话"。不要往里加定时器、webhook、消息推送。
- stdout 属于 MCP 协议。 任何日志/打印一律走 stderr(
server.py的 logging 配置已处理, 新代码用logging,不要print)。
关键技术决定(有背景,别随手推翻)
- 工具名必须扁平蛇形(
starrail_daily_note,不用starrail.daily_note):MCP 规范 SEP-986 要求工具名匹配^[a-zA-Z0-9_-]{1,64}$,点号会被部分客户端拒绝。用前缀当命名空间。 - mcp SDK 是 2.0:高层 API 是
from mcp.server.mcpserver import MCPServer(装饰器风格)。 老代码里的mcp.server.fastmcp.FastMCP在 2.0 已不存在,抄旧示例代码时注意。 - 米游社扫码登录复用 genshin.py 内部方法
Client._create_qrcode()/_check_qrcode(ticket)(passport-api.miyoushe.com,确认后 Set-Cookie 给 v2 cookies:account_id_v2/account_mid_v2/ltoken_v2/cookie_token_v2)。genshin.py 自带的login_with_qrcode()是阻塞交互式的,所以才在auth/qr.py拆成 start/poll。 - HoYoLAB 登录尚未接入:genshin.py 没有 OS 扫码流程,mihoyo-api-collect 对 OS 扫码 endpoint 标注"未知"。在验证过真实流量之前,不要凭记忆写死 OS 登录 endpoint。
- 告警去重状态属于本服务(
alerts/state.py的 armed/re-arm 机制):目的是让客户端 cron 轮询starrail_check_alerts时空列表可以直接静默,不重复推送也不烧 LLM token。 - 返回结构防御式归一化:米哈游 API 字段会变,
games/notes.py里用 getattr + 默认值, 上游加/删字段不应炸掉工具,未知字段变 None。
分层约定
tools/ 薄封装:解析参数 → 调服务层 → 返回 dict。不写业务逻辑
auth/ games/ alerts/ accounts/ 服务层,可单测
context.py AppContext 单例(settings/registry/vault/sessions/alerts)
新增一个游戏能力的套路:accounts/models.py 的 Game 枚举确认有值 →
games/notes.py 加 fetch + normalize → tools/note_tools.py 注册工具 →
tests/test_server.py 的 EXPECTED_TOOLS 加名字 → 告警类逻辑进 alerts/ 并配纯逻辑测试。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 104 lines · 1,763 tokens per session scan A 0a86ff4351cf
mihoyo-mcp AGENTS.md is an instructions file published in the GitHub repository AI1379/mihoyo-mcp (0 stars, last pushed 15d ago), licensed MIT. It adds 1,763 tokens to every session, about $0.0088 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
next.js AGENTS.md
AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.
deepseek-harness AGENTS.md
AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.