关于 helldivers2-mcp
helldivers2-mcp 是无状态 MCP 服务,通过社区 API 向大模型提供 Helldivers 2 的实时银河战况数据。工具涵盖战争统计、星球、主要命令、广播、Steam 新闻和太空站信息。
主要功能
- 01查看银河范围的战争统计
- 02读取进行中的 Major Orders
- 03列出星球并查看详情
- 04获取广播和 Steam 新闻
- 05查看太空站详情
适用场景
- 01检查当前战局进展
- 02查看 Major Order 目标
- 03检查星球状态和战斗数据
- 04阅读游戏内广播和新闻
MCP 相关
通过无状态 Streamable HTTP 传输,以工具形式提供来自 api.helldivers2.dev 的 Helldivers 2 实时数据。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://mcp.avengersofsuperearth.com/mcpclaude mcp add --transport http xerno42-helldivers2 https://mcp.avengersofsuperearth.com/mcp{"mcpServers":{"xerno42-helldivers2":{"type":"http","url":"https://mcp.avengersofsuperearth.com/mcp"}}}在 Cursor 中打开{"servers":{"xerno42-helldivers2":{"type":"http","url":"https://mcp.avengersofsuperearth.com/mcp"}}}在 VS Code 中打开{"mcpServers":{"xerno42-helldivers2":{"type":"http","url":"https://mcp.avengersofsuperearth.com/mcp"}}}{"mcpServers":{"xerno42-helldivers2":{"serverUrl":"https://mcp.avengersofsuperearth.com/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
7此工具无需参数。
详细介绍
helldivers2-mcp
一个无状态的模型上下文协议(MCP)服务,可向大模型提供实时的 Helldivers 2 银河战争数据。
数据来自社区 API:api.helldivers2.dev。
软件包
| Registry | Package |
|---|---|
| npm | helldivers2-mcp |
| Docker Hub | xerno42/helldivers2-mcp |
| GitHub Container Registry | ghcr.io/xerno42/helldivers2-mcp |
| MCP Registry | io.github.xerno42/helldivers2-mcp |
工具
| Tool | Description |
|---|---|
get_war_status | 银河范围的战争统计数据(按派系划分的击杀数、胜利/失败的任务数、命中率、死亡数、影响倍率),以及包含所有者、玩家数量、活跃事件、进攻路线和区域生命值的活跃星球 |
get_assignments | 正在进行的主要命令,包含标题、简报、解码后的任务列表(派系、难度、目标星球)、当前进度数据、奖励类型和数量,以及到期剩余时间 |
get_all_planets | 包含 ID、名称和星区的完整星球列表 |
get_planet_details | 单个星球的详细信息:生物群系、危险、初始/当前所有者、生命值、航点、活跃事件、完整战斗统计数据、进攻星球和区域(每次调用最多 5 个星球) |
get_dispatches | 游戏内的通报信息流——高级指挥部广播,包含发布日期(相对时间)和消息文本;可选 limit 参数(默认 20,最大 50) |
get_steam_news | Helldivers 2 的 Steam 新闻,包含标题、URL、发布日期(相对时间)和完整文章内容;可选 limit 参数(默认 10,最大 30) |
get_space_station_details | DSS 详情:当前驻留星球(完整星球信息)、距下一次选举的剩余时间,以及活跃战术行动的名称、描述、状态、星球效果和资源消耗 |
快速开始
前置条件
- Node.js 22+ 或 Docker
- 用于
X-Super-Contact标头的联系邮箱(上游 API 要求)
本地开发
cp .env.example .env # set [email protected]
npm install
npm run dev # hot-reload via tsx watch on :3000
生产构建
npm run build # tsc → dist/
npm run start
Docker
镜像可从 Docker Hub 和 GitHub Container Registry 获取。
docker pull xerno42/helldivers2-mcp # pull from Docker Hub
# or
docker pull ghcr.io/xerno42/helldivers2-mcp # pull from GHCR
# or
docker build -t helldivers2-mcp . # build locally
#then run with:
docker run -p 3000:3000 -e [email protected] helldivers2-mcp
配置
所有配置均通过环境变量进行。
| Variable | Default | Description |
|---|---|---|
X_SUPER_CONTACT | (必填) | 根据上游 API 的使用指南,将其转发为 X-Super-Contact |
PORT | 3000 | 要监听的 HTTP 端口 |
BIND_HOST | 127.0.0.1 | 要绑定的接口(Docker/容器使用 0.0.0.0) |
MCP_ALLOWED_ORIGINS | (未设置) | 允许的浏览器 Origin 标头逗号分隔列表。未设置时会阻止来自浏览器的请求;服务器间调用(无 Origin 标头)始终允许 |
MCP_RATE_LIMIT_PER_MIN | 60 | 持续请求速率限制(每分钟请求数) |
MCP_RATE_LIMIT_BURST | = MCP_RATE_LIMIT_PER_MIN | 令牌桶速率限制器的突发容量 |
端点
| 方法 | 路径 | 描述 |
|---|---|---|
POST | /mcp | MCP Streamable HTTP 传输端点 |
GET | /health | 存活检查 — 返回 { "ok": true } |
服务器使用无状态的 Streamable HTTP 传输。每个 POST /mcp 请求都会创建一对新的 McpServer 和传输实例,处理请求后再将它们销毁。没有会话状态。
在代码中使用
通过 Streamable HTTP 传输直接使用 HTTP 调用 MCP 服务。每个请求都是发送到 POST /mcp 的 JSON-RPC tools/call 消息。
JavaScript / TypeScript
使用官方的 MCP TypeScript SDK:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
const client = new Client({ name: "my-app", version: "1.0.0" });
const transport = new StreamableHTTPClientTransport(
new URL("https://mcp.avengersofsuperearth.com/mcp")
);
await client.connect(transport);
// List available tools
const { tools } = await client.listTools();
console.log(tools.map((t) => t.name));
// Get current war status
const warStatus = await client.callTool({
name: "get_war_status",
arguments: {},
});
console.log(warStatus.content[0].text);
// Get details for specific planets by index (up to 5)
const planets = await client.callTool({
name: "get_planet_details",
arguments: { planetindices: [57, 153] },
});
console.log(planets.content[0].text);
await client.close();
不使用 SDK — 通过 fetch 发送原始 JSON-RPC:
async function callTool(name: string, args: Record<string, unknown> = {}) {
const res = await fetch("https://mcp.avengersofsuperearth.com/mcp", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: { name, arguments: args },
}),
});
const text = await res.text();
// The response is an SSE frame ("event: message\ndata: {json}\n\n");
// concatenate its data line(s) to recover the JSON-RPC payload.
const json = text
.split("\n")
.filter((line) => line.startsWith("data:"))
.map((line) => line.slice(5).trim())
.join("");
const data = JSON.parse(json);
return data.result.content[0].text;
}
const status = await callTool("get_war_status");
const assignments = await callTool("get_assignments");
const dispatches = await callTool("get_dispatches", { limit: 5 });
const planets = await callTool("get_planet_details", { planetindices: [57, 153] });
Python
使用官方的 MCP Python SDK:
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
async with streamablehttp_client("https://mcp.avengersofsuperearth.com/mcp") as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
# List available tools
tools = await session.list_tools()
print([t.name for t in tools.tools])
# Get current war status
result = await session.call_tool("get_war_status", {})
print(result.content[0].text)
# Get details for specific planets by index (up to 5)
result = await session.call_tool(
"get_planet_details",
{"planetindices": [57, 153]},
)
print(result.content[0].text)
asyncio.run(main())
不使用 SDK — 通过 httpx 发送原始 JSON-RPC:
import httpx
MCP_URL = "https://mcp.avengersofsuperearth.com/mcp"
def call_tool(name: str, arguments: dict = {}) -> str:
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {"name": name, "arguments": arguments},
}
headers = {
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream",
}
response = httpx.post(MCP_URL, json=payload, headers=headers)
response.raise_for_status()
import json
# The response is an SSE frame ("event: message\ndata: {json}\n\n");
# concatenate its data line(s) to recover the JSON-RPC payload.
text = "".join(
line[5:].strip()
for line in response.text.splitlines()
if line.startswith("data:")
)
return json.loads(text)["result"]["content"][0]["text"]
status = call_tool("get_war_status")
assignments = call_tool("get_assignments")
planets = call_tool("get_planet_details", {"planetindices": [57, 153]})
连接到 Claude Desktop
托管服务(最简单)
可使用公共实例:https://mcp.avengersofsuperearth.com/mcp。无需设置 — 只需将其添加到 claude_desktop_config.json:
{
"mcpServers": {
"helldivers2": {
"url": "https://mcp.avengersofsuperearth.com/mcp"
}
}
}
自托管(本地二进制文件)
{
"mcpServers": {
"helldivers2": {
"command": "node",
"args": ["/path/to/helldivers2-mcp/dist/index.js"],
"env": {
"X_SUPER_CONTACT": "[email protected]"
}
}
}
}
自托管(HTTP 服务)
{
"mcpServers": {
"helldivers2": {
"url": "http://localhost:3000/mcp"
}
}
}
开发
npm run test # Jest (ESM mode)
npm run test:watch
npm run test:coverage
npm run lint # ESLint
运行单个测试文件:
npm run test src/__tests__/tools.war.test.ts
添加工具
- 创建
src/tools/your-tool.ts,并导出一个包含.definition和.handler的Tool对象。 - 导入它,并将其添加到 src/index.ts 中的
TOOLS数组。 - 成功时返回
textResponse(...),失败时返回errorResponse(...)— 绝不要从处理器中抛出异常。 - 所有上游调用都必须通过
hd2Fetch(内存中的 2 分钟缓存 + 感知速率限制的队列)。
许可证
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。