Skip to content

About

πŸš€ Browser-based C# playground and MCP-enabled platform powered by .NET 10 WebAssembly and Roslyn. ✍️ Write, compile, and run C# entirely client-side with πŸ”’ no server, πŸ‘€ no account, and πŸ“¦ no installation. πŸ€– Securely expose MCP tools for AI agents to analyze, execute, and interact with C# code in a zero-trust browser sandbox at scale.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🧩 codedotnet

A browser-based C# playground β€” write, compile, and run C# entirely client-side using the .NET 10 WebAssembly runtime and Roslyn. No server. No account. No install.

.NET 10 React 19 TypeScript Vite MCP License: MIT Deploy

πŸš€ Live demo β†’

πŸ”Œ Also includes an MCP Playground β€” a Model Context Protocol server + in-browser client that exposes compile_and_run as a tool for VS Code, Claude Desktop, and any other MCP-aware client.

codedotnet main editor: Monaco-powered C# editor pane on the left with syntax highlighting, and an output pane on the right showing captured stdout, diagnostics, and timing information


✨ What it does

πŸ“ Monaco-powered editor for a single Program.cs file with C# syntax highlighting, inline diagnostics, and error navigation.
▢️ Click Run to compile and execute your code inside a dedicated Web Worker running Roslyn and the .NET WebAssembly runtime, entirely in your browser.
⌨️ Supply buffered STDIN before running, and see captured stdout/stderr, exceptions, and timing breakdowns (compile / execute / total) in the output pane.
πŸ“Š Automatic time/space Big-O complexity estimate (with rationale) for the code you just ran.
🧱 Resizable, swappable editor/I-O panes, focus modes, and fullscreen support.
πŸ’Ύ Editor preferences, theme (light/dark/system), and layout are persisted locally so your workspace is restored next time you visit.
⚑ Keyboard shortcuts: Ctrl/Cmd+Enter to run, Shift+F5 to stop, Ctrl/Cmd+S to force-save locally, F11 to toggle fullscreen, plus Monaco's native Find/Replace and Undo/Redo.
πŸ›‘ Graceful recovery from runaway programs (e.g. infinite loops): Stop hard-terminates the worker and a fresh one takes its place.
🌐 A clear "unsupported browser" message if required capabilities (WebAssembly, Web Workers, Blob URLs, local storage) are missing, instead of a silent failure.

πŸ”Œ MCP Playground

codedotnet also ships a Model Context Protocol (MCP) server (codedotnet-sandbox/) that exposes the exact same compile_and_run capability as a tool any MCP-aware client (VS Code, Claude Desktop, Cursor, Continue, the browser, or a custom JSON-RPC-over-stdio/WebSocket script) can call β€” reusing the same CodeDotNet.Engine-backed WebAssembly artifact as the main playground, but isolated per-call in a disposable, hard-timeout-enforced child process.

The MCP Playground tab in the web app is an in-browser client for this server over a WebSocket transport (ws://127.0.0.1:7900 by default):

MCP Playground: connected to ws://127.0.0.1:7900, showing the discovered compile_and_run tool, a Singleton pattern C# sample in the editor, and the execution result pane with status, captured output, a nullable-reference warning, timing breakdown, and the raw JSON-RPC tools/call response

πŸ”— Connect to any MCP WebSocket endpoint (defaults to the local sandbox) and see its Connected/Disconnected status live.
🧰 Discovered tools panel lists every tool the server advertises via tools/list, with its description.
πŸ“ Edit a single-file C# program in the same Monaco-powered editor used by the main playground.
▢️ Call compile_and_run invokes the tool over JSON-RPC 2.0 and renders the parsed result: status (e.g. ExecutionCompleted, ExecutionCompletedWithWarnings), captured stdout, diagnostics/warnings with file/line/column, and a build / run / total timing breakdown.
πŸ” A collapsible Raw JSON-RPC tools/call response section shows the exact wire payload for debugging or integrating your own MCP client.

⚠️ Note: The live demo is a static GitHub Pages site and cannot run the MCP WebSocket sandbox server, so the MCP Playground tab will show Disconnected there. The sandbox (codedotnet-sandbox/) is a Node.js process that forks a pool of disposable child processes β€” each cold-booting the .NET WebAssembly runtime (~1.5-2s) β€” to isolate and hard-timeout every compile_and_run call. That's intentionally heavy for a hosted/serverless environment, so it is not deployed; you must run it locally (see below) to get a live MCP connection.

To try it locally:

# Terminal 1: start the MCP WebSocket server (ws://127.0.0.1:7900)
cd codedotnet-sandbox
npm install
npm run serve

# Terminal 2: start the web app
cd codedotnet.web
npm install
npm run dev

Requirements: Node.js 22+ for both processes, and the .NET 10 SDK to publish the codedotnet.compiler browser-wasm artifact the sandbox reuses (one-time step: dotnet publish -c Release codedotnet.compiler/codedotnet.compiler.csproj, or run scripts/copy-worker-assets.ps1).

Open the printed dev server URL, switch to the MCP Playground tab, click Connect, and run the sample program. See codedotnet-sandbox/README.md for the stdio transport, worker-pool isolation model, and instructions for registering the server with VS Code, Claude Desktop, Cursor, Continue, or any other MCP-aware/JSON-RPC client.

🚦 Quick start

Prerequisites: .NET 10 SDK and Node.js 22+.

# Frontend (dev server with hot reload)
cd codedotnet.web
npm install
npm run dev

# Publish the compiler worker once so the frontend can load it locally
npm run build:worker

Then open the printed local URL in your browser.

To produce a production build (as used for GitHub Pages deployment):

cd codedotnet.web
npm run build:worker:release
npm run build

πŸ—‚οΈ Repository layout

image
Path Purpose
πŸ–₯️ codedotnet.web/ React + TypeScript + Vite frontend (editor, shell, worker manager, complexity estimator).
βš™οΈ codedotnet.compiler/ .NET 10 browser-wasm project: Roslyn compile host, execution host, JS interop.
βœ… codedotnet.compiler.tests/ xUnit tests for the compiler/execution host logic (linked source, runs natively).
🧰 codedotnet-sandbox/ Node.js MCP server: stdio + WebSocket transports for a sandboxed compile_and_run tool.
πŸ€– .github/workflows/deploy.yml CI validation + GitHub Pages deployment workflow.
πŸ“¦ .github/dependabot.yml Automated weekly dependency updates (npm, NuGet, GitHub Actions).
πŸ“š docs/ Architecture, testing, deployment, security, privacy, limitations, and ADRs.

πŸ“– Documentation

πŸ“œ License

MIT β€” see LICENSE.

About

πŸš€ Browser-based C# playground and MCP-enabled platform powered by .NET 10 WebAssembly and Roslyn. ✍️ Write, compile, and run C# entirely client-side with πŸ”’ no server, πŸ‘€ no account, and πŸ“¦ no installation. πŸ€– Securely expose MCP tools for AI agents to analyze, execute, and interact with C# code in a zero-trust browser sandbox at scale.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages