Skip to main content
Glama
README.md
# Turbostar — Verilog/FPGA & Systems MCP Servers, Agentic Framework & Terminal IDE

Turbostar is an open-source **C++23** developer platform uniting three tightly integrated workflows in one codebase:

1. **Verilog, SystemVerilog & FPGA MCP Server (`turbostar-verilog mcp`)** — A focused 21-tool Model Context Protocol (MCP) server and standalone CLI built around the **agentic hardware inner loop** (Verilator, Yosys, SymbiYosys, `nextpnr`, VCD waveforms, formal mutation testing, timing closure, and switching-activity power profiling).
2. **C/C++ & Linux Kernel Systems MCP Server (`turbomcp`)** — A 60+ tool MCP server bringing LSP X-ray codemaps, Semcode B-tree kernel indexing, automated GDB coredump analysis, cycle-accurate CPU `perf` profiling, and ELF/hex inspection into Claude Code, Gemini CLI, Cursor, VS Code, and Antigravity.
3. **Classic Terminal IDE & Built-In Agent Workspace (`turbostar`)** — A Turbo Pascal–inspired TUI editor with WordStar/Joe keybindings, live LSP diagnostics, Git integration, virtual paged AI context, and atomic undo/redo.

- **Website:** [https://www.turbostar.ai/](https://www.turbostar.ai/)
- **FPGA & Verilog Deep Dive:** [https://www.turbostar.ai/fpga.html](https://www.turbostar.ai/fpga.html)
- **SystemVerilog Agent Playbook (`AGENTS.md`):** [https://www.turbostar.ai/systemverilog-agents.md](https://www.turbostar.ai/systemverilog-agents.md)
- **Systems MCP Server Guide:** [https://www.turbostar.ai/mcp.html](https://www.turbostar.ai/mcp.html)

---

## Model Context Protocol (MCP) Implementation

Turbostar implements the **Model Context Protocol (JSON-RPC 2.0 over `stdio`)** natively in C++23 with zero Node.js or Python runtime dependencies:

| Component | Source Files | Capabilities |
|---|---|---|
| **Core MCP Protocol Engine** | [`src/mcp/mcp_stdio_server.h`](src/mcp/mcp_stdio_server.h), [`src/mcp/mcp_stdio_server.cpp`](src/mcp/mcp_stdio_server.cpp) | Handles `initialize` (with workflow `instructions`), `notifications/initialized`, `tools/list`, `tools/call`, `resources/list`, `resources/read`, and `ping`. Auto-adapts tool parameter casing (`snake_case`, `camelCase`, `PascalCase`) from MCP `clientInfo`. |
| **Verilog / FPGA MCP Server (`turbostar-verilog mcp`)** | [`src/verilog_cli_tool_main.cpp`](src/verilog_cli_tool_main.cpp), [`src/plugins/verilog/`](src/plugins/verilog/) | Statically linked 21-tool stdio MCP server (16 hardware/VCD tools + 5 read/task companions) and MCP Resource provider (`system://verilog/*`). |
| **Systems MCP Server (`turbomcp` / `turbostar --mcp`)** | [`src/mcp/turbomcp_server.h`](src/mcp/turbomcp_server.h), [`src/mcp/turbomcp_server.cpp`](src/mcp/turbomcp_server.cpp) | Full 60+ tool stdio MCP server with LSP X-ray, Semcode indexing, GDB crashdump analysis, CPU `perf` profiling, ELF/hex tools, and dynamic plugin families. |
| **MCP Client Setup Wizard** | [`src/mcp/mcp_client_setup.h`](src/mcp/mcp_client_setup.h), [`src/mcp/mcp_client_setup.cpp`](src/mcp/mcp_client_setup.cpp) | `turbostar-verilog setup` and `turbomcp setup` auto-detect and safely merge configs for Claude Code, Claude Desktop, Gemini CLI, Antigravity, Cursor, and VS Code. |
| **Container & Registry Manifests** | [`Dockerfile`](Dockerfile), [`glama.json`](glama.json), [`server.json`](server.json), [`server-turbomcp.json`](server-turbomcp.json) | Pure Debian Trixie multi-stage OCI build (default `ENTRYPOINT ["turbostar-verilog", "mcp"]`) and official MCP Registry manifests (`ai.turbostar/*`). |

---

## 1. Verilog, SystemVerilog & FPGA MCP Server (`turbostar-verilog mcp`)

Most EDA MCP servers are thin CLI wrappers that shell out to Verilator or Yosys and dump raw logs into the LLM's context. **`turbostar-verilog` is built around the three primitives every agentic hardware loop needs**:

1. **Objective Measurement (Scoreboard):** Fast, low-noise metrics against explicit goals — multi-seed median $F_{\max}$ vs. target MHz, line coverage %, Formal % / Combined % mutation kill rates, post-synthesis weighted toggles/cycle, and functional PASS/FAIL + `.lastpass.vcd` diffs.
2. **Actionable Breadcrumbs (Direction):** Native C++23 post-tool analysis turns raw waveforms, netlists, and timing graphs into exact `file.sv:line` RTL snippets, LUT depth cones, routed wire hotspots, enum-decoded VCD tables, and surviving-mutant gap lists.
3. **Proactive Guardrails (Tripwires):** Routine calls automatically detect regressions and trigger the right fix loop — reporting $F_{\max}$ during compile/synthesis, auditing formal suites for vacuous `assume`-without-`cover` or unchecked outputs, and auto-diffing every simulation against `.lastpass.vcd` with AXI/handshake protocol checks.

### MCP Tools Exposed by `turbostar-verilog mcp` (16 Hardware/VCD + 5 Companions)

| Category | Tool | Description |
|---|---|---|
| **Config & Mapping** | `verilog_project_settings` | Inspects host EDA toolchain status (`verilator`, `verilator_coverage`, `yosys` + `slang` plugin, `nextpnr-*`, `sby`, SMT solvers, versions, paths, setup hints) and reads/updates `turbostar.json`. |
| **Config & Mapping** | `verilog_project_map` | Maps the RTL module instantiation hierarchy, ports/parameters, `.mermaid` FSM diagrams, testbench bindings, and formal status. |
| **Config & Mapping** | `verilog_configure_testbench` | Scans and binds testbenches to RTL modules with test tiers (`quick`, `comprehensive`, `extreme`) and hierarchical defaults. |
| **Lint & Synthesis** | `verilog_compile` | Hierarchy-scoped Verilator static lint (`lint_only=true`, ~0.13s) and Yosys synthesis + `nextpnr` check, separating correctness hazards from style notes. |
| **Simulation & Power** | `verilog_simulate` | Parallel bottom-up Verilator regression with automatic `.previous.vcd` / `.lastpass.vcd` streaming diffing, RTL line/port/toggle coverage (`coverage=true`), and post-synthesis gate-level switching-activity power profiling (`gate_toggles=true`). |
| **Formal & Mutation** | `verilog_formal` | Runs SymbiYosys (`prove`, `bmc`, `cover`) on `formal/*_props.sv` `bind` modules with vacuity/unchecked-output audits, counterexample VCDs, and native Yosys mutation testing (`mode="mutate"` / `mode="gaps"`). |
| **Timing & PnR** | `verilog_logic_depth` | Pre-PnR combinational LUT depth cones (`Reg -> Reg`, `In -> Reg`, `Reg -> Out`), carry chains, and cell area attributed to exact `file.sv:line` RTL statements. |
| **Timing & PnR** | `verilog_update_timing` | Writes aligned, in-place `// [timing: ...]` port delay annotations directly into `.sv` module headers. |
| **Timing & PnR** | `verilog_pnr_timing` | Runs multi-seed `nextpnr` physical place-and-route (`ice40`, `ecp5`, `generic`), reports median $F_{\max}$ and slack, and correlates routed critical paths back to RTL source lines. |
| **VCD Waveforms** | `vcd_file_info` | Inspects VCD scopes, timescale, detected clocks, and flags zero-toggle (`**`) inactive nets. |
| **VCD Waveforms** | `vcd_wave` | Clock-aligned Markdown waveform tables with live `typedef enum` decoding, qualifier masking, and idle-cycle collapsing. |
| **VCD Waveforms** | `vcd_search` | Searches traces for multi-signal boolean expressions or edge conditions. |
| **VCD Waveforms** | `vcd_compare` | Sub-100 ms streaming cycle-accurate diff between two VCDs with first-divergence tick and protocol violation context. |
| **VCD Waveforms** | `vcd_signal_labels` | Maps raw bus/state values to readable enum names or instruction mnemonics. |
| **VCD Waveforms** | `vcd_signal_qualifier` | Masks invalid bus cycles (e.g. `valid == 0`) so tables and diffs focus only on active transactions. |
| **VCD Waveforms** | `vcd_signal_to_code` | Traces any VCD signal back to its RTL drivers and sinks. |
| **Companions (5)** | `manage_task`, `fs_read_lines`, `fs_batch_read`, `fs_list_dir`, `fs_grep_files` | Bounded-wait async task control (`wait_any`) and minimal read-only workspace inspection without conflicting with host agent tools. |

### MCP Resources Exposed (`resources/list` & `resources/read`)
- `system://verilog/AGENTS.md` — Battle-tested SystemVerilog & FPGA agent workflow playbook (also installable via `turbostar-verilog config --init-agents-md` and readable at [docs/systemverilog-agents.md](docs/systemverilog-agents.md)).
- `system://verilog/bram_template.sv` & `system://verilog/formal_template.sv` — Clean synchronous BRAM and `bind` formal property templates.
- Live post-run reports: `system://verilog/coverage.md`, `system://verilog/toggles.md`, `system://verilog/gate_toggles.md`, `system://verilog/formal.md`, `system://verilog/formal_mutation.md`, `system://verilog/synthesis.log`, and `system://tasks/index.md`.

### Quick Start: `turbostar-verilog mcp`

```bash
# Option A: Build locally and run the interactive MCP client setup wizard
meson setup build && meson install -C build
turbostar-verilog setup            # registers Claude Code, Gemini CLI, Antigravity, Cursor, VS Code
turbostar-verilog tool-status      # verify installed Verilator, Yosys, nextpnr, sby, SMT solvers

# Option B: Run via Docker / Podman
podman build -t turbostar-verilog .
podman run -i --rm -v "$PWD:/workspace" turbostar-verilog
```

Manual MCP client config (`mcp.json` / `claude_desktop_config.json` / `~/.gemini/config/mcp_config.json`):
```json
{
  "mcpServers": {
    "turbostar-verilog": {
      "command": "turbostar-verilog",
      "args": ["mcp"]
    }
  }
}
```

---

## 2. C/C++ & Linux Kernel Systems MCP Server (`turbomcp`)

`turbomcp` (or `turbostar --mcp`) exposes **60+ native systems engineering tools** over stdio JSON-RPC 2.0:

- **LSP X-Ray & Instant Codemaps:** `fs_read_lines`, `fs_read_symbol`, `fs_file_codemap`, and `fs_grep_files` surface enclosing symbols, called dependencies, and companion header definitions automatically.
- **Semcode Linux Kernel Indexing:** Sub-10 ms SQLite B-tree symbol and call-graph queries on monolithic repositories.
- **Automated Crash & Live GDB Debugging:** `crashdump_get_info` extracts symbolicated backtraces and faulting instructions; `run_executable(debugger=true)` drives live interactive GDB sessions.
- **Cycle-Accurate CPU Profiling & Binary Tools:** `perf_profile_summary`, `perf_profile_detail`, `elf_list_symbols`, `elf_list_sections`, `hexdump`, and `hexinspect`.
- **On-Demand Plugin Families:** Activate the full Verilog/FPGA suite (`activate_tool_family("verilog")`) or security scanners dynamically.

```bash
# Register turbomcp with your AI coding client
turbomcp setup
```

See [docs/one-pager-mcp.md](docs/one-pager-mcp.md), [docs/one-pager-verilog.md](docs/one-pager-verilog.md), and [docs/tools.md](docs/tools.md) for the complete tool reference.

---

## 3. Terminal IDE & Built-In Agentic Workspace (`turbostar`)

Turbostar also runs as a responsive terminal-based (TUI) IDE with the classic look and feel of Turbo Pascal, modernized with WordStar/Joe keybindings, live LSP diagnostics, Git integration, and an embedded multi-agent workspace (`^K A`).

![Turbostar Welcome Screenshot](docs/screenshot-welcome.png)

### Key Highlights
- **Classic TUI Workspace:** Turbo Pascal aesthetics, visual split windows, WordStar/Joe keybindings (`^KB`/`^KK`, `^KO`, `^KS`, `^KH`), live LSP (`clangd`, `pylsp`/`pyright`), and Git branch/dirty status in window titles.
- **Virtual Paged AI Context:** Dynamically pages context in and out at multiple fidelity levels (full, think-removed, tool-call reduced) rather than discarding history via lossy compaction.
- **Atomic Undo/Redo & Security Sandbox:** Every AI edit is reviewable in the [undo history view](docs/screenshot-agent-undo-view.png) and undoable atomically; all tools run under strict path canonicalization, regular-file checks, shell-argument escaping, and optional `bandit` Python scanning.

### Key Quick Reference

| Action | WordStar/Joe Key | Alternate/Ncurses Key |
| :--- | :--- | :--- |
| **Open Menu Bar** | — | `F10` or `Esc` |
| **Open File Dialog** | `^K O` | `F3` |
| **Save Current File** | `^K S` | `F2` |
| **Open Agent Chat** | `^K A` | — |
| **Open Diff / Undo View** | `^K H` | — |
| **Mark Block Start / End** | `^K B` / `^K K` | — |
| **Exit Editor** | `^K Q` | `Alt+X` |

### Image Gallery

<a href="docs/screenshot-editfile.png"><img src="docs/screenshot-editfile.png" width="230" alt="Multi-Window Editing" /></a>
<a href="docs/screenshot-debugger.png"><img src="docs/screenshot-debugger.png" width="230" alt="Interactive Debugger" /></a>
<a href="docs/screenshot-compile.png"><img src="docs/screenshot-compile.png" width="230" alt="Compile Output" /></a>
<a href="docs/screenshot-agent-undo-view.png"><img src="docs/screenshot-agent-undo-view.png" width="230" alt="Agent Undo View" /></a>
<a href="docs/screenshot-inline-agent.png"><img src="docs/screenshot-inline-agent.png" width="230" alt="Inline Agent" /></a>
<a href="docs/screenshot-inline-agent-codereview.png"><img src="docs/screenshot-inline-agent-codereview.png" width="230" alt="Inline Code Review" /></a>
<a href="docs/screenshot-agent-edits-the-program.png"><img src="docs/screenshot-agent-edits-the-program.png" width="230" alt="Agent Program Edit" /></a>
<a href="docs/screenshot-agent-runs-the-testsuite.png"><img src="docs/screenshot-agent-runs-the-testsuite.png" width="230" alt="Agent Running Test Suite" /></a>
<a href="docs/screenshot-agent-reviewed-the-screenshot.png"><img src="docs/screenshot-agent-reviewed-the-screenshot.png" width="230" alt="Agent Reviewing Screenshot" /></a>

---

## Building from Source

Turbostar is written in **C++23** (GCC 14+ / Clang 17+) and uses **Meson** and **Ninja**.

### Debian / Ubuntu Dependencies
```bash
# Build dependencies
sudo apt update
sudo apt install g++ meson ninja-build pkg-config libncursesw5-dev libpcre2-dev \
  nlohmann-json3-dev libcpp-httplib-dev libyaml-cpp-dev libcurl4-openssl-dev \
  libsqlite3-dev libdtl-dev libunwind-dev libmagic-dev liblexbor-dev \
  libgraphicsmagick++1-dev libctre-dev

# Optional Verilog / FPGA EDA runtime toolchain
sudo apt install verilator yosys nextpnr-ice40 fpga-icestorm z3 make

# Optional C/C++ systems runtime helpers
sudo apt install clangd clang-format gdb gdbserver python3-bandit elfutils cppcheck tidy
```

### Compile & Install
```bash
git clone https://github.com/fenrus75/turbostar2.git
cd turbostar2
git submodule update --init --recursive

meson setup build
meson compile -C build
meson install -C build
```

Run the test suite (optional):
```bash
MESON_TESTTHREADS=2 meson test -C build
```

## Known Quirks

- **Mouse Paste in X11:** Hold **Shift** while clicking or dragging to use your terminal emulator's native middle-click paste or highlight-to-copy.
- **Windows Colors:** Under WSL/SSH, use **Windows Terminal (`ms-terminal`)** rather than legacy `xterm` for accurate Turbo Pascal palette rendering.

## License

GPLv3 — see [COPYING-GPLv3](COPYING-GPLv3).