Unity API Documentation

io.github.Codeturion由 GitHub 账号 Codeturion 发布v2.1.1更新于 Oct 24, 2026

Accurate Unity API docs (2022/2023/6) for AI agents. Prevents hallucinated signatures.

已验证STDIO仅桌面知识与记忆开发者工具

概览

AI 生成的概览

一个本地 MCP 服务器,为 AI 助手提供 Unity 2022、2023 和 6 的准确 API 文档,用于核对方法签名、命名空间和弃用信息。

可以做什么
按关键词搜索 Unity API,覆盖 UnityEngine、UnityEditor 以及 Input System、Addressables、uGUI/TextMeshPro、AI Navigation、Netcode 等包。获取包含全部重载的精确方法签名,以及列出方法、字段和属性的完整类参考。解析某个类型应使用的 using 指令,并检查 API 是否已弃用及其替代方案。所有结果来自本地按版本区分的 SQLite 数据库查询。
适用场景
适合助手编写或审查 Unity C# 代码时,需要核实确切重载、命名空间或弃用状态,而不是从用法示例中推断。最适合使用 Unity 2022 LTS、2023 或 Unity 6 且依赖内置模块和上述 Unity 包的项目。
运行要求
以 Python 包形式在本地运行(需 Python 3.10 及以上),可通过 uvx 或 pip 安装,无需安装 Unity。需设置 UNITY_VERSION(如 2022、2023、6 或 6000.3 这类版本流),或设置 UNITY_PROJECT_PATH 从 ProjectSettings/ProjectVersion.txt 自动识别;否则默认使用 Unity 6。首次运行需联网,从网络下载约 20-30 MB 的数据库到用户主目录。
安装前请注意
首次运行及启动时会从 GitHub 下载并检查数据库是否为最新,因此需要网络访问,并会在用户主目录下写入文件。它只做只读的文档查询,不会修改 Unity 项目。不收录 DOTween、VContainer、Newtonsoft.Json 等第三方资源,这些库的查询结果不可信。README 建议向项目的助手配置文件追加一段说明,这会改动项目文件。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Unity API Documentation,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

unity-api-mcp

[PyPI Version] [PyPI Downloads] [MCP Registry] [GitHub Stars] [GitHub Last Commit] [Weekly DB Build] [License: MIT] [Python 3.10+]

MCP server that gives AI agents accurate Unity API documentation. Prevents hallucinated signatures, wrong namespaces, and deprecated API usage.

Supports Unity 6 (one database per minor stream), Unity 2023, and Unity 2022 LTS. Works with Claude Code, Cursor, Windsurf, or any MCP-compatible AI tool. No Unity installation required. See the supported versions. New Unity releases are detected and built automatically every week.

Quick Start

Add to your MCP config (.mcp.json, mcp.json, or your tool's MCP settings), setting UNITY_VERSION to match your project:

json
{  "mcpServers": {    "unity-api": {      "command": "uvx",      "args": ["unity-api-mcp"],      "env": {        "UNITY_VERSION": "6000.3"      }    }  }}

Valid values: a Unity 6 stream like "6000.3", or "6", "2023", "2022".

On first run the server downloads the correct database (~20-30 MB) to ~/.unity-api-mcp/.

How It Works

  1. Version detection. The server figures out which Unity version to serve:
PrioritySourceExample
1UNITY_VERSION env var"2022", "6", "6000.3", or "6000.3.8f1"
2UNITY_PROJECT_PATHReads ProjectSettings/ProjectVersion.txt, maps 2022.3.62f1 to "2022", 6000.3.8f1 to "6000.3"
3Default"6"
  1. Database download. If the database for that version isn't cached locally, it downloads from GitHub. Unity 6 minor streams (6000.0, 6000.3, 6000.5, …) get their own per-stream database, falling back to the generic 6 database when a stream database isn't published. Cached databases are freshness-checked against the release on startup, so weekly rebuilds reach existing installs automatically.

  2. Serve. All tool calls query the version-specific SQLite database. Every query returns in <15ms.

Each version has its own database with the correct signatures, deprecation warnings, and member lists for that release.

Tools

ToolPurposeExample
search_unity_apiFind APIs by keyword"Tilemap SetTile", "async load scene"
get_method_signatureExact signatures with all overloadsUnityEngine.Physics.Raycast
get_namespaceResolve using directives"SceneManager" -> using UnityEngine.SceneManagement;
get_class_referenceFull class reference card"InputAction" -> all methods/fields/properties
get_deprecation_warningsCheck if an API is obsolete"WWW" -> Use UnityWebRequest instead

Coverage

All UnityEngine and UnityEditor modules, plus packages parsed from C# source: Input System, Addressables, uGUI (incl. TextMeshPro on Unity 6), AI Navigation, and Netcode. ~42,500 records per Unity 6 database, ~500 deprecation warnings each.

Full version list: db-v1 release page. CI regenerates that table on every build. New Unity patches are detected and built automatically every Monday.

Does not cover third-party assets (DOTween, VContainer, Newtonsoft.Json). For those, rely on project source.

Benchmarks

Measured, not promised: 25 research questions across 3 testbeds, answered by 3 agent configs, every answer judged against ground truth verified in the source beforehand. The full harness lives in docs/benchmark/ and re-runs with one command.

[Answer quality by agent config, judged against verified ground truth]
ConfigCorrectPartialWrongHallucinated APIs
MCP + targeted Read24/25100
Skilled (Grep+Read)20/25321
Naive (full Reads)19/25331

The one reproduced hallucination is instructive. Asked to list the overloads of SceneManager.LoadSceneAsync, both non-MCP agents invented single-parameter LoadSceneAsync(string) and LoadSceneAsync(int) overloads that do not exist. Code written against them does not compile. The MCP agent returned the exact four real overloads.

Why correctness and not token savings? Agentic tools are good at code search now. Claude Code has shipped a Grep tool from the start, and current models search first and then read a narrow line range, so raw token use was comparable across all configs in our runs. But exact overloads, namespaces, and deprecations are not in your project files at all. An agent without MCP can only infer them from usage examples, and when it infers wrong you pay with a broken build.

Methodology
  • 3 testbeds: a real Unity 6 game project (11 questions), pure Unity API lookups (8), and Unity Input System package source with 2,700 to 4,600 line files (6)
  • 3 configs, same model and turn limit: MCP tools + Grep/Read, Grep/Read only, Read only
  • Ground truth verified by reading the source before any runs; answers judged by a separate model session against that ground truth; token usage taken from API usage fields
  • Run it yourself: python docs/benchmark/run.py --project <unity-project-path> (results from July 2026; agent behavior moves, so re-run before quoting)

CLAUDE.md Snippet

Add this to your project's CLAUDE.md (or equivalent instructions file). This step is important. Without it, the AI has the tools but won't know when to reach for them.

markdown
## Unity API Lookup (unity-api MCP)
Use the `unity-api` MCP tools to verify Unity API usage instead of guessing. **Do not hallucinate signatures.**
| When | Tool | Example ||------|------|---------|| Unsure about a method's parameters or return type | `get_method_signature` | `get_method_signature("UnityEngine.Tilemaps.Tilemap.SetTile")` || Need the `using` directive for a type | `get_namespace` | `get_namespace("SceneManager")` || Want to see all members on a class | `get_class_reference` | `get_class_reference("InputAction")` || Searching for an API by keyword | `search_unity_api` | `search_unity_api("async load scene")` || Checking if an API is deprecated | `get_deprecation_warnings` | `get_deprecation_warnings("FindObjectOfType")` |
**Rules:**- Before writing a Unity API call you haven't used in this conversation, verify the signature with `get_method_signature`- Before adding a `using` directive, verify with `get_namespace` if unsure- Covers: all UnityEngine/UnityEditor modules, Input System, Addressables, uGUI/TextMeshPro, AI Navigation, Netcode- Does NOT cover: DOTween, VContainer, Newtonsoft.Json (third-party)

Setup Details

Auto-detect version from project path

Instead of setting UNITY_VERSION, you can point to your Unity project. The server reads ProjectSettings/ProjectVersion.txt automatically:

json
{  "mcpServers": {    "unity-api": {      "command": "uvx",      "args": ["unity-api-mcp"],      "env": {        "UNITY_PROJECT_PATH": "/path/to/your/unity-project"      }    }  }}
Alternative installation methods

Using pip install:

bash
pip install unity-api-mcp
json
{  "mcpServers": {    "unity-api": {      "command": "unity-api-mcp",      "args": [],      "env": {        "UNITY_VERSION": "6000.3"      }    }  }}
Environment variables
VariablePurposeExample
UNITY_VERSIONUnity version to serve6000.3, 6000.3.8f1, 6, 2023, 2022
UNITY_PROJECT_PATHAuto-detect version from projectF:/Unity Projects/my-project
UNITY_INSTALL_PATHOverride Unity install path (for ingest only)D:/Unity/6000.3.8f1
Building databases locally

If you want to build a database from your own Unity installation instead of downloading:

bash
# Install with ingest dependenciespip install unity-api-mcp[ingest]
# Windowspython -m unity_api_mcp.ingest --unity-version 6000.3 --unity-install "D:/Unity/6000.3.8f1" --project "F:/Unity Projects/MyProject"
# macOSpython -m unity_api_mcp.ingest --unity-version 6000.3 --unity-install "/Applications/Unity/Hub/Editor/6000.3.20f1" --project "/path/to/UnityProject"
# Legacy versionspython -m unity_api_mcp.ingest --unity-version 2022 --unity-install "D:/Unity/2022.3.62f1"

Databases are written to ~/.unity-api-mcp/unity_docs_{version}.db by default.

AI-Assisted Setup

If an AI agent is setting this up for you:

Add unity-api-mcp to my MCP config using uvx with UNITY_VERSION set to match my project, append the CLAUDE.md snippet from the README, and verify with get_namespace("SceneManager").

Project structure
unity-api-mcp/├── src/unity_api_mcp/│   ├── server.py          # MCP server (5 tools)│   ├── db.py              # SQLite + FTS5 database layer│   ├── version.py         # Version detection + DB download│   ├── xml_parser.py      # Parse Unity XML IntelliSense files│   ├── cs_doc_parser.py   # Parse C# doc comments from package source│   ├── unity_paths.py     # Locate Unity install + package dirs│   └── ingest.py          # CLI ingestion pipeline└── pyproject.toml

Databases are stored in ~/.unity-api-mcp/ (downloaded on first run).

Troubleshooting

ProblemFix
"Could not download Unity X database"Check internet connection. Or build locally: python -m unity_api_mcp.ingest --unity-version 2022
Wrong API version being servedSet UNITY_VERSION explicitly. Check stderr: unity-api-mcp: serving Unity <version> API docs
Server won't startCheck python --version (needs 3.10+). Check path: which unity-api-mcp or where unity-api-mcp
ModuleNotFoundError: No module named 'mcp.server.fastmcp'Version 2.1.0 or older installed mcp 2.x. Restart your MCP client, or run uvx unity-api-mcp@latest. With pip, run pip install -U unity-api-mcp.
Third-party packages return no resultsDOTween, VContainer, Newtonsoft.Json are not indexed (third-party, not Unity packages)

See Also

unreal-api-mcp: same concept for Unreal Engine (C++), with weekly auto-built databases per UE version.

Contact

Need a custom MCP server for your engine or framework? I build MCP tools that cut token waste and prevent hallucinations for AI-assisted game development. If you want something similar for your team's stack, reach out.

[email protected]

License

MIT

来源:README.md,提交 3f65d1d

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v2.1.1最新Oct 12, 2026
  2. v2.1.0Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分