Logo UnityNaturalMCP

UnityNaturalMCP

Cộng đồng
notargs

UnityNaturalMCP is an MCP server implementation for Unity that aims for a "natural" user experience.

Nhà phát hànhnotargs
Kho mãUnityNaturalMCP
Ngôn ngữC#
Bản fork
17
Sao
163
Công cụ có sẵn
0
Phương thức truyền tảistdio, streamable-http
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    UnityNaturalMCP cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    163 sao và 17 bản fork từ kho mã được liên kết.

UnityNaturalMCP

Stars Forks Ask DeepWiki

Unity .NET C# 9.0 GitHubCopilot ClaudeCode Cursor WSL2

日本語

UnityNaturalMCP is an MCP server implementation for Unity that aims for a "natural" user experience.

MCP tools defined in Unity C# can be used directly from MCP clients such as Claude Code, GitHub Copilot(VSCode) and Cursor.

[!WARNING] UnityNaturalMCP is still in the preview stage. It is usable in practice, but several feature additions are planned.

Features

  • Concise communication flow between Unity Editor and MCP clients
  • stdio/Streamable HTTP support
  • Implementation of extended MCP tool entirely written in C# using MCP C# SDK
  • ClaudeCode, GitHub Copilot(VSCode) and Cursor support

Requirements

  • Unity 6000.0 or later
  • Node.js 18.0.0 or later (if using mcp-stdio-to-streamable-http)

Architecture

or

UnityNaturalMCPServer

An MCP server implementation provided as a Unity Package that behaves as a Streamable HTTP server.

Clients that support Streamable HTTP, such as Github Copilot(VSCode), can communicate directly with Unity Editor through this server.

mcp-stdio-to-streamable-http

mcp-stdio-to-streamable-http

A Node.js-based stdio MCP server that relays communication between MCP clients and Unity.

Some MCP clients, such as Cursor, do not support Streamable HTTP as of June 23, 2025.

By bypassing stdio input to Streamable HTTP, it enables communication between UnityNaturalMCPServer and MCP clients.

UnityNaturalMCPTest

A Unity project for functional verification and as a sample.

MCP Tools

Currently, the following MCP tools are implemented:

  • RefreshAssets: Refresh Unity Editor assets
  • GetCurrentConsoleLogs: Get Unity Console log history
  • ClearConsoleLogs: Clear Unity Console logs
  • RunEditModeTests: Run Edit Mode tests on Unity Test Runner
  • RunPlayModeTests: Run Play Mode tests on Unity Test Runner

Installation

Unity

The following packages are required:

Also, install the following Nuget Packages via NugetForUnity:

[!WARNING] ModelContextProtocol is still in preview stage. When installing via NugetForUnity, you need to enable the Show Prerelease toggle.

You can install via UPM (Unity Package Manager):

  • Edit Packages/manifest.json
  • Add the following to the dependencies section:
    json
    "jp.notargs.unity-natural-mcp": "https://github.com/notargs/UnityNaturalMCP.git?path=/UnityNaturalMCPServer"

Initial Setup

  1. Open Edit > Project Settings > Unity Natural MCP in Unity Editor
  2. Set the MCP server port number (default: 56780)
  3. Click the Refresh button to apply the settings

[!NOTE] 56780 is just the default port. Feel free to change it to suit your project. Note that 67 80 is the ASCII code for CP. Of course, it comes from MCP.

Setting

Claude Code

Use the following command to register an MCP server with ClaudeCode.

shell
claude mcp add -s project --transport http unity-natural-mcp http://localhost:56780/mcp

WSL2

When using MCP with Claude Code on Windows, you need to use WSL2.

To integrate WSL2 with Unity, you need to properly configure the network settings between WSL2 and the host OS.

A simple approach is to use mirror mode to connect WSL2 and the host OS.

To enable mirror mode, add the following settings to C:/Users/[username]/.wslconfig:

ini
[wsl2]
networkingMode=mirrored

In mirror mode, you can communicate between WSL2 and the host OS via localhost.

However, when the C# server binds to localhost, it may not work as expected and connections may fail.

To work around this, set the IP Address to * in Unity's Edit > Project Settings > Unity Natural MCP and execute Refresh.

[!CAUTION] From a security perspective, specifying * for the IP Address is not normally recommended. This is only meant to show a simplified setup procedure. Please adjust accordingly based on your environment.

GitHub Copilot(VSCode)

When using GitHub Copilot(VSCode), connection via Streamable HTTP is possible.

Add the following configuration to .vscode/mcp.json:

json
{
  "servers": {
    "unity-natural-mcp": {
      "url": "http://localhost:56780/mcp"
    }
  }
}

Cursor

Cursor does not support Streamable HTTP as of June 23, 2025. You need to connect via stdio. Please download the latest mcp-stdio-to-streamable-http from mcp-stdio-to-streamable-http Releases.

Clone this repository and add these snippets to .cursor/mcp.json.

Please replace path/to/mcp-stdio-to-streamable-http with the path to the cloned mcp-stdio-to-streamable-http.

json
{
  "mcpServers": {
    "unity-natural-mcp": {
      "command": "node",
      "args": ["path/to/mcp-stdio-to-streamable-http/dist/index.js"],
      "env": {
        "MCP_SERVER_IP": "localhost",
        "MCP_SERVER_PORT": "56780"
      }
    }}
}

Gemini CLI

Streamable HTTP is supported. Create .gemini/settings.json at the root and add the following (if you use a custom port, replace 56780):

json
{
  "mcpServers": {
    "httpServer": {
      "httpUrl": "http://localhost:56780/mcp"
    }
  }
}

For more details, see the Gemini CLI documentation: Gemini CLI documentation: HTTP-based MCP server

Custom MCP Tool Implementation

1. Create MCP Tool

In UnityNaturalMCP, you can implement MCP tools in C# using the MCP C# SDK.

Create an asmdef for the Editor and add the following script files.

csharp
using System.ComponentModel;
using ModelContextProtocol.Server;

[McpServerToolType, Description("Description of custom MCP tool")]
public class MyCustomMCPTool
{
    [McpServerTool, Description("Method description")]
    public string MyMethod()
    {
        return "Hello from Unity!";
    }
}

2. Create MCP Tool Builder

To register MCP tools with the MCP server, create a class that inherits from McpBuilderScriptableObject.

csharp
using Microsoft.Extensions.DependencyInjection;
using UnityEngine;
using UnityNaturalMCP.Editor;

[CreateAssetMenu(fileName = "MyCustomMCPToolBuilder", 
                 menuName = "UnityNaturalMCP/My Custom Tool Builder")]
public class MyCustomMCPToolBuilder : McpBuilderScriptableObject
{
    public override void Build(IMcpServerBuilder builder)
    {
        builder.WithTools<MyCustomMCPTool>();
    }
}

3. Create ScriptableObject

  1. Right-click in the project window in Unity Editor
  2. Create ScriptableObject by Select Create > UnityNaturalMCP > My Custom Tool Builder
  3. From Edit > Project Settings > Unity Natural MCP > Refresh, restart the MCP server to load the created tools.

Best practices for Custom MCP Tools

MCPInspector

From MCP Inspector, you can call MCP tools via Streamable HTTP and perform operational verification smoothly.

MCPInspector

Error Handling

When errors occur within MCP tools, they are not displayed in logs.

It is recommended to use try-catch blocks to log errors and rethrow them.

csharp
[McpServerTool, Description("Example of error-returning process")]
public async void ErrorMethod()
{
  try
  {
      throw new Exception("This is an error example");
  }
  catch (Exception e)
  {
      Debug.LogError(e);
      throw;
  }
}

Asynchonous Processing

When using Unity's API, it is necessary to consider the possibility that it may be called from threads other than the main thread.

Additionally, the return type must use ValueTask<T>.

csharp
[McpServerTool, Description("Example of asynchronous processing")]
public async ValueTask<string> AsyncMethod()
{
    await UniTask.SwitchToMainThread();
    await UniTask.Delay(1000);
    return "Finished async processing";
}

Troubleshooting

Run tests tool fails due to disconnecting

When a domain reload occurs while running tests, the connection with the Unity editor will be disconnected, and the run tests tool will fail.

Note the following:

  • Run tests after the compilation is complete
  • Do not run Edit Mode tests that involve domain reloading
  • When running Play Mode tests, turn off Reload Domain in Edit > Project Settings > Editor > "Enter Play Mode Settings"

License

MIT License

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

{
  "mcpServers": {
    "notargs-unitynaturalmcp": {
      "command": "",
      "args": []
    }
  }
}

Dùng MCP UnityNaturalMCP với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối UnityNaturalMCP, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. Bạn có thể chạy MCP ngay trên thiết bị của mình hoặc kết nối qua URL của máy chủ MCP từ xa.

Cách 1: Dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm UnityNaturalMCP làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của UnityNaturalMCP.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "notargs-unitynaturalmcp": {
      "command": "npx",
      "args": [
        "-y",
        "UnityNaturalMCP"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của UnityNaturalMCP, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của UnityNaturalMCP.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng UnityNaturalMCP giúp tôi làm việc này không?
UnityNaturalMCP
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng UnityNaturalMCP.

Cách 2: Thêm URL máy chủ MCP

Dùng cách này khi UnityNaturalMCP đã được lưu trữ từ xa hoặc nhóm của bạn muốn có một trình kết nối dùng chung cho nhiều người dùng.

1

Mở mục Trình kết nối MCP

Trong TypingMind, vào Plugin, mở mục Trình kết nối MCP, rồi chọn Thêm URL.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Vào mục Plugin.
  3. Mở mục Trình kết nối MCP.
  4. Nhấp vào Thêm URL.
Biểu mẫu Thêm URL máy chủ MCP tùy chỉnh của TypingMind
2

Dán URL máy chủ

Nhập URL máy chủ của bạn vào trường URL máy chủ. Thêm tên kết nối, mô tả, biểu tượng, header HTTP tùy chỉnh hoặc cài đặt ứng dụng khách OAuth nếu máy chủ yêu cầu.

  1. Dán URL máy chủ của bạn vào trường URL máy chủ.
  2. Nhập tên kết nối cho UnityNaturalMCP.
  3. Thêm mô tả và biểu tượng nếu bạn muốn dễ nhận biết kết nối hơn.
  4. Thêm header HTTP tùy chỉnh hoặc thông tin ứng dụng khách OAuth nếu máy chủ yêu cầu xác thực.
3

Tạo kết nối

Nhấp vào Tạo kết nối, sau đó quay lại danh sách Plugin và xác nhận kết nối MCP mới đang hoạt động.

  1. Nhấp vào Tạo kết nối.
  2. Quay lại danh sách trình kết nối MCP.
  3. Xác nhận kết nối UnityNaturalMCP hiển thị trạng thái đang hoạt động.
  4. Làm mới danh sách plugin nếu kết nối chưa xuất hiện ngay.
4

Đổi mô hình mà không cần kết nối lại

Bắt đầu cuộc trò chuyện với mô hình bạn thích, bật các công cụ của UnityNaturalMCP trong mục Plugin và chuyển sang mô hình khác khi cần. Kết nối MCP vẫn sẵn dùng trong không gian làm việc TypingMind.

  1. Bắt đầu cuộc trò chuyện mới trong TypingMind.
  2. Chọn mô hình AI bạn muốn dùng.
  3. Bật các công cụ của UnityNaturalMCP trong mục Plugin.
  4. Yêu cầu mô hình dùng công cụ khi cần.
  5. Chuyển sang mô hình AI khác và dùng lại cùng kết nối MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng UnityNaturalMCP giúp tôi làm việc này không?
UnityNaturalMCP
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng UnityNaturalMCP.

Câu hỏi thường gặp

Máy chủ MCP UnityNaturalMCP dùng để làm gì?

UnityNaturalMCP là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP UnityNaturalMCP với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng UnityNaturalMCP với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP UnityNaturalMCP với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối UnityNaturalMCP, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP UnityNaturalMCP với TypingMind?

Bạn có thể kết nối UnityNaturalMCP trong TypingMind bằng trình kết nối MCP cục bộ hoặc bằng cách thêm URL máy chủ MCP từ xa. Dùng trình kết nối cục bộ khi máy chủ cần truy cập tệp, ứng dụng hoặc tài nguyên riêng trên thiết bị của bạn; dùng URL máy chủ khi máy chủ MCP được lưu trữ từ xa.

MCP UnityNaturalMCP cung cấp những công cụ nào trong TypingMind?

UnityNaturalMCP cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP UnityNaturalMCP không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu UnityNaturalMCP yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇