mihoyo-mcp: Instructions file for Codex

AGENTS.md

mihoyo-mcp AGENTS.md is an instructions file for Codex, OpenCode from AI1379/mihoyo-mcp. It costs 1,763 tokens per session, scanned A, original, MIT.

Project instructions for mihoyo-mcp, a server that lets an AI client use account and game-related services for MiHoYo games in China and internationally.

In plain words
What is it for?
They are for guiding safe changes to the server, its account handling, MCP tools, and communication with MiHoYo services.
Why use it?
They explain the project’s boundaries, including how to protect login credentials and keep scheduling and notifications outside the server.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md.

This is AI1379/mihoyo-mcp's own configuration. It tells Codex and OpenCode how to work on mihoyo-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mihoyo-mcp configures →

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/AI1379/mihoyo-mcp/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/AI1379/mihoyo-mcp

Made for: Codex, OpenCode.

Wrote 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.

agentmods badge for mihoyo-mcp AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/ai1379/mihoyo-mcp/agents-md/github.svg)](https://agentmods.dev/instructions/ai1379/mihoyo-mcp/agents-md)
Your own site
<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.

agentmods 80×15 button for mihoyo-mcp AGENTS.md

Your own site · 80×15
<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>
Per session 1,763 This file is loaded in full into every session.
When invoked 1,763 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 8d ago against content hash 0a86ff4351cf, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

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.

AGENTS.md · 104 lines

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。

不可违反的边界(改设计前先想清楚)

  1. 凭据永不出服务边界。 Cookie/token 只存在 accounts/vault.py 的 Fernet 加密库里, 只交给 genshin.py 客户端。工具结果、日志、异常消息里绝不能出现 cookie 字段值; Agent 能看到的只有 account_id(形如 miyoushe:123456)和公开的游戏角色信息。 新增任何工具时自查一遍返回结构。
  2. 本服务不管调度和推送。 "什么时候轮询、问完告诉谁"是客户端(nahida-bot 的 cron/channel)的事。这里只提供"怎么和米哈游说话"。不要往里加定时器、webhook、消息推送。
  3. 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.pyGame 枚举确认有值 → games/notes.py 加 fetch + normalize → tools/note_tools.py 注册工具 → tests/test_server.pyEXPECTED_TOOLS 加名字 → 告警类逻辑进 alerts/ 并配纯逻辑测试。

Read the full file on GitHub · 104 lines

Changes

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.

  1. 8d ago First seen · 104 lines · 1,763 tokens per session scan A 0a86ff4351cf

Subscribe to this mod's changes

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.

Related

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.

vercel/next.js · 7,296 tokens

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.

openai/codex · 5,153 tokens

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).

microsoft/vscode · 6,785 tokens

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).

microsoft/vscode · 5,001 tokens

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.

langchain-ai/langchain · 4,469 tokens

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.

deepseek-ai/deepseek-harness · 3,737 tokens