Skip to main content
Glama

m{ai}geXR-3d-mcp

真正可用的多框架 3D MCP 服务器。 从任何支持 MCP 的 AI(GitHub Copilot、Claude Desktop、Cursor 等)控制实时的 Three.js、A-Frame、Babylon.js 和 React Three Fiber 场景,并配有 世界内异步聊天 功能,这样你就可以在 3D 画布内与 AI 对话,同时让它重塑你周围的世界。

所有 四个 框架客户端都从单一的统一场景状态渲染匹配、视觉对齐的输出。相同的提示词,相同的场景,任何引擎。


亮点

  • 4 个生产就绪的 3D 客户端 — Three.js、A-Frame (1.7.0 + bloom)、Babylon.js (PBR)、React Three Fiber + Zustand — 全部视觉对齐

  • WebXR / VR 支持 — 在所有四个客户端中进入沉浸式 VR;浮动聊天面板跟随你的视线,这样你就可以在头显内与 AI 对话

  • 9 个开箱即用的 AI 提供商 — OpenAI (GPT-5.2)、Anthropic (Claude Sonnet 4.6)、Google Gemini 3.1 Pro、Mistral、Groq (Llama 3.3 70B)、xAI Grok-4、Cohere Command R+、Together.ai 和本地 Ollama

  • 23 个 MCP 工具 — 对象、灯光、摄像机、动画、环境、场景 I/O、撤销/重做、截图和世界内聊天

  • 持久化动画 — 动画在页面重新加载后依然存在;服务器将活动动画存储在场景状态中,并在客户端重新连接时重播它们

  • 并发动画 — 多个属性(位置、旋转、缩放)在所有引擎的同一对象上同时进行动画处理

  • 各框架系统提示词 — 每个客户端都会告诉 AI 如何生成在该引擎中看起来正确的几何体、材质和光照(改编自 iOS maigeXR 应用)

  • 世界内聊天 — 按 ~ 即可与 AI 对话,无需离开 3D 视口;它会读取你的消息并在浮动覆盖层中回答

  • 场景感知 AI — 20 轮对话历史 + 实时场景状态注入,确保 AI 进行增量编辑,而不是破坏性重建

  • 一条命令 — pnpm dev 同时启动服务器 + 所有四个客户端;自动在浏览器中打开 Three.js 客户端

  • 热插拔 AI 提供商 — 从客户端下拉菜单中切换提供商,无需重启


Related MCP server: threejs-devtools-mcp

快速开始

选项 A — npx (无需克隆)

npx maige-3d-mcp

这通过 stdio 启动 MCP 服务器。将你的 MCP 客户端(VS Code Copilot、Claude Desktop、Cursor)指向命令 npx maige-3d-mcp。

选项 B — 从源码安装

1. 安装

cd mcp-webgpu
pnpm install

2. 配置

cp .env.example .env

至少添加一个 API 密钥。所有变量:

变量

默认值

用途

WS_PORT

8083

WebSocket 网桥端口

CHAT_PROVIDER

openai

活动 AI 提供商 (openai

anthropic

google

mistral

groq

xai

cohere

together

ollama)

OPENAI_API_KEY

—

OpenAI

ANTHROPIC_API_KEY

—

Anthropic

GOOGLE_API_KEY

—

Google Gemini

MISTRAL_API_KEY

—

Mistral

GROQ_API_KEY

—

Groq

XAI_API_KEY

—

xAI / Grok

COHERE_API_KEY

—

Cohere

TOGETHER_API_KEY

—

Together.ai

OLLAMA_BASE_URL

http://localhost:11434

本地 Ollama

AUTO_OPEN_BROWSER

true

启动时打开浏览器

DEFAULT_FRAMEWORK

threejs

自动打开哪个客户端 (threejs

aframe

babylonjs

r3f)

每个提供商还有一个 *_MODEL 环境变量(例如 OPENAI_MODEL=gpt-4.1)— 请参阅 .env.example 获取所有可用模型。

两种聊天模式:

  • 中继模式 (无需密钥):MCP 主机 AI (Copilot, Claude Desktop) 通过轮询 getPendingUserMessages 处理世界内聊天。

  • 直接模式 (在 .env 中配置密钥):服务器使用配置的提供商自主回答聊天。

3. 构建并运行

pnpm build:server   # compile TypeScript once
pnpm dev            # start server + all 4 clients

客户端打开地址:

4. 在 VS Code Copilot 中注册

.vscode/mcp.json 已预先配置。重新加载 VS Code,maige-3d-mcp 将出现在 Copilot 代理模式中。

或者,添加到你的全局 VS Code 设置中:

// .vscode/mcp.json (already included)
{
  "servers": {
    "maige-3d-mcp": {
      "type": "stdio",
      "command": "node",
      "args": ["packages/server/build/main.js"],
      "env": {
        "OPENAI_API_KEY": "${env:OPENAI_API_KEY}",
        "ANTHROPIC_API_KEY": "${env:ANTHROPIC_API_KEY}",
        "GOOGLE_API_KEY": "${env:GOOGLE_API_KEY}"
      }
    }
  }
}

支持的 AI 提供商 (9)

提供商

默认模型

可用模型

备注

OpenAI

gpt-5.2

gpt-5.2, gpt-5.2-pro, gpt-4.1, gpt-4.1-mini, gpt-4o, o3, o4-mini

最佳通用选项

Anthropic

claude-sonnet-4-6

claude-opus-4-6, claude-sonnet-4-6, claude-sonnet-4-5, claude-haiku-4-5

强大的推理能力

Google Gemini

gemini-3.1-pro-preview

gemini-3.1-pro-preview, gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite

最新旗舰,多模态

Mistral

mistral-large-latest

mistral-large, mistral-medium, mistral-small, open-mistral-nemo

快速且强大

Groq

llama-3.3-70b-versatile

llama-3.3-70b, deepseek-r1-distill-llama-70b, llama-3.1-8b-instant, mixtral-8x7b

极速推理

xAI / Grok

grok-4-0709

grok-4-0709, grok-4-fast-reasoning, grok-3, grok-3-mini, grok-code-fast-1

最新 Grok 4

Cohere

command-r-plus

command-r-plus, command-r, command, command-light

专注于工具使用

Together.ai

DeepSeek-R1-Distill-Llama-70B-free

DeepSeek-R1-Distill-70B-free, Llama-3.3-70B-free, Llama-3.3-70B, DeepSeek-R1, Qwen2.5-72B

提供免费层级

Ollama

llama3.2

llama3.2, mistral, phi4, gemma3, qwen2.5, deepseek-r1

完全本地,无需 API 密钥

在聊天覆盖层的下拉菜单中切换提供商,或通过更改 .env 中的 CHAT_PROVIDER 进行切换。使用 *_MODEL 环境变量覆盖每个提供商的模型(请参阅 .env.example)。


可用的 MCP 工具 (23)

对象

工具

描述

createObject

添加网格 — 盒子、球体、圆柱体、圆锥体、圆环、平面、胶囊或 glTF 模型

updateObject

部分更新:位置、旋转、缩放、材质(颜色、金属度、粗糙度、自发光)、可见性

deleteObject

按 ID 删除

cloneObject

复制并可选择偏移量

getObject

检查单个对象

getSceneState

完整场景 JSON 快照

灯光

createLight · updateLight · deleteLight — 环境光、平行光、点光源、聚光灯、半球光

摄像机

setCamera · flyToObject

动画

animateObject · stopAnimation — 旋转、弹跳、脉冲、浮动、自旋、自定义关键帧。动画保留在服务器状态中,并在页面重新加载时自动重播。每个对象可同时进行多个属性的动画处理。

环境

setEnvironment — 背景颜色、雾、色调映射、曝光、阴影切换

场景

clearScene · loadScene · exportScene · undo · redo · takeScreenshot

世界内聊天

工具

描述

getPendingUserMessages

获取从 3D 画布内输入的消息

sendChatMessage

在浮动覆盖层中显示 AI 回复

clearPendingMessages

清空队列


MCP 资源

URI

描述

maige-3d://scene/state

所有对象、灯光、摄像机和环境的实时 JSON 快照

maige-3d://server/sessions

当前连接的浏览器会话列表 (ID, 框架, 时间戳)


MCP 提示词

提示词

描述

3d-world-assistant

AI 助手的完整系统上下文 — 场景工具、聊天工作流、增量更新规则、10+ 高级演示配方 (星系、DNA 螺旋、霓虹隧道、水晶簇等)

framework-guide

各框架的几何体/材质/光照提示。接受 framework 参数:threejs, aframe, babylonjs, r3f

demo-showcase

新功能:即时访问 10+ 个令人惊叹的预构建演示模板。非常适合快速制作令人印象深刻的可视化效果。接受 style 参数:galaxy, dna, tunnel, crystals, geometries, wave, spiral, orbit, explosion, all


WebXR / VR 支持

所有四个客户端都通过 WebXR 支持沉浸式 VR。点击 🥽 Enter VR 按钮(左下角)开始会话。

框架

实现

Three.js

自定义 VRSetup.ts — WebXR 会话管理、控制器射线投射器、VRChatPanel.ts 画布纹理聊天面板

A-Frame

原生 vr-mode-ui + laser-controls,带有动态文本的 3D 聊天实体

Babylon.js

WebXRDefaultExperience + DynamicTexture 聊天面板

React Three Fiber

@react-three/xr v6 (createXRStore + <XR> 包装器),React VR 聊天面板组件

在 VR 中,聊天面板浮动在你面前并跟随你的视线。AI 回复实时出现,因此你可以在头显内指挥场景。

需要 支持 WebXR 的浏览器(Chrome 79+、Edge 79+、Meta Quest Browser)以及 VR 头显或用于桌面测试的 WebXR API Emulator 扩展。


世界内聊天

按 ~ (反引号) 或点击右下角的 AI Chat。输入消息,按 Enter,AI 就会收到消息、采取行动并回复 — 所有这些都无需离开 3D 视口。聊天覆盖层还包括:

  • 提供商选择器 — 随时切换 AI 提供商

  • 系统提示词编辑器 — 自定义每个会话的 AI 行为

  • 清空场景 按钮 — 立即重置世界

  • 调试面板 — 按 Escape 检查场景状态和连接信息


架构

┌─────────────────────────┐
│   MCP Host (Copilot,    │  stdio / JSON-RPC
│   Claude, Cursor, etc.) │◄────────────────────┐
└─────────────────────────┘                     │
                                                 │
                              ┌──────────────────┴──────────────────┐
                              │      MCP Server (Node.js)           │
                              │                                      │
                              │  tools/ ─ 23 tool definitions        │
                              │  state/ ─ SceneStateManager + Undo   │
                              │  chat/  ─ ChatRelay (9 providers)    │
                              │  ws/    ─ WebSocket bridge :8083     │
                              │     └── adapters/ (per-framework)    │
                              └──────────┬───────────────────────────┘
                                         │ WebSocket
        ┌────────────────┬───────────────┼───────────────┬────────────────┐
        ▼                ▼               ▼               ▼                │
┌──────────────┐ ┌──────────────┐ ┌───────────────┐ ┌──────────────┐     │
│  Three.js    │ │  A-Frame     │ │  Babylon.js   │ │  R3F / React │     │
│  :5173       │ │  :5174       │ │  :5175        │ │  :5176       │     │
│ ┌──────────┐ │ │ ┌──────────┐ │ │ ┌──────────┐  │ │ ┌──────────┐ │     │
│ │VR/WebXR  │ │ │ │VR/WebXR  │ │ │ │VR/WebXR  │  │ │ │VR/WebXR  │ │     │
│ │ChatPanel │ │ │ │ChatPanel │ │ │ │ChatPanel  │  │ │ │ChatPanel │ │     │
│ └──────────┘ │ │ └──────────┘ │ │ └──────────┘  │ │ └──────────┘ │     │
└──────────────┘ └──────────────┘ └───────────────┘ └──────────────┘

每个客户端通过 WebSocket 连接到同一个 MCP 服务器。服务器维护一个单一的规范场景状态,并通过各框架适配器推送命令,这些适配器将 Vec3 格式、材质模型和几何体名称转换为每个引擎的原生表示。

服务器关键特性:

  • 对话历史 — AI 记住最近 20 轮对话,避免破坏性场景重建

  • 场景状态注入 — 每次 AI 调用都包含当前对象、灯光和环境的摘要,以便 AI 知道已经存在的内容

  • 各框架系统提示词 — 每个客户端告诉 AI 如何生成在该特定引擎中看起来正确的几何体、材质和光照

  • 撤销/重做 — 服务器上有 20 层快照堆栈,通过 MCP 工具触发

  • 动画持久化 — 活动动画存储在场景状态中,并在重新连接时重播,因此循环动画在页面重新加载后依然存在


项目布局

mcp-webgpu/
├── .env.example                   ← all env vars + model lists documented
├── .vscode/mcp.json               ← pre-configured for VS Code Copilot agent mode
├── package.json                   ← pnpm workspace root
├── PLAN.md                        ← full architecture plan
├── packages/
│   ├── server/                    ← MCP server (TypeScript / Node)
│   │   └── src/
│   │       ├── main.ts            ← entry + .env discovery
│   │       ├── types.ts           ← shared types
│   │       ├── tools/             ← 23 MCP tool definitions
│   │       ├── handlers/          ← tool / prompt / resource handlers
│   │       ├── state/             ← SceneStateManager + UndoStack
│   │       ├── chat/              ← ChatRelay (9 providers) + MessageQueue
│   │       └── ws/                ← WebSocket server + framework adapters
│   │           └── adapters/      ← ThreeAdapter, AFrameAdapter,
│   │                                 BabylonAdapter, R3FAdapter
│   ├── client-threejs/            ← Three.js (Vite)
│   │   └── src/
│   │       ├── scene.ts           ← SceneManager
│   │       ├── commands/          ← command dispatcher
│   │       ├── overlay/           ← ChatOverlay UI
│   │       └── vr/               ← VRSetup + VRChatPanel (WebXR)
│   ├── client-aframe/             ← A-Frame 1.7.0 + bloom (Vite)
│   │   └── src/
│   │       ├── scene.ts           ← A-Frame SceneManager
│   │       ├── commands/          ← command dispatcher
│   │       └── overlay/           ← ChatOverlay UI
│   ├── client-babylonjs/          ← Babylon.js + PBR (Vite)
│   │   └── src/
│   │       ├── scene.ts           ← Babylon SceneManager
│   │       ├── commands/          ← command dispatcher
│   │       └── overlay/           ← ChatOverlay UI
│   └── client-r3f/                ← React Three Fiber + Zustand (Vite)
│       └── src/
│           ├── App.tsx            ← React app shell
│           ├── SceneCanvas.tsx    ← R3F canvas + XR wrapper
│           ├── store/             ← Zustand scene store
│           ├── commands/          ← command dispatcher
│           ├── overlay/           ← ChatOverlay UI
│           └── vr/               ← VRChatPanel (React XR component)

路线图

  • [x] 第一阶段 — Three.js 客户端 + 完整工具集 + 世界内聊天

  • [x] 第二阶段 — A-Frame 客户端 (1.7.0, bloom 后期处理) + Babylon.js 客户端 (PBR 材质)

  • [x] 第三阶段 — React Three Fiber 客户端 (Zustand 状态, drei 辅助工具)

  • [x] 第三阶段.5 — 9 个 AI 提供商,各框架系统提示词,所有 4 个引擎的视觉对齐

  • [x] 第四阶段 — WebXR / VR 头显支持 (所有 4 个客户端 + 浮动 VR 聊天面板)

  • [x] 第五阶段 — VS Code MCP 配置,自动打开浏览器,对话历史 + 场景状态感知

  • [x] 第六阶段 — 动画持久化,并发多属性动画,增强的默认光照(环境光 + 半球光 + 带阴影的平行光)


许可证

MIT

Available Tools

33 tools
addBehaviorA

Attach a continuous frame-tick behavior to an object. Behaviors run every frame until removed. Types: spin (rotate continuously), bob (oscillate up/down), orbit (circle around a point), lookAt (always face camera), pulse (rhythmic scale breathing).

Inputs: id (required), objectId (required), type (required), params.

animateObjectA

Animate an object property to a target value. Supports transforms (position, rotation, scale) and material properties (emissiveIntensity, opacity, color) for pulsing glow, fading, color shifts.

Inputs: id (required), property (required), to (required), duration, +2 more.

clearPendingMessagesA

Clear all queued in-world user messages (useful after processing a batch).

Inputs: no named parameters.

clearSceneA

Remove all user-created objects from the scene and reset default lighting.

Inputs: no named parameters.

cloneObjectC

Duplicate an object with an optional position offset.

Inputs: id (required), newId, offset.

createLightC

Add a light to the scene.

Inputs: lightType (required), id, color, intensity, +7 more.

createObjectA

Add a 3D object to the live scene. Returns the assigned id. Always call getSceneState first to understand what already exists.

Inputs: type (required), id, position, rotation, +12 more.

createParticlesA

Create a particle system (stars, dust, sparks, snow, fire embers, laser trails). Uses GPU-efficient point sprites with optional drift animation and twinkle.

Inputs: count (required), spread (required), id, position, +10 more.

deleteLightC

Remove a light from the scene by id.

Inputs: id (required).

deleteObjectC

Remove a 3D object from the scene by id.

Inputs: id (required).

deleteParticlesC

Remove a particle system from the scene.

Inputs: id (required).

executeScriptA

Execute arbitrary JavaScript code in the connected browser scene context. The code runs inside an async function with access to: scene (THREE.Scene), camera, renderer, controls, and a helpers object. Return a value to send it back. Use this for advanced effects the other tools cannot achieve — custom shaders, complex geometry, procedural generation, physics, etc.

Inputs: code (required).

exportSceneA

Export the current scene as a JSON string (can be stored and re-loaded later).

Inputs: no named parameters.

exportStandaloneSceneA

Export the current scene as a standalone HTML file that plays in any browser without a server. Includes all objects, lights, materials, animations, camera, and environment. No chat UI. Saved to the scenes/ folder. Returns the file path.

Inputs: name.

flyToObjectB

Smoothly move the camera to look at an object.

Inputs: id (required), distance, duration.

getObjectC

Get properties of a single scene object by id.

Inputs: id (required).

getPendingUserMessagesA

Return any in-world chat messages the user has typed from inside the 3D environment. Call this at the start of every turn to check for user input from the canvas.

Inputs: no named parameters.

getSceneStateA

Get the full current scene state: all objects, lights, camera, and environment. Call this first before making any changes.

Inputs: no named parameters.

listScenesB

List all saved scene JSON files in the scenes/ folder.

Inputs: no named parameters.

loadSceneB

Replace the entire scene with a previously exported scene JSON.

Inputs: sceneJson (required).

loadSceneFromFileC

Load a previously saved scene from the scenes/ folder by name.

Inputs: name (required).

redoB

Redo a previously undone scene change.

Inputs: no named parameters.

removeBehaviorC

Remove a behavior by its ID, stopping its frame-tick effect.

Inputs: id (required).

saveSceneB

Save the current scene to a JSON file in the scenes/ folder. Returns the file path.

Inputs: name.

sendChatMessageA

Display a message in the in-world chat overlay visible to the user inside the 3D view.

Inputs: message (required), sessionId.

setCameraC

Set the camera position and look-at target.

Inputs: position, target, fov.

setEnvironmentC

Configure the scene environment: background, fog, tone mapping, shadows, and post-processing effects.

Inputs: background, hdriUrl, fog, shadows, +5 more.

stopAnimationC

Stop any running animation on an object.

Inputs: id (required).

takeScreenshotA

Capture the current 3D viewport and return a base-64 PNG data URL. Requires a browser client to be connected.

Inputs: no named parameters.

undoB

Undo the last scene change (up to 20 levels).

Inputs: no named parameters.

updateLightC

Update an existing light by id.

Inputs: id (required), color, intensity, position, +1 more.

updateObjectC

Update any properties of an existing 3D object. Supports partial updates.

Inputs: id (required), position, rotation, scale, +2 more.

updateParticlesC

Update properties of an existing particle system.

Inputs: id (required), position, color, size, +4 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 33 tools

    Disambiguation4/5

    Most tools have distinct purposes with clear boundaries, such as createObject vs. updateObject, or animateObject vs. addBehavior. However, some overlap exists: animateObject and addBehavior both handle object animations, which could cause confusion in selection, though their descriptions clarify animateObject is for property transitions while addBehavior is for continuous frame-tick effects.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern throughout, such as createObject, deleteObject, updateObject, and getSceneState. All tools use camelCase uniformly, with no mixing of naming conventions, making the set predictable and easy to navigate.

    Tool Count3/5

    With 33 tools, the count is borderline high for a 3D scene management server, potentially overwhelming for agents. While the tools cover a comprehensive range of operations, the number may feel heavy compared to typical well-scoped servers, though it aligns with the domain's complexity.

    Completeness5/5

    The tool set provides complete coverage for 3D scene management, including CRUD operations for objects, lights, and particles, scene state management, animation controls, user interaction handling, and advanced features like scripting and export. No obvious gaps exist; agents can perform full lifecycle workflows without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to inspect and modify live Three.js scenes in real time through 59 tools covering objects, materials, shaders, textures, animations, performance monitoring, memory diagnostics, and code generation. Works with vanilla Three.js, React Three Fiber, and any framework without changing your project, using an injected browser bridge and in-page devtools overlay.
      6,808 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to inspect and edit Three.js scenes, materials, shaders, lights, animations, and performance in real time, preview changes live in the browser, capture frames, and turn approved changes into code. It supports vanilla Three.js and React Three Fiber across WebGL/WebGPU without modifying the project.
      6,808 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to inspect and edit live Three.js scenes in the browser — objects, materials, shaders, textures, lights, animation, performance and memory — with 69 tools covering scene trees, screenshots, website audits and video frame capture. Changes can be previewed live with zero project modifications, then converted into ready-to-paste vanilla Three.js or React Three Fiber code.
      6,808 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to inspect, debug and edit Three.js scenes in real time from a live browser, covering objects, materials, shaders, textures, lights, animation, and performance. Live preview changes can be audited, reverted, or turned into ready-to-paste vanilla Three.js and React Three Fiber code without modifying the project.
      6,808 npm
      MIT