Skip to main content
Glama

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:

{
  "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/.

Related MCP server: Funplay MCP for Unity

How It Works

  1. Version detection. The server figures out which Unity version to serve:

Priority

Source

Example

1

UNITY_VERSION env var

"2022", "6", "6000.3", or "6000.3.8f1"

2

UNITY_PROJECT_PATH

Reads ProjectSettings/ProjectVersion.txt, maps 2022.3.62f1 to "2022", 6000.3.8f1 to "6000.3"

3

Default

"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

Tool

Purpose

Example

search_unity_api

Find APIs by keyword

"Tilemap SetTile", "async load scene"

get_method_signature

Exact signatures with all overloads

UnityEngine.Physics.Raycast

get_namespace

Resolve using directives

"SceneManager" -> using UnityEngine.SceneManagement;

get_class_reference

Full class reference card

"InputAction" -> all methods/fields/properties

get_deprecation_warnings

Check 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.

Config

Correct

Partial

Wrong

Hallucinated APIs

MCP + targeted Read

24/25

1

0

0

Skilled (Grep+Read)

20/25

3

2

1

Naive (full Reads)

19/25

3

3

1

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.

  • 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.

## 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

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

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

Using pip install:

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

Variable

Purpose

Example

UNITY_VERSION

Unity version to serve

6000.3, 6000.3.8f1, 6, 2023, 2022

UNITY_PROJECT_PATH

Auto-detect version from project

F:/Unity Projects/my-project

UNITY_INSTALL_PATH

Override Unity install path (for ingest only)

D:/Unity/6000.3.8f1

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

# Install with ingest dependencies
pip install unity-api-mcp[ingest]

# Windows
python -m unity_api_mcp.ingest --unity-version 6000.3 --unity-install "D:/Unity/6000.3.8f1" --project "F:/Unity Projects/MyProject"

# macOS
python -m unity_api_mcp.ingest --unity-version 6000.3 --unity-install "/Applications/Unity/Hub/Editor/6000.3.20f1" --project "/path/to/UnityProject"

# Legacy versions
python -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.

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").

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

Problem

Fix

"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 served

Set UNITY_VERSION explicitly. Check stderr: unity-api-mcp: serving Unity <version> API docs

Server won't start

Check 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 results

DOTween, 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.

fuatcankoseoglu@gmail.com

License

MIT

Available Tools

5 tools
get_class_referenceA

Get a complete reference card for a Unity class — all public methods, properties, fields, and events.

Use this when you want to see everything available on a class at a glance.

Args: class_name: Class name with or without namespace. Examples: "Rigidbody", "Tilemap", "InputAction", "SceneManager"

Inputs: class_name (required). Returns: result

get_deprecation_warningsA

Check whether a Unity class, method, or property is deprecated, and find the replacement.

Use this before using any API you suspect might be outdated. Catches common mistakes like using FindObjectOfType (deprecated) instead of FindAnyObjectByType.

Args: name: Class or member name to check. Examples: "WWW", "FindObjectOfType", "GUIText", "UnityEngine.Component.BroadcastMessage"

Inputs: name (required). Returns: result

get_method_signatureA

Look up the exact signature of a Unity API member by fully-qualified name.

Use this when you know the specific API (e.g. from autocomplete or docs reference) and need its exact parameters, return type, and deprecation status.

Args: fqn: Fully-qualified name, e.g. "UnityEngine.Physics.Raycast" or "UnityEngine.SceneManagement.SceneManager.LoadScene" Method overloads include params: "UnityEngine.Physics.Raycast(UnityEngine.Ray)"

Inputs: fqn (required). Returns: result

get_namespaceA

Find the correct namespace and using directive for a Unity class or member.

Use this when you need to know which namespace to import for a Unity type.

Args: name: Class or member name, e.g. "SceneManager", "NavMeshAgent", "Rigidbody"

Inputs: name (required). Returns: result

search_unity_apiA

Search Unity API documentation by keyword.

Use this to find Unity classes, methods, properties, and fields. Returns ranked results with summaries.

Args: query: Search terms (e.g. "Physics Raycast", "SceneManager load", "Transform position") n_results: Max results to return (default 5, max 20) member_type: Optional filter — "type", "method", "property", "field", or "event"

Inputs: query (required), n_results, member_type. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 5 tools

    Disambiguation4/5

    Each tool has a discernible niche: search_unity_api is keyword-based fuzzy lookup, get_class_reference returns a full class card, get_method_signature resolves a precise FQN, get_namespace maps a type to its using directive, and get_deprecation_warnings checks obsolescence. The main overlap is that get_method_signature already surfaces deprecation status and search can return members, but input-shape differences keep boundaries mostly clear.

    Naming Consistency5/5

    All tools follow a predictable verb_noun pattern: get_class_reference, get_deprecation_warnings, get_method_signature, get_namespace, with search_unity_api as the single search verb. The convention is uniform and readable throughout.

    Tool Count5/5

    Five tools is well-scoped for a documentation/API-lookup server. Each tool covers a distinct lookup mode (class card, signature, namespace, deprecation, keyword search) and none feels like filler.

    Completeness4/5

    The surface covers the core reference needs: finding classes/members, exact signatures, namespaces, and deprecation. Minor gaps exist such as inheritance hierarchy or example/usage lookup, but agents can work around these with the existing tools.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      An intelligent MCP server that enables AI agents to crawl, index, and semantically search official framework documentation using local RAG. It prevents hallucinations by providing precise, up-to-date documentation excerpts directly into the AI's context window.
      1
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      This MCP server integrates AI assistants with Unity Editor, allowing them to create scenes, generate scripts, simulate input, and automate workflows using 91 built-in tools.
      287
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that provides tools to fetch live, version-accurate documentation, changelogs, examples, and method signatures for npm and PyPI packages, preventing AI coding agents from hallucinating stale APIs.
      7 npm
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP Server that provides Retrieval-Augmented Generation (RAG) capabilities to surface the latest Unity API documentation (currently v6.x).
      1
      MIT