ucsim-mcp
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., "@ucsim-mcpstart a session with firmware.hex and step 10 instructions"
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.
ucsim-mcp
A Model Context Protocol (MCP) server for the
µCsim microcontroller simulator, built with
FastMCP. It lets an AI model (or any MCP
client) load firmware images, reset/run/step a simulated CPU, inspect and modify
memory and registers, set breakpoints, and drive peripherals on virtual
hardware targets — the whole ucsim_* family (ucsim_51/s51, ucsim_z80,
ucsim_stm8, …).
How it works
The server is a thin adapter over the pyucsim client library,
which does the actual simulator driving: it holds one long-lived ucsim_*
process per session, driven over a pseudo-terminal with a unique prompt
marker (ucSim only prints its prompt on a TTY).
pyucsim handles several ucSim quirks transparently:
@in a filename crashes ucSim (it parsesfile@memoryspace). Images whose path contains@— e.g.M2764A@DIP28.HEX— are copied to a safe temp path before loading.run Ndoes not stop after N cycles on the MCS-51 build (it free-runs until a breakpoint). Use thesteptool for a bounded, deterministic advance.Commands are never pipelined after a
run/step, which ucSim would otherwise swallow as a user interrupt.
MCP client ──stdio──▶ ucsim-mcp (FastMCP tools) ──▶ pyucsim.UCSimEngine ──pty──▶ ucsim_51Related MCP server: dbgprobe-mcp-server
Install
The simulator binary is not bundled — point the server at your own ucSim
build. (A ucsim_* / s51 binary is auto-discovered on PATH, then a local
build at ~/github/razr/ucsim/src/sims/s51.src/ucsim_51.)
This package depends on the pyucsim library. Until both are published, install pyucsim from its sibling checkout first:
cd ucsim-mcp
python3 -m venv .venv
. .venv/bin/activate
pip install -e ../pyucsim # the client library (dependency)
pip install -e ".[dev]" # the MCP serverConfiguration
Environment variables set the defaults for new sessions:
Variable | Meaning | Example |
| ucSim executable (path or name on |
|
| default CPU type ( |
|
| default crystal frequency ( |
|
Any of these can be overridden per-session via start_session arguments.
Run
# stdio transport (what MCP clients spawn)
python -m ucsim_mcp
# or, after install:
ucsim-mcpMCP client configuration
The repo ships a ready-to-use mcp.json that invokes the
ucsim-mcp console script by name — no hardcoded paths. For this to work
the client must find ucsim-mcp on its PATH. The portable way to do that is
to install it in an isolated environment with pipx:
pipx install /path/to/ucsim-mcp # or: pipx install ucsim-mcp (once published){
"mcpServers": {
"ucsim": {
"command": "ucsim-mcp",
"args": [],
"env": {
"UCSIM_CPU": "51",
"UCSIM_XTAL": "11.0592M"
}
}
}
}UCSIM_BINARY is optional — the server auto-discovers a ucsim_* / s51
binary on PATH. Set it only if your simulator lives somewhere unusual.
No install (run from a checkout) — use pipx run / uvx so the client
needs no fixed venv path:
{
"mcpServers": {
"ucsim": {
"command": "pipx",
"args": ["run", "--spec", "/path/to/ucsim-mcp", "ucsim-mcp"]
}
}
}(Replace pipx run --spec ... ucsim-mcp with uvx --from /path/to/ucsim-mcp ucsim-mcp if you prefer uv.)
Tools
Tool | Purpose |
| Start a simulator process (optionally load an image) |
| List active sessions and their configuration |
| Terminate a session |
| Load a firmware image into a running session |
| Reset the CPU |
| Advance a bounded number of instructions ( |
| Free-run until a breakpoint / stop / timeout |
| Interrupt a free-running simulation (SIGINT) |
| CPU state summary (PC, cycles, …) |
| Dump CPU registers |
|
|
|
|
| Disassemble from an address or the current PC |
| Set an execution breakpoint |
| Clear an execution breakpoint |
| List breakpoints |
| Load a cl_hw plugin |
| List loaded plugins + ucSim's |
| Drive a peripheral ( |
| Escape hatch: run any raw ucSim console command |
Memory space names depend on the simulated CPU (for MCS-51: rom/code,
iram, xram, sfr).
Hardware plugins (cl_hw)
ucSim peripherals can be loaded at runtime as shared objects built against the
ucsim-plugin-sdk (loadhw, alias insmod). Two ways:
At startup (recommended when the module must observe the first fetch):
start_session(image=..., load_hw=["/path/adc.so", "/path/teachbox.so"]). Modules are loaded before the image and reset.At runtime:
load_hardware(session_id, "/path/adc.so"). Returns the parsedid_string; drive it withset_hardware(session_id, "adc 0 0x80").
The plugin must be built against the same ucSim binary (the C++ ABI must
match). list_hardware shows what's loaded.
Example flow
start_session(image="firmware.hex", cpu="51", xtal="11.0592M") -> {"session_id": "sim1", ...}
reset(session_id="sim1")
read_memory(session_id="sim1", space="rom", start=0, end=15)
step(session_id="sim1", count=100)
get_state(session_id="sim1")
write_memory(session_id="sim1", space="iram", address=0x50, value=0x42)
stop_session(session_id="sim1")Tests
. .venv/bin/activate
python -m pytestUnit tests run without a simulator. Integration tests drive the real binary and
auto-skip if UCSIM_BINARY (default: the local ucsim_51 build) or the test
ROM is unavailable.
License
MIT.
This server cannot be deployed
Maintenance
Related MCP Connectors
Run, build, and validate firmware on virtual hardware from your AI agent. Hardware knowledge corpus.
- QuallaaOAuthcom.quallaa
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Live browser debugging for AI assistants — DOM, console, network via MCP.
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server that exposes GDB debugging as tools. An AI assistant can set breakpoints, run programs, step through code, inspect variables and memory, and examine registers — all via structured tool calls. Reverse debugging with rr is also supported.343MIT
- AlicenseAqualityCmaintenanceStateful MCP server for driving debug probes (J-Link) to flash, debug, and inspect embedded targets. Enables AI agents to perform flash, memory, breakpoint, and ELF/SVD-aware operations conversationally.4121 PyPI10MIT
- AlicenseAqualityDmaintenanceDebug microcontrollers directly from Claude. This is an MCP server that drives OpenOCD, letting Claude flash firmware, control execution, and inspect a running target — and read your variables and peripheral registers by name instead of raw addresses.3958 PyPI4MIT
- AlicenseNot gradedqualityAmaintenanceMCP server for simulating firmware on virtual microcontroller instances, allowing AI agents to upload, run, and read UART output from supported boards such as STM32 and Nordic.17MIT