Back to MCP directory
publicPublicdnsLocal runtime

CereBro

CereBro.Unity是一个基于CereBro的模型无关AI代理包装器,支持Model Context Protocol(MCP),允许开发者编写可跨AI模型使用的工具。

article

README

🚀 CereBro.Unity

CereBro.Unity 是一个基于 CereBro 的模型无关 AI 代理包装器,专为 Unity 打造。它支持通过 Model Context Protocol 使用不同的 AI 模型。借助官方的 C# SDK(https://github.com/modelcontextprotocol/csharp-sdk),你可以编写工具,且无需更改代码。

🚀 快速开始

CereBro.Unity 能让你在 Unity 中轻松使用不同的 AI 模型,通过简单的配置即可实现 AI 功能的集成。

✨ 主要特性

  • 基于 CereBro,是模型无关的 AI 代理包装器。
  • 支持通过 Model Context Protocol 使用不同的 AI 模型。
  • 可使用官方 C# SDK 编写工具,无需更改代码。

📦 安装指南

Git URL

你可以通过 Git URL 从 Unity 的包管理器安装 CereBro.Unity。具体安装步骤请访问 https://docs.unity3d.com/Manual/upm-ui-giturl.html

在 Unity 项目中,使用以下 Git URL 进行安装:

https://github.com/rob1997/CereBro.git?path=/Packages/com.cerebro.unity

Open UPM

⚠️ 重要提示

目前尚未提供 Open UPM 支持。

💻 使用示例

MCP Server

步骤 1:导入服务器

从菜单栏选择 CereBro > Import Server,这会将 CereBro.Server.Unity 导入到 Unity 项目的根目录中。它作为中介的 MCP 服务器,负责在 Unity 和 AI 模型之间 relay 数据。

步骤 2:配置客户端

你需要将具体的聊天客户端配置为使用 CereBro.Server.Unity。你可以在客户端的配置文件中添加以下内容:

"servers": {
      "cerebro-server-unity": {
        "type": "stdio",
        "command": "dotnet",
        "args": [
          "<Path to Unity Project>/CereBro.Server.Unity/CereBro.Server.Unity.dll",
          "--port",
          "<Port Number>"
        ]
      }
    }

如果你使用的是 CereBro 客户端,可以在 servers.json 文件中添加以下内容:

[
  {
    "Id": "unity-server",
    "Name": "CereBro.Server.Unity",
    "TransportType": "stdio",
    "TransportOptions": {
      "command": "dotnet \"<Path To Unity Project>/CereBro.Server.Unity/CereBro.Server.Unity.dll\"",
      "arguments": "--port <Port Number>"
    }
  }
]

步骤 3:在 Unity 中运行 CereBro

接下来你需要在 Unity 中运行 CereBro。这将创建一个侦听器,用于监听 CereBro.Server.Unity 的请求。

编辑器模式:

[InitializeOnLoad]
public static class CereBroEditorRunner
{
    static CereBroEditorRunner()
    {
        CereBroListener.RunForEditor(5050);
    }
}

运行时模式: 在运行时,你需要调用 CereBroListener.Run(int port = 5000, CancellationToken cancellationToken = default) 方法,该方法将返回一个 Awaitable Task。

现在你可以启动客户端并使用 CereBro 在 Unity 中。

MCP 客户端

⚠️ 重要提示

尚未提供 MCP 客户端相关内容。

基础用法

上述 MCP Server 的步骤 1 - 3 即为基础的使用流程,按照这些步骤配置和运行,即可在 Unity 中使用 CereBro。

高级用法

目前文档未提供高级用法相关内容,可关注项目后续更新。

📚 详细文档

CereBro.Unity 示例

你可以在包管理器中导入 CereBro.Unity 的示例项目。它包含可以直接从 MCP 客户端调用的编辑器工具:

  • CreateShapeTool:在当前场景中创建一个 primitives 形状(例如立方体、球体、圆柱体等)。
  • GetCurrentPositionTool:获取当前场景中 GameObject 的当前位置。
  • MoveGameObjectTool:按照指定的偏移量在 x、y 和 z 方向上移动 GameObject。
  • RePositionTool:将 GameObject 移动到指定的位置。
  • RotateGameObjectTool:按照指定的角度绕 x、y 和 z 轴旋转 GameObject。

🤝 为项目做贡献

如果你希望为该项目做出贡献,可以 fork 仓库并创建 pull request。你也可以在发现任何问题或有任何功能请求时创建 issue。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client