Skip to main content
Glama
Turbo C MCP Server
by BBSRGUY

๐Ÿ’พ What is this?

Turbo C MCP Server hands your AI assistant a genuine Borland Turbo C 3.0 toolchain over the Model Context Protocol. Your LLM doesn't simulate C anymore โ€” it compiles and runs the real thing on the same 16-bit compiler a generation of programmers grew up on, and gets back true output, real Borland diagnostics, and cycle-accurate timing.

Ask Claude to "write a prime sieve in C and run it" โ€” and it actually does, on TCC.EXE. Errors are real. exit 0 is earned.

flowchart LR
    A["๐Ÿง  LLM / Claude"] -- MCP stdio --> B["โš™๏ธ turboc-mcp-server"]
    B -- TCC.EXE --> C["๐Ÿ“€ Borland Turbo C 3.0"]
    C -- .EXE --> D["๐Ÿ–ฅ๏ธ DOS runtime / DOSBox"]
    D -- stdout ยท exit code ยท timing --> B
    B -- structured result --> A
    style A fill:#00c853,stroke:#eafff3,color:#04150d
    style B fill:#0b3d2e,stroke:#00e5ff,color:#eafff3
    style C fill:#ffb300,stroke:#0b0f14,color:#0b0f14
    style D fill:#37474f,stroke:#00e5ff,color:#eafff3

Related MCP server: dosbox-mcp

โœจ Why it goes further than "run my C"

๐Ÿ›  It's a studio, not a button

Twelve composable tools: compile-only checks, a static analyzer that runs without a compiler, an error explainer, an assembly disassembler, a benchmark harness, and a self-healing doctor.

๐Ÿง  Structured, model-friendly output

Every compile is parsed into error/warning objects with file + line, so your LLM can fix code surgically instead of squinting at raw logs.

๐ŸŽฎ Batteries + nostalgia included

A built-in library of 12 classic programs โ€” Fibonacci, prime sieve, Towers of Hanoi, BGI graphics, conio colors โ€” exposed as MCP resources.

๐Ÿ“ฆ Runs on modern Windows

16-bit TCC.EXE can't run on 64-bit Windows? The included DOSBox bridge wrappers make compile and run work anywhere. One env var each.


๐Ÿš€ Quick Start

1 ยท Prerequisites

  • Node.js โ‰ฅ 18

  • Borland Turbo C 3.0 at C:\TURBOC3 (or set TURBOC_ROOT)

  • 64-bit Windows? Also grab DOSBox โ†’ see DOSBox setup

2 ยท Install & build

git clone https://github.com/BBSRguy/turboc-mcp-server.git
cd turboc-mcp-server
npm install
npm run build

3 ยท Wire it into your MCP client

{
  "mcpServers": {
    "turboc": {
      "command": "node",
      "args": ["C:/path/to/turboc-mcp-server/build/server.js"],
      "env": {
        "TURBOC_ROOT": "C:\\TURBOC3"
        // On 64-bit Windows, add the DOSBox bridge (see docs/DOSBOX.md):
        // "TCC_COMMAND": "C:\\TURBOC3\\wrappers\\dosbox-tcc.bat",
        // "MCP_C_RUN_COMMAND": "C:\\TURBOC3\\wrappers\\dosbox-run.bat"
      }
    }
  }
}
claude mcp add turboc -- node C:/path/to/turboc-mcp-server/build/server.js

4 ยท Say hello

You: "Use turboc to run the hello example." AI: calls run_example โ†’ Hello, Turbo C! Compiled on real DOS iron. โœ” exit 0

Not sure it's wired up? Ask it to run environment_doctor โ€” it verifies your whole toolchain and tells you exactly what's missing.


๐Ÿงฐ The toolbox (12 tools)

#

Tool

What it does

1

๐ŸŸข compile_and_run

Compile with TCC.EXE and run the DOS .EXE; capture stdout/stderr, exit code, timing, diagnostics

2

๐Ÿ”Ž compile_check

Compile-only syntax/semantic check โ€” fast, no execution

3

๐Ÿงช analyze_code

Static analysis without compiling: gets(), scanf &, = in if, brace balance, missing main, malloc checks, float-I/O traps

4

๐Ÿ“– explain_error

Plain-English cause + fix for any Turbo C compiler / linker / runtime message

5

โš™๏ธ generate_asm

Emit the 16-bit x86 assembly listing (TCC -S) for any snippet

6

๐Ÿ“š list_examples

Browse the classic-program library (filter by category)

7

๐Ÿ“„ get_example

Fetch the full source of any example

8

โ–ถ๏ธ run_example

Compile and run an example in one shot

9

โฑ๏ธ benchmark

Run the program N times; report min / avg / max ms

10

๐ŸŽจ format_code

Re-indent by brace depth, tidy whitespace โ€” zero deps

11

๐Ÿฉบ environment_doctor

Verify TCC, INCLUDE, LIB, BGI, workspace โ€” with fix hints

12

๐Ÿงน clean_workspace

Sweep old scratch sessions; keep the N most recent

Plus MCP resources (turboc://environment, turboc://examples/*) and prompts (debug-c-error, optimize-c, explain-program).


๐ŸŽฎ Examples

The bundled library (list_examples) covers every corner of the DOS C world:

Category

Programs

๐ŸŸฉ basics

hello, fibonacci

๐Ÿงฎ algorithms

prime-sieve, bubble-sort, hanoi, matrix-multiply

๐ŸŽจ graphics

bgi-graphics (concentric circles via EGAVGA.BGI)

๐Ÿ’ฝ dos

file-io, conio-colors

๐Ÿ—‚ data

student-records (structs)

๐Ÿ•น fun

pascal-triangle, number-guess

โ–ถ  run_example { "id": "prime-sieve" }

Compile: โœ“ success  (312 ms, exit 0)
=== Run phase ===
Result: โœ“ exit 0  (44 ms)
--- program stdout ---
Primes up to 100:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

โš™๏ธ Configuration

Everything is environment-driven, so one build works on every setup.

Variable

Default

Purpose

TURBOC_ROOT

C:\TURBOC3

Turbo C install root

TCC_COMMAND

โ€ฆ\BIN\TCC.EXE

Compiler entry point (or a DOSBox .bat)

MCP_C_RUN_COMMAND

(unset)

Wrapper to launch the compiled .EXE (DOSBox bridge)

TURBOC_INCLUDE

โ€ฆ\INCLUDE

Header search path

TURBOC_LIB

โ€ฆ\LIB

Library search path

TURBOC_BGI

โ€ฆ\BGI

BGI graphics drivers

MCP_C_WORKROOT

โ€ฆ\mcp_work

Scratch directory for sessions

MCP_C_TIMEOUT_MS

5000

Per-run execution timeout

MCP_C_COMPILE_TIMEOUT_MS

10000

Per-compile timeout

MCP_C_MAX_OUTPUT_BYTES

65536

Output cap returned to the model


๐Ÿ— Architecture

graph TD
    S[server.ts<br/>tools ยท resources ยท prompts] --> T[turboc.ts<br/>compile ยท run ยท asm ยท doctor]
    S --> A[analyze.ts<br/>heuristic linter]
    S --> E[errors-db.ts<br/>error knowledge base]
    S --> X[examples.ts<br/>classic programs]
    S --> F[format.ts<br/>C reformatter]
    T --> D[diagnostics.ts<br/>parse TCC output]
    T --> U[util.ts<br/>spawn ยท timeout ยท shell bridge]
    T --> C[config.ts<br/>env-driven paths]
    style S fill:#00c853,stroke:#04150d,color:#04150d
    style T fill:#0b3d2e,stroke:#00e5ff,color:#eafff3

Clean, single-responsibility modules โ€” easy to read, easy to extend.


๐Ÿ—บ Roadmap

  • Multi-file / project compilation

  • BGI graphics โ†’ PNG capture via DOSBox screenshots

  • Turbo Assembler (TASM) round-trip

  • Memory-model presets (tiny/small/large) as first-class options

  • npm one-line install (npx turboc-mcp-server)

  • Watch mode + hot examples gallery on the website

Ideas welcome โ€” open an issue or PR.


๐Ÿค Contributing

PRs are warmly welcome. Fork โ†’ branch โ†’ npm run build โ†’ PR. New examples and error-DB entries are especially appreciated; see CONTRIBUTING.md.


โญ Star history

If this brought a little 1992 magic to your AI, drop a โญ โ€” it genuinely helps.


๐Ÿ‘ค Author

BBSRguy ยท @BBSRguy ยท rasran90@yahoo.com

Built for everyone who still hears the clrscr() flicker in their dreams. ๐Ÿ•น๏ธ

Available Tools

12 tools
analyze_codeA

Static analysis of C source WITHOUT compiling: flags unsafe gets(), scanf-missing-&, assignment-in-if, unbalanced braces, missing main(), unchecked malloc, Turbo C float I/O pitfalls, and more. Instant, no toolchain required.

Inputs: code (required).

benchmarkA

Compile once, then run the program N times (default 5) and report min/max/avg execution time in milliseconds. Useful for comparing algorithm variants on the real DOS runtime.

Inputs: code (required), runs, stdin, filename, +1 more.

clean_workspaceA

Delete old scratch session directories created by compiles/runs. Optionally keep the N most recent. Frees disk and keeps the DOS work root tidy.

Inputs: keep.

compile_and_runA

Compile C code with Borland Turbo C (TCC.EXE) and run the resulting DOS executable, capturing stdout/stderr, exit code, timing, and structured diagnostics. The everyday workhorse.

Inputs: code (required), stdin, filename, extraCompilerArgs.

compile_checkA

Compile-only syntax/semantic check (no execution). Returns structured errors and warnings with line numbers โ€” perfect for fast iteration and CI-style validation.

Inputs: code (required), filename, extraCompilerArgs.

environment_doctorA

Inspect the Turbo C toolchain: verify TCC.EXE, INCLUDE, LIB, and BGI paths, count available headers, report workspace sessions, and list any problems with fix hints. Run this first if compiles fail.

Inputs: no named parameters.

explain_errorA

Look up a Turbo C / Borland compiler, linker, or runtime message and get a plain-English cause + concrete fix. Feed it the raw error text (e.g. "Undefined symbol 'x' in function main").

Inputs: message (required).

format_codeA

Reformat C source: re-indent by brace depth, tidy trailing whitespace, and collapse blank-line runs. Dependency-free; returns the formatted code.

Inputs: code (required), indent.

generate_asmA

Compile C to a Turbo C assembly listing (TCC -S) and return the generated .ASM. Great for teaching how C maps to 16-bit x86, inspecting codegen, or optimization study.

Inputs: code (required), filename, extraCompilerArgs.

get_exampleA

Return the full C source of a built-in example by id (see list_examples).

Inputs: id (required).

list_examplesB

Browse the built-in library of classic Turbo C programs (hello, Fibonacci, prime sieve, bubble sort, Towers of Hanoi, structs, file I/O, conio colors, BGI graphics, matrix multiply, number-guessing game, Pascal's triangle). Returns ids you can run.

Inputs: category.

run_exampleA

Compile and run a built-in example by id in one shot (uses its sample stdin when defined).

Inputs: id (required), stdin.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    A4.1/5.0

    Scored across 12 tools

    Disambiguation5/5

    Each tool serves a distinct purpose. For example, analyze_code performs static analysis without compiling, while compile_check is a compile-only syntax check. There is no overlap that would confuse an agent.

    Naming Consistency4/5

    Most tool names follow a verb_noun pattern (e.g., analyze_code, format_code). However, 'benchmark' is a single noun and 'environment_doctor' deviates slightly, introducing minor inconsistency.

    Tool Count5/5

    With 12 tools, the set is well-scoped for a Turbo C development server. Each tool covers a necessary operation without bloat or triviality.

    Completeness5/5

    The tool surface covers the entire workflow: analysis, compilation, execution, benchmarking, error explanation, formatting, assembly generation, environment diagnosis, and example management. No obvious gaps.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to code and debug Commodore PET software using the VICE emulator, with CLI and MCP tools for session control, screen reading, memory manipulation, and testing.
      44
      1
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      This MCP server enables AI agents to inspect and control the native DOSBox-X debugger through bounded MCP tools, including breakpoint management, execution control, register/memory inspection, and disassembly for DOS program debugging and reverse engineering.
      1
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to run CP/M, MP/M, and DOS packages on Z80/x86 emulators, inspect byte-exact results and files, and debug the emulators themselves over the Model Context Protocol.
      7
      GPL 3.0