Token导航 LogoToken导航TokenDH.com
Threlte MCP logo
设计创作stdio官方级别未说明来源级核验

Threlte MCP

MCP Server

threlte-mcp

Threlte MCP是一个基于Model Context Protocol的服务,使AI代理能够实时检查和操作Three.js/Threlte场景。

工具数

30

提示词数

0

GitHub Stars

8

资源数

0
实时交互TypeScriptClaudeAI代理Claude DesktopClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

SerifeusStudio

提供方

SerifeusStudio

最后核验

2026/5/17 20:22

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx threlte-mcp setup

详细介绍

Threlte MCP

](https://www.npmjs.com/package/threlte-mcp) ](https://www.npmjs.com/package/threlte-mcp) ![License: MIT](https://opensource.org/licenses/MIT) ![MCP Compatible](https://modelcontextprotocol.io/) ![Built with Claude](https://claude.ai)

MCP(模型上下文协议)服务器,使AI代理能够实时检查和操纵Three.js/Serlte场景。

✅ 兼容

  • 克劳德桌面版 -Anthropic的桌面应用程序
  • 反重力 -谷歌的人工智能集成开发环境
  • 克劳德代码 -Claude的CLI工具
  • 光标 -AI驱动的代码编辑器
  • 帆板运动 -Codeium的人工智能集成开发环境
  • 继续 -VS代码AI扩展
  • 任何兼容MCP的客户端

请参阅详细的兼容性指南→

特性

  • 🔍 现场检查 -查看完整的3D场景层次结构,按名称/类型查找对象
  • 🎯 对象操纵 -移动、旋转、缩放、显示/隐藏对象
  • 🎨 材料和资产 -应用材料、加载GLTF模型、更改环境
  • 🧪 资产分析 -检查GLTF结构并验证性能
  • dYZ+ 资产优化 -简化网格、压缩纹理、修剪未使用的数据
  • dY”? Svelte出口 -从GLTF生成Threlte/Svelte组件
  • dYZ? 相机预设 -保存、加载和设置摄影机视图的动画
  • 物理控制 -添加物理体,施加脉冲,设置重力
  • 🎭 Vibe预设 -应用情绪预设(舒适、怪异、霓虹灯等)

安装

npm install threlte-mcp

快速开始

1.安装包装

npm install threlte-mcp

2.配置IDE(一次性设置)

npx threlte-mcp setup

此功能会自动检测您的IDE(Antigravity、Cursor、Claude Desktop)并创建MCP配置。

3.将组件添加到您的Threlte应用程序中

MCPBridge组件需要Svelte 5。


  import { MCPBridgeComponent } from 'threlte-mcp/client';

 -->

就是这样! AI现在可以检查和操纵您的场景。

______________________________________________________________________

📋 Manual Configuration (Alternative)

如果 npx threlte-mcp setup 不适用于您的IDE,请手动添加到您的配置中:

{
  "mcpServers": {
    "threlte-mcp": {
      "command": "npx",
      "args": ["-y", "threlte-mcp"]
    }
  }
}

配置文件位置:

  • 反重力: ~/.gemini/antigravity/mcp_config.json
  • 光标: ~/.cursor/mcp.json
  • 克劳德桌面版: ~/Library/Application Support/Claude/claude_desktop_config.json (Mac)

🔧 Advanced: TypeScript API

import { MCPBridge } from 'threlte-mcp/client';
import { useThrelte } from '@threlte/core';

const { scene } = useThrelte();

// Create bridge (auto-connects in dev mode)
const bridge = new MCPBridge(scene, {
  url: 'ws://127.0.0.1:8082',  // default
  autoConnect: true,           // default in dev
  reconnectDelay: 60000,       // 1 minute
});

// In render loop
bridge.update();

// Get scene state
bridge.getSceneState();

// Find objects
bridge.findObjects({ nameContains: 'player' });

选项B:按场景(简单用于原型制作)


  import { onMount, onDestroy } from 'svelte';
  import { useThrelte } from '@threlte/core';

  const { scene } = useThrelte();
  let ws: WebSocket | null = null;
  
  onMount(() => {
    ws = new WebSocket('ws://localhost:8082');
    
    ws.onopen = () => {
      console.log('[MCPBridge] Connected');
      // Send initial scene state
      ws?.send(JSON.stringify({
        type: 'sceneState',
        data: serializeScene(scene)
      }));
    };
    
    ws.onmessage = (event) => {
      const command = JSON.parse(event.data);
      handleCommand(command);
    };
  });
  
  onDestroy(() => {
    ws?.close();
  });
  
  function serializeScene(obj: THREE.Object3D, depth = 0, maxDepth = 3) {
    if (depth > maxDepth) return null;
    return {
      name: obj.name,
      type: obj.type,
      position: obj.position.toArray(),
      rotation: obj.rotation.toArray().slice(0, 3),
      scale: obj.scale.toArray(),
      visible: obj.visible,
      children: obj.children.map(c => serializeScene(c, depth + 1, maxDepth)).filter(Boolean)
    };
  }
  
  function handleCommand(cmd: any) {
    const { action, requestId, ...params } = cmd;
    let result;
    
    switch (action) {
      case 'getFullSceneState':
        result = { data: serializeScene(scene, 0, params.maxDepth || 3) };
        break;
      case 'moveSceneObject':
        const obj = scene.getObjectByName(params.name || params.path);
        if (obj && params.position) {
          obj.position.set(...params.position);
          result = { success: true };
        }
        break;
      // Add more handlers as needed
    }
    
    if (requestId) {
      ws?.send(JSON.stringify({ ...result, requestId }));
    }
  }

3.运行您的应用程序并开始使用MCP工具

一旦MCP服务器和Threlte应用程序都运行,AI代理就可以:

"Get the scene state"
"Find all objects named 'Player'"  
"Move the 'Camera' to position [0, 5, 10]"
"Apply the 'neon' vibe to the scene"

可用工具

现场检查

工具说明
get_scene_state获取完整的场景层次结构
find_objects按名称、类型或用户数据搜索
get_object_position获取特定对象的位置
log_positions导出代码位置

相机

工具说明
set_camera_position设置相机位置、视角和镜头设置
save_camera_preset将当前相机视图另存为预设
load_camera_preset加载已保存的相机视图
list_camera_presets列出所有已保存的摄像头预设
delete_camera_preset删除已保存的相机预设
animate_camera_presets通过一系列预设进行动画制作

层级管理

工具说明
spawn_entity创建基本体(长方体、球体等)
destroy_entity从场景中删除对象
move_object设置对象位置
set_transform设置位置、旋转、比例
set_visibility显示/隐藏对象
rename_entity重命名对象
duplicate_entity克隆对象

物理学

工具说明
make_physical添加物理体
remove_physics移除物理体
apply_impulse用力
set_gravity设置全局重力

资产处理

工具说明
analyze_gltf检查GLTF/GLB结构
validate_asset验证GLTF/GLB是否存在问题
optimize_gltf优化GLTF/GLB资产
export_to_svelte生成Threlte/Svelte组件

材料和资产

工具说明
load_asset加载GLTF/GLB模型
apply_material设置材料
set_environment设置天空盒/环境

大气

工具说明
apply_vibe应用情绪预设
get_bridge_status检查连接状态

配置

WebSocket连接

默认情况下,服务器使用端口8082进行WebSocket通信。

环境变量

MCPBridge在开发模式下自动连接。对于生产,您可以通过环境变量启用它:

# Add to .env file:
VITE_MCP_ENABLED=true

这有助于:

  • 生产构建中的测试
  • 演示环境
  • 调试生产问题

注: 在开发模式下自动启用(npm run dev),无需配置。

发展

# Clone the repo
git clone https://github.com/RaulContreras123/threlte-mcp.git
cd threlte-mcp

# Install dependencies
npm install

# Run in development
npm run dev

# Build for production
npm run build

贡献

欢迎投稿!请随时提交拉取请求。

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add some amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

麻省理工学院© 劳尔 Contreras

链接

______________________________________________________________________

建于 克劳德 🤖

目录标签

目录标签

实时交互TypeScriptClaudeAI代理3D场景操作本地部署AI辅助开发Three.js工具Threlte插件

支持客户端

Claude DesktopClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

threlte-mcp

工具数量(toolCount,工具数)

30

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP