CarlaMCP
Click on "Deploy 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., "@CarlaMCP Run an aggressive cut-in from the right at 120 km/h with 1.2s TTC"
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.
CarlaMCP
Natural language → executable autonomous-vehicle scenarios in the CARLA simulator, exposed to any LLM through the Model Context Protocol.
Built on the tool-based architecture of IROSA, validated against CARLOS for containerized deployment.
A prompt like "an aggressive cut-in from the right at highway speed in heavy rain at night" becomes a validated, reproducible scenario that runs in CARLA — and can be saved as a spec for replay.
How it works
NL prompt ─▶ LLM picks tools ─▶ validated ScenarioManifest ─┬─▶ execute in CARLA ─▶ ScenarioResult
(Pydantic primitives) │
└─▶ save .json spec ─▶ replay / reuseThree layers, each independently testable:
Layer | Package | Responsibility |
Primitives |
| Pydantic models with LLM-facing descriptions, range constraints, and cross-field validators. The LLM never writes raw simulator code. |
Executors |
| Translate validated primitives into |
Server |
| The MCP server exposing tools to the model. |
Related MCP server: HUTB Simulator MCP Server
Project structure
CarlaMCP/
├── carlamcp/
│ ├── config.py # connection + simulation/spawn constants
│ ├── enums.py # CARLAMap, Side, WeatherCondition
│ ├── results.py # ScenarioResult
│ ├── carla_client.py # CARLA binding import + get_client()
│ ├── world.py # map / actor / sync-mode / find_ego helpers
│ ├── storage.py # save / load scenario specs (export & replay)
│ ├── primitives/ # one file per primitive + the manifest
│ │ ├── cut_in.py pedestrian.py weather.py manifest.py
│ ├── executors/ # one executor per primitive + the orchestrator
│ │ ├── cut_in.py pedestrian.py weather.py manifest.py
│ └── server.py # FastMCP server + tools + main()
├── tests/ # pytest suite, runs WITHOUT a simulator
│ ├── fakes.py conftest.py test_executor.py test_primitives.py
├── pyproject.toml requirements.txt .gitignore LICENSE README.mdSetup
1. Start CARLA (separate terminal)
~/carla/CarlaUE4.sh -RenderOffScreen -quality-level=Low &2. Install CarlaMCP
cd CarlaMCP
pip install -e ".[dev]" # package + test deps (no simulator needed)
pip install -e ".[carla,dev]" # also installs the carla==0.9.15 binding3. Verify the CARLA connection
python -c "from carlamcp.carla_client import get_client; print(get_client().get_server_version())"4. Run the MCP server
python -m carlamcp.server # or just: carlamcp5. Wire into Claude Desktop
Add to your claude_desktop_config.json (use the absolute path to your clone):
{
"mcpServers": {
"carlamcp": {
"command": "python",
"args": ["-m", "carlamcp.server"],
"cwd": "<path-to-your-CarlaMCP-clone>"
}
}
}Restart Claude Desktop; the CarlaMCP tools will appear.
Usage
Once connected, talk to the model:
"Check if CARLA is running" →
get_status"Run an aggressive cut-in from the right at 120 km/h with 1.2s TTC" →
run_scenario"Pedestrian crosses 25 m ahead, occluded by a parked car, in heavy fog"
"Set the weather to rain_night at intensity 0.8" →
set_weather"Validate this manifest before running it: {...}" →
validate_scenario
Tools
Tool | Purpose |
| Check the simulator is reachable. |
| List supported towns and their characteristics. |
| Build + validate + execute a scenario (optional |
| Apply a weather preset only. |
| Validate a manifest JSON without running it. |
| Validate and persist a manifest for later. |
| Load a saved spec and execute it. |
Scenario primitives
Primitive | Key parameters | Default map |
|
| Town04 (motorway) |
|
| Town03 (urban) |
|
| Any |
Export & replay
Any scenario can be persisted as a validated JSON spec and re-run later — useful for regression sets, sharing, and scenario inpainting / augmentation pipelines:
run_scenario("...", cut_in_speed_kmh=120, cut_in_ttc_s=1.2, cut_in_side="right",
save_as="rainy_cutin") # writes scenarios/rainy_cutin.json
replay_scenario("rainy_cutin") # re-executes the exact same specThe export layer (carlamcp/storage.py) is deliberately decoupled from
execution, so generated specs can be consumed by downstream tooling without a
running simulator. See Roadmap → OpenSCENARIO export.
Testing
The suite runs entirely offline — tests/conftest.py injects a fake carla
module so the executor logic (spawn geometry, velocities, ordering, error paths,
collision metric) is verified without a GPU or a running simulator. This makes
it CI-friendly.
pip install -e ".[dev]"
pytest -qtests/test_executor.py doubles as the canonical example of the project's
Google-style (Sphinx Napoleon)
docstring convention used across every module.
FAQ — why Python and not C++?
CARLA runs on Unreal Engine (C++), so it's a fair question. For CarlaMCP, C++
buys nothing: the carla PyPI package is a thin binding over the C++
LibCarla client, and everything done here (spawning actors, weather, the
traffic manager) is fully exposed in Python with negligible overhead at these
tick rates. C++ only becomes worthwhile for work that lives inside the CarlaUE4
server build — custom Unreal sensors/actors/map assets, per-frame
high-bandwidth sensor processing where the GIL is the bottleneck, or C++
ScenarioRunner extensions. None of those are on the roadmap, so CarlaMCP stays
pure Python.
Roadmap
Phase 1 — Validated primitives + MCP server + CARLA execution
Phase 2 — Modular package, offline test suite, scenario export/replay
Phase 3 — CARLOS Docker integration (
docker-compose.yml)Phase 4 — CSR/ISR/TCR evaluation harness
Phase 5 — OpenSCENARIO export for the CARLOS replay pipeline
Paper — IEEE IV / ITSC submission
Related work
IROSA — tool-based LLM architecture for robot skill adaptation (DLR/TUM)
CARLOS — containerized CARLA simulation framework (ika RWTH Aachen)
SUMO-MCP — MCP for traffic simulation (adjacent domain)
License
MIT.
Available Tools
7 toolsget_statusA
Check whether the CARLA server is reachable and return version info.
Always call this first before running scenarios.
Returns:
dict: carla_available/ready flags plus version info or an error
hint describing how to start the simulator.
Inputs: no named parameters.
list_mapsA
List the CARLA maps supported by CarlaMCP.
Returns:
dict: A maps mapping of map name to a short description of its
characteristics.
Inputs: no named parameters.
replay_scenarioA
Load a previously saved scenario spec and execute it.
Args:
path (str): Saved scenario name or path (e.g. "demo" or
"scenarios/demo.json").
Returns:
dict: The execution result, or {"error": ...} if the spec could not
be loaded.
Inputs: path (required).
run_scenarioA
Generate and execute a CARLA scenario from natural language.
Builds a validated :class:ScenarioManifest from flat parameters and runs
it. At least one of the cut_in_*, pedestrian_*, or weather_*
groups must be provided. Optionally persists the validated spec for replay.
Args:
nl_prompt (str): The natural-language description of the scenario.
cut_in_speed_kmh (Optional[float]): See :func:_build_manifest.
cut_in_ttc_s (Optional[float]): See :func:_build_manifest.
cut_in_side (Optional[str]): See :func:_build_manifest.
cut_in_ego_speed_kmh (float): See :func:_build_manifest.
cut_in_map (str): See :func:_build_manifest.
pedestrian_gap_s (Optional[float]): See :func:_build_manifest.
pedestrian_distance_m (Optional[float]): See :func:_build_manifest.
pedestrian_occluded (bool): See :func:_build_manifest.
weather_condition (Optional[str]): See :func:_build_manifest.
weather_intensity (Optional[float]): See :func:_build_manifest.
save_as (Optional[str]): If given, save the validated spec under this
name for later replay.
Returns:
dict: The execution result, or an error/hint payload if
validation failed.
Examples: Aggressive cut-in from the right at 120 km/h::
run_scenario("...", cut_in_speed_kmh=120, cut_in_ttc_s=1.2,
cut_in_side="right")
Occluded pedestrian crossing 30 m ahead::
run_scenario("...", pedestrian_gap_s=1.5, pedestrian_distance_m=30,
pedestrian_occluded=True)
Inputs: nl_prompt (required), cut_in_speed_kmh, cut_in_ttc_s, cut_in_side, +8 more.
save_scenarioB
Validate and persist a scenario manifest for later replay.
Args:
manifest_json (str): JSON string of a :class:ScenarioManifest.
name (str): Short name to save under (stored as scenarios/<name>.json).
Returns:
dict: {"saved": True, "path": ...} on success, or
{"saved": False, "error": ...} if validation failed.
Inputs: manifest_json (required), name (required).
set_weatherA
Apply a weather condition to the world without spawning agents.
Args:
condition (str): One of clear, rain, fog, night,
rain_night.
intensity (float): Severity from 0.0 (minimal) to 1.0 (maximum).
Returns: dict: The execution result.
Inputs: condition (required), intensity (required).
validate_scenarioA
Validate a scenario manifest JSON without executing it.
Args:
manifest_json (str): JSON string of a :class:ScenarioManifest.
Returns:
dict: {"valid": True, "manifest": ..., "primitives": [...]} on
success, or {"valid": False, "error": ...} on failure.
Inputs: manifest_json (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clearly defined purpose with no overlap: server status, map listing, scenario generation from NL, replay, save, weather control, and validation. The pair run_scenario and replay_scenario are distinguished by input source (NL vs. saved spec).
All tools follow the verb_noun snake_case convention (get_status, list_maps, run_scenario, etc.), making the API predictable and easy to navigate.
Seven tools cover the essential operations for a CARLA simulation server: status check, map exploration, scenario lifecycle (create, save, replay, validate), and weather control. The count is well-scoped without redundancy.
The tool surface covers the core workflow (scenario generation, execution, replay, weather). Minor gaps include no tool to list or delete saved scenarios, but agents can work around by using the file system or naming conventions.
Related MCP Connectors
AI-native programming language and toolchain for accountable, verifiable agent-driven development.
Launch and verify high-fidelity mobile simulations from an AI agent.
MERCATOR Verify: evidence-backed verification and decision support for autonomous agents.
Task and planning workspace for humans collaborating with AI agents
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceConnects LLMs to Eclipse SUMO traffic simulation, enabling AI agents to automate traffic network generation, demand modeling, signal optimization, simulation execution, and real-time TraCI control through natural language.59MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI interaction with embodied humans, autonomous vehicles, and drones through the HUTB simulator. Supports voice/chat control, weather conditions, perspective switching, and recording features.Apache 2.0
- AlicenseAqualityCmaintenanceEnables interactive design, execution, and analysis of SUMO traffic simulations through natural language, providing tools for scenario generation, policy experimentation, result analysis, and visualization.2611MIT
- AlicenseAqualityCmaintenanceAn agentic system for sim-ready interactive scene generation in Isaac Sim61Apache 2.0