How unity-api-mcp Works
By Fuat Can Köseoğlu,
When you add AI to your Unity workflow, you gain speed. You also gain a new failure mode: confident hallucinations. Wrong method signatures. Deprecated classes used without warning. Missing using directives. The AI is not guessing randomly. It has genuine knowledge of Unity. But Unity's API surface spans tens of thousands of members across dozens of modules, and it moves fast. Training data has a cutoff. The API does not. So I built unity-api-mcp. It is an MCP server that gives AI agents ground-truth Unity 2022 LTS, 2023, and Unity 6 documentation, parsed directly from Unity's own files and served locally via SQLite. The Problem With Existing Approaches When an AI agent needs a Unity API signature, it has a few options. Guess from training data . Fast, zero tokens, wrong when the API has changed or the agent is uncertain. Read raw XML files . Unity ships IntelliSense XML files with every installation. They are accurate. But they are large. Reading one costs thousands of tokens and requires finding the right file first. Web search. Fetches the docs page, which adds network latency and risks returning results for the wrong Unity version. None of these are great. The XML approach is the most accurate, but the cost is too high for routine lookups. Two Data Sources The server ingests documentation once and stores everything in a local SQLite database with FTS5 full-text search. Unity XML IntelliSense files Every Unity installation ships XML summary files at Editor/Data/Managed/. These are the same files that power IntelliSense tooltips in Visual Studio. They contain every public class, method, property, field, and event across all UnityEngine and UnityEditor modules, with parameter names, types, return types, and deprecation flags. The ingestion pipeline parses all 139 XML files and inserts them into SQLite. This is the ground truth for signatures, types, and deprecation status. C# source doc comments (packages) Unity packages like Input System and Addressables do not ship as DLLs. They ship as source code in your project's Library/PackageCache/. The pipeline parses /// XML doc comments directly from .cs files, giving you the same structured data for package APIs. The result is a single SQLite database with 42,223 records covering everything from UnityEngine.Physics to InputAction to Addressables.LoadAssetAsync. Five Tools The server exposes five MCP tools to any connected AI agent. get_namespace resolves using directives. Ask for "SceneManager" and get back using UnityEngine.SceneManagement;. get_method_signature returns exact signatures with all overloads, parameters, and return types. get_class_reference gives you a full class reference card with all methods, properties, and events grouped by type. search_unity_api runs a keyword search across all 42K records. get_deprecation_warnings checks whether an API is obsolete and returns the recommended replacement. Every query runs locally against SQLite. No network request. No Unity installation required at query time. Typical response time is under 15ms. Token Cost in Practice The clearest way to show the value is a direct comparison. get_namespace("SceneManager ") costs about 30 tokens and returns one line. The manual alternative, grepping your project for the using directive or reading the XML, costs 500 to 2,000 tokens across multiple tool calls. get_method_signature("UnityEngine.Tilemaps.Tilemap.SetTile") returns all overloads with full parameter details for around 900 tokens. Without MCP, reading TilemapModule.xml to find the same answer costs roughly 19,500 tokens. The savings compound across a session. Every routine API lookup now costs a fraction of the tokens with a structured, accurate result. Honest Limitations Third-party packages like DOTween, VContainer, and Newtonsoft.Json are not indexed. They do not ship with accessible structured docs in PackageCache. unity-api-mcp is MIT licensed and available on GitHub and PyPI. If you are adding AI to your Unity workflow, give it a try. Codeturion Blog