内容
# nexus-mcp
用于 [Nexus Mods](https://www.nexusmods.com) 模组发现、研究和下载的本地 MCP 服务器,由 v2 GraphQL API (`api.nexusmods.com/v2/graphql`) 和网站的 DownloadPopUp 小部件支持。
## 工具列表
| 工具 | 用途 |
|---|---|
| `search_games` | 将游戏标题解析为域名;浏览最多模组游戏 |
| `search_mods` | 按名称、游戏、作者、标签搜索模组,按认可度等排序 |
| `get_mod` | 模组详细信息:描述、需求、标签、统计数据 |
| `get_mod_files` | 模组的下载文件,包含版本和更新日志 |
| `get_download_url` | 获取预签名 CDN 下载 URL(需要 API 密钥或 Cookie) |
| `download_mod` | 将模组文件下载到磁盘(需要 API 密钥或 Cookie) |
| `search_collections` | 搜索精选模组列表 |
| `get_collection` | 收藏元数据 + 完整的模组列表(按 slug,可选修订版) |
| `get_user` | 用户资料 + 他们最认可的模组 |
| `run_graphql` | 出口:任何只读 GraphQL 查询(拒绝突变) |
成人内容始终包含 - 没有过滤开关。
## 设置
```sh
npm install
npm run build
```
在 Claude Code(本地检查)中注册:
```sh
claude mcp add nexus-mods -e NEXUS_MODS_API_KEY=<your key> -- node dist/index.js
```
或通过 npx 直接运行(无需检查 - 仓库是公开的):
```sh
claude mcp add nexus-mods -e NEXUS_MODS_API_KEY=<your key> -- npx github:mbj733/nexus-mcp
```
或在 Claude Desktop 的 `claude_desktop_config.json` 中:
```json
{
"mcpServers": {
"nexus-mods": {
"command": "node",
"args": ["dist/index.js"],
"env": { "NEXUS_MODS_API_KEY": "<your key>" }
}
}
}
```
## 身份验证
三种选项:
### 选项 A:个人 API 密钥
`NEXUS_MODS_API_KEY` — 来自 [nexusmods.com/users/myaccount?tab=api](https://www.nexusmods.com/users/myaccount?tab=api)。
启用 v1 REST 下载 API + 相对查看器的 GraphQL 字段。
### 选项 B:浏览器 Cookie(无需 API 密钥)
运行帮助脚本一次登录:
```sh
node scripts/login.mjs
```
这会启动 Chrome,您登录后,Cookie 将保存到 `~/.nexus-mcp-cookies.json`。
MCP 服务器会自动读取此文件。
### 选项 C:独立 CLI(无需 Claude Code)
`nexus-cli.mjs` 工具完全独立工作:
```sh
node scripts/nexus-cli.mjs login # 一次登录
node scripts/nexus-cli.mjs search skyrim "unofficial patch" # 搜索模组
node scripts/nexus-cli.mjs download skyrim 266 # 下载模组
node scripts/nexus-cli.mjs download baldursgate3 1234 --dir ./mods
```
Cookie 存储在 `~/.nexus-mcp-cookies.json`,过期时自动刷新。
## 开发
```sh
npm run dev # 从源代码运行 via tsx
node scripts/smoke.mjs # 端到端烟雾测试(需要构建)
node scripts/login.mjs # 从 Chrome 提取 Nexus Mods Cookie
node scripts/nexus-cli.mjs login # 独立登录
```
领域术语位于 `CONTEXT.md`。