Skip to content

接入你的 client

《夜如何》采用 BYOC(Bring Your Own Client)—— 服务器只提供 MCP tools,你带你的 AI。任何支持 MCP HTTP + Bearer 的 client 都能玩。

前置

  1. 拿到 token:目前内测,邮件 [email protected] 私发。每玩家独立,服务器只留 sha256 摘要,找不回,只能重发。
  2. 确定 endpoint
    • URL:https://1001.ye.games/mcp
    • Auth:Authorization: Bearer <你的 token>
    • Protocol:MCP 2026-07-28(modern envelope);2025-era client 走 stateless fallback

Claude Code

~/.claude/claude.json 或项目 .claude/settings.local.json 加:

json
{
  "mcpServers": {
    "spareme": {
      "type": "http",
      "url": "https://1001.ye.games/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN_HERE"
      }
    }
  }
}

然后 /mcp 列表里应能看到 spareme + 10 个 tool。

推荐:装 Skill 让 AI 更懂游戏(走 agentskills.io 标准,Cursor / Codex CLI / 其他支持 Agent Skills 的 runtime 也适用)。

Cursor

Cursor Settings → MCP → Add new MCP server:

json
{
  "spareme": {
    "url": "https://1001.ye.games/mcp",
    "headers": {
      "Authorization": "Bearer YOUR_TOKEN_HERE"
    }
  }
}

Claude Desktop

配置文件路径:

  • macOS:~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows:%APPDATA%\Claude\claude_desktop_config.json

Claude Desktop 目前不直接支持 HTTP MCP,用 mcp-remote 代理:

json
{
  "mcpServers": {
    "spareme": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://1001.ye.games/mcp",
        "--header",
        "Authorization: Bearer YOUR_TOKEN_HERE"
      ]
    }
  }
}

MCP inspector(调试用)

bash
npx @modelcontextprotocol/inspector

浏览器打开 → connect → https://1001.ye.games/mcp → 加 header Authorization: Bearer YOUR_TOKEN_HERE。用来手工调 tool、看 response schema。

验证接入

get_state(不传参数)应返回:

json
{
  "welcome": "你是舒冉。天亮之前,要向王讲一段故事——若够动人...",
  "how_to_play": "一局=一夜或数夜。每夜分白日与说话两段...",
  "tools_flow": ["start_run —— ...", "..."],
  "next_step": "调 start_run 开启第一局。"
}

看到这份 welcome 就通了。

常见问题

Q: 我 client 提示 401 unauthorized? A: token 错、或没带 Authorization header,或 header 里少写了 Bearer 前缀(含末尾空格)。

Q: 429 或 rate-limited? A: 单 token 每秒 1 req,突发 60。慢一点即可;生产 rate limit 后续会迁 Valkey。

Q: Invalid Host 403? A: 你 client 发的 Host header 不在服务器 allowed 列表里。官方部署1001.ye.games)通常已包含该域名 + 常见 loopback,正常玩不该看到;若真踩官方端点,反馈邮件。自建时须把当前访问域名加入 ALLOWED_HOSTNAMES(逗号分隔),loopback 会自动追加。

Q: 5xx? A: 服务器问题,试几分钟;持续挂请邮件贴 request id。

早期开发阶段 —— 一切规则、工具、Skill 均可能变。