by firekula
Provides a modern runtime node inspection and AI bridge panel for Cocos Creator 2.4.x, enabling dual‑pane debugging, property editing, drawcall analysis, memory profiling, screen picking, and automatic bridging to large language model clients.
MCP Inspector Bridge delivers a Vue 3 + Electron based debugging panel specially crafted for Cocos Creator 2.4.x. It injects a non‑intrusive probe into the running game, captures the full node hierarchy, and exposes a rich set of tools—node tree search, two‑way property editing, draw‑call diagnostics, memory analysis, screen picking, performance overlay, and a multi‑instance MCP server that bridges the engine to AI clients such as Claude, Cursor, and 20+ other large‑model interfaces.
# Global plugin location
~/.CocosCreator/packages/mcp-inspector-bridge/
# Or project‑specific location
your‑project/packages/mcp-inspector-bridge/
esbuild for the probe):
npm install
npm run build
window.__MCP_DEBUG__ = true.Q: Which Cocos Creator versions are supported? A: Cocos Creator 2.4.x, including custom builds that have been upgraded to Electron 14+.
Q: Do I need to rebuild the probe after modifying game code? A: No. The probe is injected at runtime; changes to game scripts are reflected automatically when you restart the preview.
Q: What if port 4456 is already in use?
A: The server includes an EADDRINUSE detection routine that increments the port number until a free one is found.
Q: Can I disable the AI bridge? A: Yes. In the Settings tab, turn off “AI Bridge” to stop listening for external LLM clients.
Q: How is logging handled?
A: Log capture uses CDP Runtime.consoleAPICalled when available; otherwise it falls back to script injection. Logs are silenced by default and can be enabled with window.__MCP_DEBUG__ = true.
Q: Is there support for Windows/macOS/Linux? A: The plugin runs inside Cocos Creator, which itself is cross‑platform. Video export to MP4 requires FFmpeg on the host OS.
Q: Where are my preferences saved?
A: Settings such as custom resolutions, panel widths, and overlay toggles are persisted under the project’s settings/ directory via Editor.Profile.
专为 Cocos Creator 2.4.x 打造的现代化运行时节点审查与 DevTools 桥接插件。
基于 Vue 3 + Electron BrowserView 架构,提供双分栏沉浸式调试体验:左侧游戏预览、右侧节点树/属性检查/DevTools/性能分析,彻底解决原版内嵌 Chromium DevTools 的挂起死锁问题。
将本项目克隆或复制到 Cocos Creator 的插件目录中:
# 全局插件目录
~/.CocosCreator/packages/mcp-inspector-bridge/
# 或项目级插件目录
your-project/packages/mcp-inspector-bridge/
# 安装依赖(包含 esbuild)
npm install
# 编译 TypeScript + 打包探针模块与 MCP 客户端
npm run build
采用 Vue 3 构建主面板,左侧 Webview 渲染游戏视口,右侧集成多功能调试标签页,实现"边玩边审"的沉浸式体验。
基于预加载脚本 (preload.ts) 无侵入注入探针至游戏运行时,实时截获完整节点树结构。
Animation 定位所有挂载该组件的节点)为 LLM (大模型如 Claude/Cursor) 提供双端通信与跨进程的游戏引擎交互视界。
EADDRINUSE 冲突递增机制,支持同时开启多个编辑器实例,实现不同项目端口的自动隔离(默认 4456)。projectName 与 projectPath,允许 AI 快速识别目标平行宇宙。get_active_instances 扫描活跃端口、set_active_instance 绑定指定项目端口、以及 refresh_preview 主动刷新游戏预览窗口。Runtime.consoleAPICalled 零注入被动监听(非侵入式,完美保留 DevTools 源归属);针对 BrowserView 采用原生 console-message 事件。双重防御配合每秒后台激进式探测定时器,在游戏初始化第一帧即接管日志,彻底杜绝早期生命周期错误丢失。CDP 不可用时自动降级至注入方案。遵循现代化卡片化 UI 设计规范 (Modern Card-based UI),选中节点后实时展示结构清晰、分栏合理的组件属性库:
number / string / boolean 以及现代化多行下潜渲染的 array、Anchor、Color、Opacity、Group 等全景属性双向实时更新;string 属性支持多行文本编辑 (textarea 替代 input,Enter 键插入换行);并且内置 0.5 秒高频属性轮询挂载鼠标与焦点双重意图拦截保护,在节点产生自动动画、物理位移时实现完美的数据追平,而在用户试图编辑时自动停止刷新以防光标跳跃。enabled,一键休眠/唤醒指定组件Sprite.type) 以及业务测自定义枚举列表,拒绝盲填查字典的痛苦按 Bundle 分域聚合的资源内存排行榜:
db://assets/textures/... 可读路径运行时 DrawCall 合批断流诊断:
在游戏预览区左上角渲染半透明 Vue 性能数据面板,彻底解决引擎内置 cc.debug.setDisplayStats() 在高分辨率/移动端预览下完全无法辨认的问题:
在偏好设置面板(⚙️ 设置标签页)中管理全局自定义分辨率预设,出现在预览窗口下拉菜单的「自定义」分组中:
自定义分辨率(W×H))与宽高Editor.Profile 全局存储,一次配置多项目共享在游戏预览区右上角提供半透明截图按钮(📷),与 FPS 叠加框风格一致,一键截取当前游戏画面。
webContents.capturePage() 精确捕获游戏渲染输出,不受 WebGL preserveDrawingBuffer 限制,无黑屏问题。cc.view.getDesignResolutionSize(),预留精确缩放能力。在截图按钮下方提供半透明录屏按钮(📹),支持一键录像并弹出系统保存文件对话框,并在“⚙️ 设置”面板提供专属配置。
AudioNode.prototype.connect。当发声源连接到扬声器时,自动静默双路连接至录制目标,实现音视频轨道在流级的纳秒级完美对齐。.webm 或 .mp4 格式。保存 MP4 时优先检测插件根目录下 <插件根目录>/bin/win32/ffmpeg.exe(或其他系统环境变量中的 FFmpeg),智能使用 H.264 (libx264) 或内置 MPEG-4 编码器执行转码。若未检测到 FFmpeg,则自动弹窗警告并安全回退保存为已修复进度条的 .webm 格式。zoom 滚动条塌缩崩溃。分辨率、FPS 叠加框开关、静音状态、面板宽度等设置自动保存至项目级 settings/ 目录,重启即恢复。
默认静默所有探针日志,控制台 100% 留给游戏业务。需要排障时设置 window.__MCP_DEBUG__ = true 即可开启底层追踪。
| 机制 | 说明 |
|---|---|
| 场景校验沙盒 | 以 IPC isEditorSceneActive 为唯一放行条件,未就绪时完全不访问预览服务器,根治 stashScene 崩溃 |
| 后台挂起复原 | ResizeObserver + pendingRefresh 标记,后台切回自动恢复画面 |
| 多实例端口适配 | 核心桥接器端口自动冲突探测并向上扫描,多开项目实例互不串台 |
| IPC 降级容错 | 原生通道失联时自动切入 DOM 轮询,2 秒后静默警告 |
| 单向数据流 | 严格杜绝面板↔探针的 IPC 递归循环 |
| Scene 节点只读 | 自动拦截 cc.Scene 属性访问,防止引擎报错 |
| Electron 跨代容灾 | 针对移除了 remote 模块的高版本引警环境 (Electron 14+) 实施智能垫片防空回退,防止面板因强制解构陷入瘫痪白屏 |
| IPC 克隆防御隔离 | 将对象结构化克隆(structuredClone)降级为跨沙盒的安全 JSON 序列化,杜绝探针在上传不可克隆引用(如原型函数/DOM)时导致整条通信链挂起崩溃 |
mcp-inspector-bridge/
├── package.json # 插件清单与脚本定义
├── main.js # Cocos 插件主进程入口
├── dist/ # 编译产物目录
├── src/
│ ├── main.ts # 主进程逻辑 (IPC 注册、 BrowserView 管理)
│ ├── preload.ts # Webview 预加载脚本 (IPC 桥接 + 探针注入)
│ ├── scene-script.ts # 编辑器 Scene 进程脚本 (仅用于少量原生操作)
│ ├── ipc-router.ts # 分发 IPC 与 WebContents 异步交互路由
│ ├── cdp-log-listener.ts # CDP 日志监听器 (BrowserView 原生事件 / Webview CDP debugger / 注入降级)
│ ├── panel/
│ │ ├── index.ts # 面板入口,Vue 3 应用挂载
│ │ ├── index.html # 面板 HTML 模板与样式
│ │ ├── store.ts # 全局响应式状态
│ │ ├── composables/ # Vue Composable 模块
│ │ │ ├── useLayout.ts # 分辨率/布局/拖拽
│ │ │ ├── useGameView.ts # 游戏视图生命周期
│ │ │ ├── useDevTools.ts # DevTools BrowserView 管理
│ │ │ ├── useNodeSystem.ts # 节点选择/属性系统
│ │ │ ├── useProfiler.ts # 性能数据采集
│ │ │ └── useTabs.ts # 标签页排序
│ │ └── components/ # Vue 组件
│ │ ├── NodeTree.ts # 节点树组件
│ │ ├── NodeInspector.ts # 属性检查器
│ │ ├── RenderDebugger.ts # 渲染调试器
│ │ └── WidgetVisualizer.ts # Widget 可视化
│ ├── mcp-client/ # MCP 原生客户端与服务层
│ │ ├── index.ts # MCP Stdio 服务器入口,处理多实例扫描与路由切换
│ │ ├── tools.ts # MCP 工具集定义 (ping, get_active_instances, etc.)
│ │ ├── resources.ts # MCP 资源订阅定义 (scene://hierarchy)
│ │ ├── prompts.ts # MCP 提示词下发策略
│ │ └── configurator.ts # 22+ 款主流 AI 客户端配置自动注入器
│ └── probe/ # 探针模块 (esbuild → dist/probe.js)
│ ├── index.ts # 探针主入口与生命周期
│ ├── crawler.ts # 节点树爬虫
│ ├── highlighter.ts # 高亮渲染层
│ ├── picker.ts # 屏幕拾取器
│ ├── profiler.ts # 帧率/耗时采集
│ ├── memory.ts # 内存资源扫描
│ ├── render-debugger.ts # 渲染管线劫持
│ └── logger.ts # 调试日志门控
├── memory/ # 项目章程文档
└── specs/ # 功能规范文档
tsc (主面板) + esbuild (探针模块 IIFE 打包)npm run watch 可同时启动 tsc 和 esbuild 的文件监听window.__MCP_DEBUG__ = true 开启探针详细日志Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.