Agent kit (MCP)
cg-agent-kit is a Model Context Protocol
server that hands the C⏚ toolchain to an AI agent. The agent writes C⏚, and
the server compiles, simulates and synthesis-checks it against the real
compiler — instead of the agent producing Verilog that has never been near
a toolchain.
That is the point. An LLM asked for Verilog will confidently emit something that does not build, does not synthesize, or silently folds away to nothing. Here every step is verified by the same compiler a human uses, and errors come back as structured diagnostics the model can act on.
It is a separate package from the VS Code extension — install whichever you need, or both. They drive the same compiler.
Install
pip install cg-agent-kitThen point it at a compiler jar:
export CG_JAR=/path/to/cg-language-server.jarTwo ways to get that jar:
- Open source — download a prebuilt jar from cg-compiler releases, or build it from source. No license required.
- Commercial — the jar inside an installed extension, at
~/.vscode/extensions/neosyn.neosyn-cg-*/server/cg-language-server.jar. This one adds the bytecode Fast Sim and VHDL.
Optional, and worth having — cg_synth and the Icarus simulation backend
shell out to these:
# Debian / Ubuntu
sudo apt install yosys iverilogRequirements: Python 3.10 or newer, and Java 17+ on your PATH for the
jar.
Configure your MCP client
Add the server to your client's config. The shape is the same everywhere:
{
"mcpServers": {
"cg": {
"command": "cg-mcp-server",
"env": { "CG_JAR": "/path/to/cg-language-server.jar" }
}
}
}- Claude Desktop —
claude_desktop_config.json - Cursor / Windsurf — the MCP section of settings
- Claude Code —
claude mcp add cg --env CG_JAR=/path/to/jar -- cg-mcp-server
Restart the client. The agent should now list the cg_* tools below.
Tools
| Tool | What it does |
|---|---|
cg_check | Compile and validate C⏚; structured diagnostics with file:line and the fix |
cg_generate_verilog | Emit synthesizable Verilog (or VHDL, with the commercial jar) |
cg_simulate | Simulate a design — Icarus backend, or the commercial Fast Sim |
cg_synth | Yosys-synthesize the Verilog: REAL / FOLDED / SUSPECT verdict plus cell count |
cg_example | Scored lookup into the validated-code dictionary (28 entries) |
cg_suggest_for_error | Map a compiler error to the recipe carrying the fix pattern |
cg_fsm / cg_graph | A task's compiled state machine, or a network's wiring graph |
cg_docs | C⏚ language and pattern reference packs |
cg_capabilities | What this install can actually do — jar version, backends present |
Two of these are the difference between an agent that guesses and one that converges:
cg_example is a dictionary, not retrieval. All 28 entries compile,
simulate and synthesize. The agent seeds from validated code and adapts it,
rather than inventing from scratch. Lookup is specificity-weighted and
returns runners-up, so an ambiguous query self-corrects.
cg_synth catches the failure that matters. Verilog that compiles can
still synthesize to nothing — a constant folded away, logic optimized out.
The REAL / FOLDED / SUSPECT verdict tells the agent whether it built
hardware or an expensive wire.
Free and commercial
The kit and the compiler it drives are open source. cg_check,
cg_generate_verilog, cg_synth, cg_example, cg_docs and the graph
tools run entirely on the open compiler, with no license.
The only gated piece is simulation speed: cg_simulate's default bytecode
backend is the commercial Fast Sim and will ask you to upgrade, while the
iverilog backend works fully — generate Verilog, run Icarus. If you
want cycle-accurate simulation in seconds without an HDL toolchain, that is
what a license buys.
Verify the install
cg-mcp-server --helpOr drive the verification functions straight from Python, without an MCP client:
from cg_agent_kit import cg_mcp_server as cg
print(cg.check(open("Counter.cg").read()))
print(cg.generate(open("Counter.cg").read()))If cg_capabilities reports your jar version and the backends you
installed, the setup is good.
Next
- Install — the VS Code extension and the standalone CLI
- Quick tutorial — write a counter yourself in ten minutes
- PyPI · source (MIT)