uMCP 是 MCP 协议的一种服务器实现,旨在与 Unity 中的 AI 进行交互。 它是一个简约且高效的服务器,可用于连接 AI 代理到 Unity 应用程序。
McpServerToolType 和 McpServerTool 属性添加自己的自定义命令和操作。
Assets/NatsunekoLaboratory/ModelContextProtocol/ManagementTools 目录中找到示例。uMCP 可以直接使用流式 HTTP 协议与 MCP 客户端通信,无需其他依赖项。 这使得其实现比依赖于 Python、Node.js 或其他语言运行时的其他 MCP 服务器更高效且轻量级。
您的 MCP 客户端 <-- 流式 HTTP --> uMCP 服务器
openupm add com.natsuneko.modelcontextprotocol.core-framework窗口 > 包管理器。+ 并选择 从 Git URL 添加包...。https://github.com/mika-f/uMCP.git?path=/Assets/NatsunekoLaboratory/ModelContextProtocol/CoreFramework
添加。openupm add com.natsuneko.modelcontextprotocol.management-toolsopenupm add com.natsuneko.modelcontextprotocol.vrchat-world-tools窗口 > 包管理器。+ 并选择 从 Git URL 添加包...。https://github.com/mika-f/uMCP.git?path=/Assets/NatsunekoLaboratory/ModelContextProtocol/MagagementTools
添加。将支持流式 HTTP 的 MCP 客户端(如 VSCode Agent 模式、Cursor、CLINE 等)连接到 MCP 服务器。
http://localhost:7225/sse
# 或
http://localhost:7225/mcp
VSCode Agent 模式的示例:
{
"servers": {
"uMCP": {
"url": "http://localhost:7225/mcp"
}
}
}
您可以通过创建自己的自定义命令和操作来扩展 uMCP。
using System;
using System.ComponentModel;
using NatsunekoLaboratory.ModelContextProtocol.CoreFramework.Attributes;
using NatsunekoLaboratory.ModelContextProtocol.CoreFramework.Models;
using NatsunekoLaboratory.ModelContextProtocol.CoreFramework.Protocol.Abstractions;
using NatsunekoLaboratory.ModelContextProtocol.CoreFramework.Protocol.Interfaces;
namespace NatsunekoLaboratory.Examples.MyCustomCommands
{
[McpServerToolType]
public class MyCustomCommand
{
[McpServerTool]
[Description("这是一个执行某些操作的自定义命令。")]
public static IToolResult Execute([Description("自定义命令的一个示例参数。")] string exampleParameter)
{
// 自定义命令逻辑在此处
return new TextResult($"执行了带有参数的自定义命令:{exampleParameter}");
}
}
}
MIT 许可证,由 @6jz 提供