mlagents-mcp
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., "@mlagents-mcpStart a new training run with default settings."
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.
mlagents-mcp
MCP server for controlling Unity ML-Agents training runs from Claude Code.
Launch, stop, resume, monitor, compare, and export ML-Agents training — all through natural conversation without leaving your editor.
Features
Training control — start, stop, resume runs as background processes
Instant checks — check training progress without blocking the conversation
Live monitoring — read TensorBoard metrics, reward curves, and training logs in real time
Run comparison — compare metrics across runs for hyperparameter tuning
Config management — read and deep-merge update YAML training configs
Model export — locate .onnx models and checkpoints
Two training modes — Unity Editor (interactive) and built executable (headless batch)
Related MCP server: claude-sessions-mcp
Requirements
Python 3.10+
uv package manager
Unity ML-Agents
mlagents-learnavailable in PATH (or via conda env)Claude Code CLI
Installation
git clone https://github.com/limam-B/mlagents-mcp-server.git
cd mlagents-mcp-server
uv syncQuick setup with Claude Code
# Register the MCP server:
claude mcp add --scope project --transport stdio mlagents-training \
-- uv run --directory /path/to/mlagents-mcp-server mlagents-mcp
# Unregister (from all scopes to clean up stale configs):
claude mcp remove --scope local mlagents-training
claude mcp remove --scope user mlagents-training
claude mcp remove --scope project mlagents-training
# List registered servers:
claude mcp listWith environment variables
The server reads its configuration from environment variables. Add them to your .mcp.json (project-level) or pass them via the CLI:
{
"mcpServers": {
"mlagents-training": {
"command": "uv",
"args": ["run", "--directory", "/path/to/mlagents-mcp-server", "mlagents-mcp"],
"env": {
"MLAGENTS_PROJECT_ROOT": "/path/to/your/unity/project",
"MLAGENTS_RESULTS_DIR": "results",
"MLAGENTS_CONFIG_DIR": "config"
}
}
}
}With conda (if ML-Agents is installed in a conda env)
{
"mcpServers": {
"mlagents-training": {
"command": "uv",
"args": ["run", "--directory", "/path/to/mlagents-mcp-server", "mlagents-mcp"],
"env": {
"MLAGENTS_PROJECT_ROOT": "/path/to/your/unity/project",
"MLAGENTS_RESULTS_DIR": "results",
"MLAGENTS_CONFIG_DIR": "config",
"MLAGENTS_CONDA_ENV": "mlagents",
"MLAGENTS_CONDA_PATH": "/home/user/miniconda3"
}
}
}
}Environment variables
Variable | Default | Description |
|
| Root directory of your Unity project |
|
| Training results directory (relative to project root) |
|
| Training config YAML directory (relative to project root) |
| — | Conda environment name to activate before running |
| — | Path to conda installation (e.g. |
Tools (18)
Training control
Tool | Description |
| Launch a new training run (overwrites previous results). Blocks until ready by default. |
| Gracefully stop a run (SIGINT, saves the model). |
| Resume from checkpoint. Auto-reads config from previous run. |
| Kill orphaned mlagents-learn and Unity build processes not tracked by any active run. |
Monitoring
Tool | Description |
| Status overview: reward trend, checkpoints, step progress. |
| Read TensorBoard scalars (reward, losses, learning rate, etc.). |
| Tail live stdout/stderr from an active run. |
| List all known runs with status filtering. |
Comparison & export
Tool | Description |
| Compare a metric across multiple runs (min/max/final + trend). |
| Locate .onnx model files and checkpoints. |
Configuration
Tool | Description |
| Read a YAML training config. |
| Deep-merge updates into a config (only specified keys change). |
Wait & check
Tool | Default | Description |
| Blocks | Blocks until first TensorBoard data point appears (~1-2 min). |
| Blocks | Blocks until training finishes. For automated run chaining (up to 4 hours). |
| Instant | Check if training reached a target step. Returns current progress. |
| Instant | Check if mean reward reached a target. Returns current reward. |
| Instant | Check if training finished. Returns current status and progress. |
| Instant | Check if new .onnx files appeared. Returns checkpoint list. |
The check_* tools always return instantly — they never block the conversation. Use wait_for_completion when you want to block until a run finishes (e.g. to chain skill A → skill B automatically).
Two training modes
Editor mode (no env_path)
Training connects to the Unity Editor. force_training blocks until mlagents-learn prints "Listening on port... press Play", then you (or an AI agent) presses Play in Unity.
force_training(config_path="movement.yaml", run_id="Movement_v1")
# → blocks until "Listening on port 5004. Start training by pressing Play..."Batch mode (with env_path)
Training launches a built executable directly — no Unity Editor needed. force_training blocks until the executable connects.
force_training(
config_path="movement.yaml",
run_id="Movement_v1",
env_path="/path/to/Build.x86_64",
num_envs=12,
no_graphics=True,
)
# → blocks until "Connected to Unity environment"Example workflow
A typical automated training session:
1. force_training(config, run_id, ...) # launch, blocks until ready
2. wait_for_first_metrics(run_id) # blocks until data flowing
3. wait_for_completion(run_id) # blocks until training ends (hours)
4. export_model(run_id) # get checkpoint
5. update_config(next_skill, init_path=..) # chain checkpoint to next skill
6. [repeat from step 1 for next skill]Steps 1-2 block briefly during startup. Step 3 blocks for the full duration (hours) — use this for automated chaining. For manual monitoring, use check_step/check_completion instead of step 3.
Development
# Install dev dependencies:
uv sync --group dev
# Lint:
uv run ruff check src/
# Format:
uv run ruff format src/
# Run the server directly (stdio):
uv run mlagents-mcpProject structure
src/mlagents_mcp/
server.py # FastMCP app, all 18 tool definitions, entry point
process_manager.py # Subprocess launch/stop, log capture, port assignment
metrics_reader.py # TensorBoard event file parsing
config_manager.py # YAML config read/write/deep-merge
run_registry.py # Thread-safe run tracking + historical disk scan
waiters.py # Blocking wait logic for all wait_for_* tools
types.py # Shared dataclasses and enumsLicense
MIT
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/limam-B/mlagents-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server