Hosted OAuth MCP

# Let Claude Code, Cursor, and Codex test real firmware on virtual hardware.

Coding agents write C and Rust fast, then stall because they have no dev board plugged in. Connect your agent to `https://app.circuittwin.ai/mcp` so it can flash ELFs, read UART output, catch register bugs, and prove every fix.

## Connect in one command (zero downloads)

CircuitTwin hosts an OAuth-authenticated Streamable HTTP MCP server at `https://app.circuittwin.ai/mcp`. Pick your client, run the command, and sign in once in your browser.

Claude Code

```
claude mcp add --transport http circuittwin https://app.circuittwin.ai/mcp
```

ChatGPT / Codex CLI

```
codex mcp add circuittwin --url https://app.circuittwin.ai/mcp
```

Gemini CLI

```
gemini mcp add --transport http circuittwin https://app.circuittwin.ai/mcp
```

Cursor / Web MCP connectors

```
https://app.circuittwin.ai/mcp
```

## What your agent can do in a tight loop

1. **Search the twin catalog:** Look up existing STM32, ESP32, RP2040, nRF52, and sensor twins before writing register code.
2. **Upload and execute ELFs:** Flash the exact compiled binary onto a board twin and inspect UART stdout, GPIO pins, bus frames, and hardfault traces.
3. **Check explicit verdicts:** Read deterministic `passed`, `failed`, or `inconclusive` verdicts instead of guessing from compiler warnings.
4. **Generate missing parts:** Feed a vendor datasheet PDF to create a new sensor or MCU twin when a part is missing from the catalog.

## Compact agent primer (under 400 tokens)

Drop <https://circuittwin.ai/agent-skill.md> into your `AGENTS.md` or `CLAUDE.md`. It teaches your coding agent the MCP URL, `ct run --json` flags, exit codes (`0` pass, `1` fail, `4` inconclusive), and capability labels in under 400 tokens.

## Proven on 43 real STM32F407 binaries

On our public [agent benchmark](https://circuittwin.ai/docs/agent-benchmark), CircuitTwin caught 24 of 26 seeded STM32F407 firmware bugs and passed all 17 of 17 working builds. Renode passed 15 of 17 working builds (catching 12/26 bugs), and QEMU passed 10 of 17 working builds (catching 19/26 raw, 8 distinct).

## What the agent sees in each kind of loop

| Loop                    | Feedback the agent gets                                         | Bugs it can find                                                             |
| ----------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Code generation only    | Compiler errors only                                            | Misses clock setup, DMA, pinouts, and bus bugs                               |
| Agent + host mocks      | Unit test assertions on x86                                     | Tests mocks instead of target registers and ISRs                             |
| Agent + CircuitTwin MCP | The real ELF runs: UART, CAN, SPI and I2C logs, register traces | Clock gating, baud, DMA, HardFault and bus failures the firmware can observe |

## Connecting coding agents to embedded twins via MCP

Let coding agents compile firmware, run the ELF on a deterministic board twin, read structured JSON diagnostics and fix bugs without guessing.

A coding agent writing C or Rust firmware without execution feedback compiles code and hopes the registers are right. Wiring CircuitTwin into the agent via the hosted OAuth MCP server (https://app.circuittwin.ai/mcp) or ct run --json gives it deterministic verdicts on every edit.

Every ct command returns one JSON document and a stable exit code: 0 pass, 1 fail, 2 invalid input, 3 platform error, 4 inconclusive (unmodelled register named by peripheral, offset and PC). Never treat exit code 4 as a pass. A compact primer for agents is published at /agent-skill.md.

### Stable ct CLI exit codes for agent loops

| Exit code | Meaning                                            | Agent action                                         |
| --------- | -------------------------------------------------- | ---------------------------------------------------- |
| 0         | Pass: all assertions met, zero unmodelled accesses | Accept edit or proceed to next fault case            |
| 1         | Fail: assertion failed, timeout or HardFault       | Read JSON trace/registers, patch firmware, re-run    |
| 2         | Invalid input: bad CLI flag or suite schema        | Fix command/YAML syntax before retrying              |
| 3         | Platform or network error                          | Retry or report environment issue                    |
| 4         | Inconclusive: firmware touched unmodelled register | Report peripheral + PC explicitly; do not claim pass |

Shell — agent-friendly JSON execution

```
# Compact primer for coding-agent system prompts:
curl -fsSL https://circuittwin.ai/agent-skill.md

# Single-document JSON verdict for automated loops:
ct run --json --board nucleo-f767zi build/app.elf
```

MCP client configuration (OAuth HTTPS)

```
{
  "mcpServers": {
    "circuittwin": {
      "url": "https://app.circuittwin.ai/mcp"
    }
  }
}
```

### Troubleshooting

| Symptom                                             | Fix                                                                                          |
| --------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| Agent claims test passed on exit code 4             | Enforce strict exit-code == 0 checking in your agent prompt (documented in /agent-skill.md). |
| Agent loops on compilation errors before simulation | Run make/cmake first and only invoke ct run after an updated ELF exists.                     |
| Need reproducible bug benchmark numbers             | Review published seeded-bug comparison records at /docs/agent-benchmark.                     |
| Headless CI needs non-interactive auth              | Use CT\_TOKEN=ctk\_... with ct cloud commands rather than browser OAuth.                     |

## Automated firmware fix loops via MCP (Claude, ChatGPT, Gemini, Cursor)

Give your coding assistant real hardware feedback: build, run on a board twin, read the exact HardFault or bus trace, and verify the fix.

Without a simulator, coding assistants guess at peripheral register bits and declare victory once gcc returns zero. Bugs in RCC clocks, I2C NACK handlers and DMA alignments survive untouched.

Wiring Claude, ChatGPT, Gemini or Cursor to the CircuitTwin MCP bundle lets the agent execute your real compiled ELF on a twin, inspect structured JSON diagnostics and iterate until every fault test passes.

### MCP tool loop steps

| Step         | MCP tool call                         | Structured output returned                                |
| ------------ | ------------------------------------- | --------------------------------------------------------- |
| 1\. Compile  | Run cmake / cargo / west build        | Target .elf binary                                        |
| 2\. Simulate | ct\_run / ct\_test\_run on board twin | Exit code, UART console, fault registers, unmodelled regs |
| 3\. Diagnose | Inspect CFSR/BFAR or bus trace        | Exact failing PC, register address and bus frame          |
| 4\. Verify   | Re-run suite with --recheck           | Zero regressions and green JUnit summary                  |

Shell - launch local CircuitTwin MCP server

```
# Verify local ct MCP server responds over stdio
ct mcp serve --catalog "$CT_CATALOG_DIR"
```

mcp.json (Claude / Cursor / Gemini / ChatGPT client)

```
{
  "mcpServers": {
    "circuittwin": {
      "command": "ct",
      "args": ["mcp", "serve"]
    }
  }
}
```

### Troubleshooting

| Symptom                                                      | Fix                                                                                                                    |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| Agent tries to silence exit code 4 by mocking the peripheral | Keep strict suite.yaml checks in CI so PRs must pass on the real board twin with zero unmodelled-register workarounds. |
| Agent loops on the same HardFault address                    | Include -g3 symbols in the debug ELF so the agent can resolve the exact C line from the fault PC.                      |

### Which clients work with the CircuitTwin MCP server?

Any standard MCP stdio client including Claude Code, Claude Desktop, ChatGPT, Gemini CLI and Cursor.

## Frequently asked questions

### Do I need to install a local binary to use CircuitTwin MCP?

No. Point Claude Code, Cursor, ChatGPT/Codex, or Gemini CLI at https://app.circuittwin.ai/mcp over Streamable HTTP and complete the OAuth browser login. Local ct mcp serve is also available if you run offline.

### What permissions does an AI agent get through OAuth?

You pick one workspace and choose either Read only or Read, run firmware, and generate twins. MCP tools cannot delete projects, revoke tokens, or overwrite workspace data.

### Do firmware runs from Claude or Cursor burn credits?

No. Running firmware, reading UART consoles, inspecting faults, and running test suites cost zero credits on every plan including Free. Credits only apply when generating brand-new part twins from datasheets.

### How does the agent know when a hardware register is missing?

CircuitTwin returns structured JSON with explicit verdicts: passed, failed, inconclusive, or error. If firmware touches an unmodelled register, the verdict is inconclusive (exit code 4) with the exact address.

[Full MCP & CLI docs](https://circuittwin.ai/docs/agents) [STM32 agent benchmark](https://circuittwin.ai/docs/agent-benchmark) [Benchmark breakdown post](https://circuittwin.ai/blog/embedded-firmware-benchmark-stm32) [CircuitTwin vs LabWired](https://circuittwin.ai/compare/labwired)

> ## Give your coding agent virtual hardware
>
> Create a free workspace and connect Claude Code, Cursor, Codex, or Gemini to https://app.circuittwin.ai/mcp in under a minute.
>
> [Start now](https://app.circuittwin.ai/try) [Read MCP setup docs](https://circuittwin.ai/docs/agents) [Connect a coding agent](https://circuittwin.ai/docs/agents)
