mcp-cocotb
This server lets AI agents discover, generate, and run Cocotb co-simulation testbenches for Verilog/SystemVerilog designs through structured MCP tools.
Run simulations end-to-end with
cocotb_run: compile Verilog sources, execute Python testbenches using Icarus or Verilator, and get structured JSON results with pass/fail counts, durations, assertion tracebacks, and optional waveform dumping.Discover tests statically with
cocotb_list_tests: parse a Python testbench file to list all@cocotb.test()coroutines and their docstrings without running a simulation.Generate reproducible Makefiles with
cocotb_generate_runner: create standard Cocotb simulation Makefiles for a specified DUT, test module, and simulator backend.Probe the toolchain with
cocotb_toolchain_info: report the active container/host runtime and versions of Cocotb, Python, and simulator engines.Support agent self-repair loops by returning exact Python tracebacks and line numbers for assertion failures.
Run with zero local configuration via rootless Podman containers or optionally force host binaries.
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., "@mcp-cocotb Run the test_dff.py Cocotb tests against dff.v and show the failures"
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.
@zesun33/mcp-cocotb
Purpose and first steps
Run Python hardware testbenches and inspect their results through an MCP server.
Who it is for: Hardware engineers using an MCP-capable client or coding agent.
First task: Configure the server in your MCP client, then call cocotb_toolchain_info before running a design.
What to expect: Simulator/tool availability, then discovered tests and parsed pass/fail results.
Current scope: Published MCP server. The npx command starts a stdio server that waits for a client; EDA execution also needs its documented host/container tools.
Start here: Runtime requirements and configuration.
Related projects: mcp-verilog, hw-verification-suite.
Model Context Protocol (MCP) server for Python-based Cocotb co-simulation hardware testbenches.
mcp-cocotb equips AI coding agents and IDEs (Cursor, Windsurf, GitHub Copilot / OpenAI Codex, Claude Code, Google Antigravity, OpenCode, Cline) with structured tools to discover, generate, and run asynchronous Python testbenches against Verilog/SystemVerilog designs. By wrapping the complexity of simulator VPI compilation, Makefile orchestration, and JUnit XML parsing into deterministic JSON contracts, agents can execute closed-loop verification without drowning in simulator logs.
Related MCP server: EDA Tools MCP Server
Install and run
Run this MCP server directly from npm:
npx -y @zesun33/mcp-cocotbFor the complete hardware-agent setup, use npx -y @zesun33/create-hw-agent my-asic.
⚡ Quick Tour: See It in Action
The examples below illustrate tool requests and result fields. Timings, counts, and scores depend on the input and runtime; they are not guaranteed outcomes or fresh verification results.
Why AI Agents Need mcp-cocotb
Without | With |
Handcrafts brittle Makefiles with obscure | 1-Call Generation & Execution ( |
Parses hundreds of lines of mixed C/VPI/Python stdout | Structured JSON with test counts, pass/fail, duration |
Assertion failures lost in noisy simulator terminal scrollback | Direct Python exception traceback & line numbers |
Simulator hangs on coroutine deadlock or infinite clock loop | Automated timeout kill-switch ( |
Requires complex local Python 3.12 + C++ compiler toolchains | Zero host configuration (runs via isolated rootless Podman) |
Example tool requests and results
1. Probing the Environment (Zero-Config Verification)
// Tool Call: cocotb_toolchain_info
{
"runtime": "podman",
"image": "ghcr.io/zesun33/verilog",
"cocotbVersion": "2.1.0",
"pythonVersion": "Python 3.12.3",
"simulator": "iverilog (Icarus Verilog)"
}2. Static Test Discovery (Inspect Test Matrix Without Running)
// Tool Call: cocotb_list_tests {"test_file": "test_dff.py"}
{
"file": "test_dff.py",
"totalTests": 3,
"tests": [
{ "name": "test_dff_reset", "doc": "Verify DFF reset behavior." },
{ "name": "test_dff_toggle", "doc": "Verify DFF data propagation across clock edges." },
{ "name": "test_dff_failing_assert", "doc": "Negative test fixture for assertion failure handling." }
]
}3. Automated Co-Simulation Runner (Passing Suite)
// Tool Call: cocotb_run {"verilog_sources": ["dff.v"], "toplevel": "dff", "python_module": "test_dff"}
{
"success": false,
"totalTests": 3,
"passedTests": 2,
"failedTests": 1,
"durationSeconds": 0.04,
"tests": [
{ "name": "test_dff_reset", "classname": "test_dff", "time": 0.012, "status": "pass" },
{ "name": "test_dff_toggle", "classname": "test_dff", "time": 0.018, "status": "pass" },
{
"name": "test_dff_failing_assert",
"classname": "test_dff",
"time": 0.010,
"status": "fail",
"failureMessage": "assert False, 'INTENTIONAL_ASSERTION_FAILURE'",
"traceback": "Traceback (most recent call last):\n File \"test_dff.py\", line 45, in test_dff_failing_assert\n assert False, 'INTENTIONAL_ASSERTION_FAILURE'\nAssertionError: INTENTIONAL_ASSERTION_FAILURE"
}
]
}4. Instant Agent Self-Repair Loop
Because mcp-cocotb captures the exact Python failure traceback (AssertionError: INTENTIONAL_ASSERTION_FAILURE at line 45), the LLM agent immediately knows what line and condition failed and can self-correct the RTL or testbench in a single turn without human intervention.
Tools Exposed
Tool | Parameters | Engine | Description |
|
|
| Compiles DUT, executes the Python testbench, and returns parsed JUnit results with tracebacks plus |
|
| AST Scanner | Fast static parser extracting all |
|
| Generator | Generates a reproducible Cocotb |
| none | Probe | Returns active container/host runtime and versions of Cocotb, Python 3, and simulator engines. |
Execution Runtime
mcp-cocotb runs inside the zesun33/verilog rootless Podman image so tools are identical on any Linux host.
Public install (recommended — anyone can pull):
podman pull ghcr.io/zesun33/verilog:latest
export MCP_COCOTB_IMAGE=ghcr.io/zesun33/verilogghcr.io/zesun33/verilog is the default (anyone can pull). Local builds still work as localhost/zesun33/verilog via MCP_COCOTB_IMAGE.
Container mount:
-v <workspace>:/workspace:Z -w /workspacePodman storage option:
--storage-opt overlay.ignore_chown_errors=true
To force host binaries instead of container execution:
export MCP_COCOTB_RUNTIME=hostUniversal Client & AI IDE Setup
Because mcp-cocotb implements the standard Model Context Protocol (MCP), it connects seamlessly to any MCP-compliant AI IDE or agent interface:
Environment | Supported Tools | Setup Location |
AI IDEs | Cursor, Windsurf, Google Antigravity, Zed |
|
Extensions | GitHub Copilot / OpenAI Codex, Cline, Roo Code | VS Code MCP extension settings |
CLI Agents | Claude Code, OpenCode, Goose, Antigravity CLI ( | Global MCP configuration or CLI flags |
Desktop | Claude Desktop |
|
1. Cursor / Windsurf / Antigravity IDE
Add to your project's .cursor/mcp.json or .windsurf/mcp.json:
{
"mcpServers": {
"cocotb": {
"command": "node",
"args": ["/path/to/personal-projects/mcp-cocotb/dist/index.js"]
}
}
}2. VS Code (GitHub Copilot / OpenAI Codex / Cline)
Add to your VS Code MCP settings or user configuration:
{
"mcpServers": {
"cocotb": {
"command": "node",
"args": ["/path/to/personal-projects/mcp-cocotb/dist/index.js"]
}
}
}3. Claude Desktop & Claude Code
Add to claude_desktop_config.json:
{
"mcpServers": {
"cocotb": {
"command": "node",
"args": ["/path/to/personal-projects/mcp-cocotb/dist/index.js"]
}
}
}Verification & Testing
Run the full 6-gate verification suite:
# Full verification (with Podman container execution)
./scripts/verify.sh
# Fast / CI verification (headless environments)
./scripts/verify.sh --quickRun specific test tiers:
npm run test:unit # Fast unit tests (parsers & AST discovery)
npm test # Full test suite (including live container simulation)npm releases
See RELEASING.md for GitHub Actions dry runs and trusted publishing.
Available Tools
4 toolscocotb_generate_runnerB
Generates a deterministic, standard Cocotb simulation Makefile for a given Verilog DUT and Python test module.
Inputs: toplevel (required), python_module (required), verilog_sources (required), simulator.
cocotb_list_testsA
Discovers all @cocotb.test() coroutines and their docstrings in a Python testbench file without executing simulation.
Inputs: test_file (required), cwd.
cocotb_runA
Compiles a Verilog DUT, executes an asynchronous Python cocotb testbench, and parses results into structured JSON test reports with assertion tracebacks.
Inputs: toplevel (required), python_module (required), verilog_sources (required), cwd, +3 more.
cocotb_toolchain_infoA
Returns active container or host execution runtime info and versions of Cocotb, Python, and simulator.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct stage of the Cocotb workflow: test discovery, Makefile generation, simulation execution, and environment introspection. There is no meaningful overlap between the tools.
All tools share the cocotb_ prefix and mostly follow a verb_noun pattern. Minor deviations are cocotb_run (verb only) and cocotb_toolchain_info (noun phrase), but the names remain predictable and readable.
Four tools is well-scoped for a focused Cocotb simulation server. Each tool covers a necessary part of the workflow without redundancy or bloat.
The set provides end-to-end coverage: discover tests, generate a runner, execute simulations with parsed results, and inspect the runtime environment. No obvious core operation is missing for the stated domain.
Maintenance
Related MCP Connectors
Design circuits, simulate and verify embedded firmware, and lay out PCBs with AI agents.
A public board where AI agents design pieces of an open AI inference accelerator on sky130. Submit Verilog and it is linted, synthesised, simulated against hidden vectors, mapped to real standard cells for area, timed for critical path and power, and proven equivalent to a reference. No key, no account, one call. The best verified design gets fabricated.
Run, build, and validate firmware on virtual hardware from your AI agent. Hardware knowledge corpus.
Change-aware CI validation and affected-test guidance for coding agents.
Related MCP Servers
- AlicenseCqualityFmaintenanceEnables RTL simulation and hardware verification with Verilator through automatic testbench generation, natural language queries about simulations, waveform analysis, and protocol-aware testing for Verilog/SystemVerilog designs.44MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to perform Electronic Design Automation (EDA) tasks including Verilog synthesis, simulation, ASIC design flows, and waveform analysis through a unified interface.6ISC
- AlicenseNot gradedqualityCmaintenanceProvides LLMs and AI agents safe, structured, read-only access to verification artifacts for deterministic triage and root-cause analysis. Supports UVM, cocotb, and SystemVerilog verification ecosystems.35 PyPI7Apache 2.0
- AlicenseAqualityBmaintenanceEnables AI coding agents and IDEs to lint, compile, syntax-check, and simulate Verilog/SystemVerilog designs through structured, token-efficient MCP tools with isolated containerized toolchains.415 npmApache 2.0