Unity Context Slicer
Provides tools for parsing C# scripts, Unity scenes, prefabs, and .meta files into a knowledge graph, enabling context slicing and compression for LLM-assisted Unity development.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Unity Context SlicerShow class details for PlayerController"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Unity Context Slicer
Unity Context Slicer is a graph-based context extraction engine and Model Context Protocol (MCP) server designed for Unity projects. It parses C# scripts, Unity scenes (.unity), prefabs (.prefab), and .meta asset GUIDs into an in-memory knowledge graph. By slicing targeted $N$-hop neighborhoods around relevant components and compressing raw YAML/AST structures, it delivers 5β10Γ token reduction, producing compact context bundles optimized for local and cloud LLMs.
β‘ Quick Start (Zero Install)
Run the server directly without installing Python dependencies using uvx:
uvx unity-context-slicer --project-dir "path/to/YourUnityProject"Or install via pip:
pip install unity-context-slicer
unity-context-slicer --project-dir "path/to/YourUnityProject"π Key Features
πΈοΈ Graph-Based Project Indexing: Maps C# classes, methods, events, Unity GameObjects, MonoBehaviours, scenes, and prefabs into a unified directed graph.
β‘ 5β10Γ Context Compression: Converts verbose scene YAML and code structures into dense, high-information text representations suited for restricted LLM context windows (e.g., 7B local models).
π― Focused Slicing: Extracts $N$-hop relational neighborhoods (
unity_slice) or comprehensive class context cards (unity_class) including method callers, attached scene objects, and inheritance hierarchies.π Auto-Reloading Resident Session: Monitors file modification times (
mtime) across.cs,.unity, and.prefabfiles to update the resident graph in milliseconds upon code changes.π Built-in MCP Server: Exposes stdio-based MCP tools for direct integration with MCP clients such as Cursor, Windsurf, Claude Desktop, VS Code (Cline / Roo Code), and custom AI agents.
π Unity GUID Resolution: Resolves
.metafile GUIDs to bridge C# MonoBehaviours with serialized scene/prefab component references.
π οΈ Architecture & Pipeline
graph TD
A["Unity Project Directory"] --> B["C# Roslyn Scanner / YAML Parser"]
A --> C["Meta GUID Resolver"]
B --> D["Loader & In-Memory Graph"]
C --> D
D --> E["Session Manager"]
E --> F["Graph Slicer"]
F --> G["Compressor & Task Bundler"]
G --> H["MCP Server & Prompt Bundles"]Pipeline Steps
Parsing & Resolution: C# AST analysis via Roslyn (ScannerCore.cs) combined with Python-native Unity scene/prefab parsing (unity_parser.py) and GUID resolution (meta_resolver.py).
Graph Construction: Builds a unified node/edge model in ProjectGraph indexed for bidirectional lookup.
Neighborhood Slicing: SubGraph algorithms isolate relevant subgraphs based on class, method, or GameObject seeds.
Dense Compression: Renders subgraphs into task-ready prompt context via compressor.py.
π MCP Tools Provided
Tool Name | Description |
| Search for project graph nodes by name substring and optional node type ( |
| Retrieve structured class context (methods, callers, attached GameObjects/scenes, inheritance). |
| Extract an $N$-hop neighborhood graph surrounding a target seed node. |
| Generate a full LLM coding prompt context bundle combining task requirements, graph context, and constraints. |
| View graph node and edge count statistics. |
| Force-reload the project graph from disk. |
π€ Integration Guide for Popular Coding Agents
1. Cursor
Navigate to Cursor Settings $\rightarrow$ Features $\rightarrow$ MCP Servers and click + Add New MCP Server:
Name:
unity-context-slicerType:
commandCommand:
uvx unity-context-slicer --project-dir "${workspaceFolder}"
2. Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"unity-context-slicer": {
"command": "uvx",
"args": [
"unity-context-slicer",
"--project-dir",
"C:/Path/To/Your/UnityProject"
]
}
}
}3. Windsurf (Codeium)
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"unity-context-slicer": {
"command": "uvx",
"args": [
"unity-context-slicer",
"--project-dir",
"${workspaceFolder}"
]
}
}
}4. VS Code Extensions (Cline / Roo Code / Continue.dev)
Add to your extension's MCP server configuration JSON:
{
"mcpServers": {
"unity-context-slicer": {
"command": "uvx",
"args": [
"unity-context-slicer",
"--project-dir",
"${workspaceFolder}"
]
}
}
}π‘ Recommended Agent Rules (.cursorrules / .windsurfrules)
To help AI coding agents use Unity Context Slicer effectively, add this instruction to your project's rule file:
When answering questions or writing C#/Unity code:
1. Use `unity_search` to discover relevant classes, methods, or scene GameObjects.
2. Use `unity_class` to inspect MonoBehaviour callers, attached scene objects, and class inheritance.
3. Use `unity_bundle` before initiating large refactors to receive a compressed graph context bundle.π Repository Structure
mcp_server.py β FastMCP stdio server implementation and tool definitions.
loader.py β Data primitives (GraphNode, GraphEdge) and graph indexing.
slicer.py β Neighborhood traversal and class context extraction.
compressor.py β Dense text formatting and LLM context reduction.
session.py β Resident GraphSession manager with stale file detection.
unity_parser.py β Scene and prefab document structure extractor.
meta_resolver.py β Mapping between
.metaGUIDs and C# source files.annotations.py β Annotation cache for node purpose metadata.
task_log.py β Task history parser and context embedder.
csharp_scanner/ β C# Roslyn scanner project (CSharpScanner.csproj).
π License
This project is licensed under the MIT License.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/guharoyAntik/unity-context-slicer'
If you have feedback or need assistance with the MCP directory API, please join our Discord server