UnityAutonomousMCP
A comprehensive autonomous agent framework for Unity 2022.3.22f1 combining Model Context Protocol with AI decision-making, enabling intelligent task planning, editor automation, and multi-agent coordination.
README
Unity Autonomous Agent MCP
š¤ A comprehensive autonomous agent framework for Unity 2022.3.22f1 that combines the power of Model Context Protocol (MCP) with advanced AI decision-making capabilities.
š Key Features
š§ Autonomous Agent Capabilities
- Intelligent Task Planning: AI-driven task decomposition and execution planning
- Decision Making: Context-aware decision trees with learning capabilities
- Self-Improvement: Continuous learning from user interactions and outcomes
- Multi-Agent Coordination: Support for multiple autonomous agents working together
š® Unity Integration
- Full Editor Control: Complete Unity Editor automation and manipulation
- Runtime AI: In-game autonomous NPC behavior and debugging
- Asset Management: Intelligent asset creation, optimization, and organization
- Scene Management: Automated scene setup, optimization, and testing
š§ Advanced MCP Features
- Extensible Architecture: Plugin-based system for custom tools and handlers
- Real-time Communication: Low-latency TCP/IP communication with external AI services
- Multi-Provider Support: Compatible with Claude, GPT, Gemini, and custom LLM providers
- Resource Management: Intelligent resource allocation and optimization
šļø Architecture Overview
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Unity Autonomous Agent MCP ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
ā ā Agent Core ā ā Task Planner ā ā Decision ā ā
ā ā ā ā ā ā Engine ā ā
ā ā - State Mgmt ā ā - Task Decomp ā ā - ML Models ā ā
ā ā - Learning ā ā - Priority ā ā - Context ā ā
ā ā - Memory ā ā - Scheduling ā ā - Reasoning ā ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
ā ā MCP Server ā ā Unity Bridge ā ā Plugin ā ā
ā ā ā ā ā ā System ā ā
ā ā - Protocol ā ā - Editor API ā ā - Custom ā ā
ā ā - Handlers ā ā - Runtime API ā ā Tools ā ā
ā ā - Transport ā ā - Asset Mgmt ā ā - Extensions ā ā
ā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā Unity Engine (2022.3.22f1) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š Requirements
- Unity 2022.3.22f1 or later (tested up to Unity 6.1)
- .NET/C# 9.0
- Node.js 18.0.0+ with npm (for TypeScript server)
- Python 3.8+ (for ML/AI components)
- External LLM Provider (Claude, OpenAI, Gemini, or custom)
š Quick Start
Re-analysis details and capability gaps are documented in
docs/capability-matrix.md.
1. Installation
# Clone the repository
git clone https://github.com/KinofSin/UnityAutonomousMCP.git
cd UnityAutonomousMCP
# Install Unity Package
# In Unity Editor: Window > Package Manager > Add package from git URL
# Enter: file:///path/to/UnityAutonomousMCP/com.autonomous-unity.mcp
2. Setup TypeScript Server
npm install
npm run build
npm run smoke
npm run smoke validates planner + executor behavior (including run_tests -> get_test_job polling) for both successful and failed test-job terminal paths, without requiring a live Unity Editor.
3. Run modes
# Autonomous bootstrap (local dry-run using mock Unity bridge)
npm run dev -- -- "inspect scene and update scripts"
# MCP stdio mode (for Claude/Cursor/Windsurf MCP client config)
npm run dev -- --mcp
# Force mock bridge explicitly
npm run dev -- --mock -- "inspect scene and update scripts"
4. Transport bridge configuration (real Unity connection)
Unity package host (inside Unity Editor) serves both transports:
- HTTP endpoint:
POST /mcp/toolonUNITY_HTTP_PORT(default8080) - TCP endpoint: newline-delimited JSON on
UNITY_TCP_PORT(default8081)
Node-side bridge environment variables:
UNITY_TRANSPORT=http # http | tcp | mock
UNITY_HOST=127.0.0.1
UNITY_HTTP_PORT=8080
UNITY_TCP_PORT=8081
UNITY_TIMEOUT_MS=10000
UNITY_TEST_POLL_ATTEMPTS=30
UNITY_TEST_POLL_INTERVAL_MS=1000
UNITY_TEST_POLL_TIMEOUT_MS=120000
5. Configure Claude Desktop
{
"mcpServers": {
"unity-autonomous-agent": {
"command": "node",
"args": ["path/to/server/dist/index.js"],
"env": {
"UNITY_HOST": "localhost",
"UNITY_TRANSPORT": "http",
"UNITY_HTTP_PORT": "8080",
"UNITY_TCP_PORT": "8081",
"AI_PROVIDER": "anthropic",
"AI_API_KEY": "your-api-key"
}
}
}
}
6. Start Using
- Open Unity Project
- Navigate to
Edit > Preferences > Autonomous Agent MCP - Configure host + HTTP/TCP ports
- Click "Connect" to start Unity transport host
- Start MCP server (
npm run dev -- --mcp) - Begin interacting with AI through your preferred MCP client
ā Current implementation status (this repo)
- Capability matrix + gap analysis:
docs/capability-matrix.md - Autonomous planner core:
server/src/planner.ts - Policy guardrails:
server/src/policy.ts - Plan executor:
server/src/executor.ts - MCP server tools (
autonomous_plan,unity_tool_call,list_capabilities):server/src/mcpServer.ts - Real Unity bridge transports (HTTP/TCP + env-driven mode):
server/src/unityBridge.ts - Concrete step contracts for autonomous_plan:
server/src/contracts.ts - Unity 2022.3.22f1 package scaffold:
com.autonomous-unity.mcp/- Editor settings/provider:
Editor/AutonomousMcpSettingsProvider.cs - Real transport host:
Editor/AutonomousMcpTransportHost.cs - Tool dispatcher:
Editor/AutonomousMcpToolDispatcher.cs - Runtime entry component:
Runtime/AutonomousMcpRuntime.cs
- Editor settings/provider:
š End-to-end autonomous_plan contract mapping
autonomous_plan now emits concrete Unity tool payloads:
read_consoleā{ level, limit }manage_sceneā{ action: "inspect_active_scene" }manage_scriptā{ action: "create_or_update", scriptPath, contents }(when goal implies code changes)validate_scriptā{ strict }(after script edits)run_testsā{ mode }(when goal mentions tests; returnsjobId)get_test_jobā{ jobId }(executor polls untilcompletedorfailed)batch_executeā{ operations: [{ tool: "manage_scene", params: { action: "save_active_scene" } }] }
Test execution flow
run_testsstarts an async Unity Test Runner job (editmodeorplaymode)- Server receives
{ jobId, status: "queued" } - Executor automatically calls
get_test_jobuntil terminal state - Final test summary (passed/failed/skipped + per-test details) is included in execution results
Test polling policy limits
UNITY_TEST_POLL_ATTEMPTS: max polling iterations forget_test_job(clamped 1..300)UNITY_TEST_POLL_INTERVAL_MS: delay between polls in milliseconds (clamped 100..60000)UNITY_TEST_POLL_TIMEOUT_MS: overall timeout for polling cycle (clamped 1000..1800000)
š¤ Autonomous Agent Features
Intelligent Task Planning
- Goal Decomposition: Break complex tasks into manageable subtasks
- Priority Management: Dynamic task prioritization based on context
- Resource Allocation: Optimal distribution of system resources
- Dependency Resolution: Handle task dependencies and conflicts
Learning & Adaptation
- Pattern Recognition: Learn from user behavior and preferences
- Performance Optimization: Improve efficiency over time
- Error Recovery: Learn from mistakes and avoid repetition
- Context Awareness: Adapt to project-specific requirements
Multi-Agent Coordination
- Agent Communication: Coordinate multiple specialized agents
- Task Distribution: Distribute workload across agent instances
- Conflict Resolution: Handle competing priorities and resource conflicts
- Collaborative Problem Solving: Combine multiple agent perspectives
š§ MCP Tools & Capabilities
š® Unity Editor Tools
- Scene Management: Create, modify, optimize scenes automatically
- Asset Operations: Intelligent asset creation and organization
- GameObject Control: Advanced object manipulation and optimization
- Component Management: Dynamic component addition and configuration
- Build Automation: Automated build processes and optimization
š§© Advanced Development Tools
- Code Generation: AI-assisted script writing and optimization
- Testing Automation: Automated test creation and execution
- Performance Analysis: Real-time performance monitoring and optimization
- Debugging Assistant: Intelligent error detection and resolution
- Documentation Generation: Auto-generate technical documentation
šÆ Runtime AI Features
- NPC Behavior: Dynamic, intelligent NPC behavior systems
- Game Balance: Automated game balance testing and adjustment
- Player Analytics: Real-time player behavior analysis
- Dynamic Difficulty: Adaptive difficulty adjustment systems
- Content Generation: Procedural content creation and optimization
š Plugin System
Create custom plugins to extend functionality:
[AutonomousPlugin("custom-tool")]
public class CustomToolPlugin : IAutonomousTool
{
public async Task<ToolResult> ExecuteAsync(ToolContext context)
{
// Your custom tool logic
return new ToolResult { Success = true, Data = result };
}
}
š Performance & Monitoring
Real-time Metrics
- Agent Performance: Monitor agent efficiency and accuracy
- Resource Usage: Track CPU, memory, and network utilization
- Task Completion: Measure task success rates and timing
- Learning Progress: Track agent improvement over time
Optimization Features
- Caching System: Intelligent caching for frequently used data
- Batch Processing: Optimize multiple operations together
- Predictive Loading: Anticipate and preload required resources
- Adaptive Performance: Adjust performance based on system capabilities
š”ļø Security & Safety
Safety Measures
- Sandboxed Execution: Isolate agent operations from critical systems
- Permission System: Granular control over agent capabilities
- Audit Logging: Complete audit trail of all agent actions
- Rollback Capability: Undo system for agent modifications
Best Practices
- Regular Backups: Automatic backup before major operations
- Validation Checks: Verify operation safety before execution
- User Confirmation: Require confirmation for destructive operations
- Error Handling: Comprehensive error recovery mechanisms
š¤ Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
- Clone repository
- Install dependencies (
npm installin server directory) - Open Unity project
- Enable Developer Mode in preferences
- Start contributing!
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š Acknowledgments
- Built upon the excellent foundations of Unity-MCP and UnityMCP
- Inspired by the latest advances in autonomous agents and AI decision-making
- Community feedback and contributions have been invaluable
š Ready to transform your Unity development with AI-powered autonomy?
Start building intelligent, self-improving Unity projects today!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.