Skip to main content
Glama

emptysock-mcp

Model Context Protocol 服务器,用于 EmptySock 游戏引擎。将引擎系统 — NavMesh、Physics、Scene、Save 和 Actor — 暴露为可由 Claude Desktop、AI 代理和 Claude API 使用的 MCP 工具。


环境要求

  • Node.js 20+

  • npm 9+


Related MCP server: Hayba

安装

git clone https://github.com/eleferrets/emptysock-mcp.git
cd emptysock-mcp
npm install
npm run build

配置

复制示例环境变量文件,并填写你需要的任何值:

cp .env.example .env

变量

必填

描述

EMPTYSOCK_API_TOKEN

用于经过身份验证的引擎 API 调用的 Bearer 令牌。

MCP_AUTH_TOKEN

SSE 传输请求所需的 Bearer 令牌。留空以禁用身份验证。

SAVE_BASE_DIR

存档工具可读写的绝对路径。默认是进程的工作目录。生产环境中请显式设置。

切勿提交 .env — 它已被 gitignore。将密钥存放在 CI/CD 的密钥管理器中,而不是仓库中。


运行服务器

stdio(推荐用于本地使用和 Claude Desktop)

npm run dev          # development — tsx, no build step
# or after building:
node dist/server.js

服务器通过 stdin/stdout 通信。没有网络端口,也没有身份验证暴露面。

Claude Desktop

将服务器添加到你的 Claude Desktop 配置中(在 macOS 上为 ~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "emptysock": {
      "command": "node",
      "args": ["/absolute/path/to/emptysock-mcp/dist/server.js"],
      "env": {
        "SAVE_BASE_DIR": "/absolute/path/to/your/saves"
      }
    }
  }
}

重启 Claude Desktop。EmptySock 工具将出现在工具选择器中。


可用工具

NavMesh

工具

描述

navmesh_find_path

在已加载的导航网格上,计算两个 2D 世界点之间的 A* 路径。返回有序路点;若不存在路径,则返回 []

navmesh_nearest_node

距离给定世界点最近的可行走导航网格节点。

示例 — 查找路径:

{
  "from": { "x": 0, "y": 0 },
  "to":   { "x": 100, "y": 50 },
  "mapId": "level1"
}

Physics

工具

描述

physics_raycast_2d

在 2D 物理空间中发射一条射线;返回第一个命中的实体、命中点和法线。

physics_raycast_3d

在 3D 物理空间(Rapier3D)中发射一条射线;返回第一个命中结果。

physics_overlap_circle

所有 2D 碰撞体与一个圆形相交的实体 ID。

physics_body_state

按实体 ID 获取物理体的当前位置、速度和角速度。

示例 — 圆形重叠:

{
  "center": { "x": 50, "y": 50 },
  "radius": 20,
  "layerMask": 3
}

Scene

工具

描述

scene_list_entities

场景中所有处于活动状态的实体 ID。

scene_entity_info

指定实体的标签、活动状态和组件列表。

scene_get_component

实体上某个组件的序列化状态。

示例 — 获取组件:

{
  "sceneId": "gameplay",
  "entityId": "player-001",
  "componentType": "Transform"
}

Save

所有存档工具均被沙箱限制在 SAVE_BASE_DIR 内。路径穿越(..、绝对路径)会在 schema 层被拒绝,并在解析时再次被拒绝。

工具

描述

save_read

从磁盘读取一个存档槽,并返回其 JSON 数据。

save_write

将一个 JSON 对象写入指定的存档槽。

save_delete

删除一个存档槽。

save_list

列出所有可用的存档槽。

示例 — 写入:

{
  "slot": "autosave",
  "data": { "level": 3, "score": 4200, "checkpoint": "bridge" }
}

存档槽名称仅由字母数字和连字符/下划线组成(例如 slot1autosavenew-game-plus)。


Actor

工具

描述

actor_send_message

将消息排队到指定 actor 的邮箱中。在下次 ActorSystem flush 时处理。

actor_broadcast

向所有已注册的 actor 广播一条消息。

actor_inbox_size

actor 邮箱中待处理消息的数量。

示例 — 发送消息:

{
  "actorId": "enemy-spawner",
  "message": { "type": "SPAWN_WAVE", "payload": { "wave": 3 } }
}

顺序说明: ActorSystem 会在调用 update() 之前清空每个 actor 的邮箱。在第 N 帧期间发送的消息会在第 N 帧的更新逻辑运行之前全部处理完毕。


开发

npm run lint        # TypeScript type-check (no emit)
npm test            # run Vitest suite
npm run test:watch  # watch mode

测试位于 src/tests/。它们涵盖输入验证、工具分发和安全不变量(路径穿越、shell 元字符注入、未知工具名)。


添加工具

  1. 创建 src/tools/<domain>.ts — 导出 toolDef 数组条目和一个 handler 函数。

  2. 通过 buildRegistry() 中的 register() 调用,将两者注册到 src/tools/index.ts

  3. emptysock-engine 中的 api-reference.json 中添加一个条目。

  4. eleferrets/emptysock-ai-skills 添加一个技能文件。

使用 src/lib/ 中共享的辅助工具:

  • parse(schema, raw) — Zod 解析,失败时抛出 McpError(InvalidParams)

  • SafeRelPathSafeIdVec2Vec3GameNum — 可复用的 Zod schema

  • textResponse(data) — 构建标准 MCP 文本内容响应

  • wrapError(err) — 记录到 stderr,并以 McpError(InternalError) 重新抛出


安全模型

关注点

缓解措施

参数格式错误

对每个输入执行 Zod safeParse;失败时返回 McpError(InvalidParams)

路径穿越

在存档处理器中使用 SafeRelPath schema + path.resolve 包含性检查

Shell 注入

不使用带模板字符串的 exec();需要子进程时使用带 argv 数组的 execFile

凭据泄漏

密钥仅来自 process.env;堆栈信息记录到 stderr,绝不上报给客户端

输入过大

每个 schema 字段的字符串长度均设上限

未知工具

McpError(MethodNotFound) — 不会落入非预期的处理器

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLM-driven text game state management by exposing MCP tools for managing players, locations, items, entities, and abstract concepts.
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    An MCP server enabling AI agents to author Unreal Engine 5 scenes directly, with tools for spawning actors, building PCG graphs, validating physics, generating terrain, and more through a single MCP connection.
    13
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Connects Claude Code to the Unity Editor via MCP, enabling AI-driven control of scenes, assets, components, UI, animations, and more through 91 tools.
    2
    -
  • A
    license
    C
    quality
    A
    maintenance
    Enables AI-driven game development by providing MCP tools to interact with the Godot editor, including scene editing, node manipulation, script attachment, and scene execution.
    28
    27
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/eleferrets/emptysock-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server