{"id":35797497,"url":"https://github.com/sdcb/csharp-runner","last_synced_at":"2026-01-24T14:22:40.724Z","repository":{"id":303390366,"uuid":"1015111024","full_name":"sdcb/csharp-runner","owner":"sdcb","description":"fast, secure c# runner","archived":false,"fork":false,"pushed_at":"2025-12-18T07:49:44.000Z","size":103,"stargazers_count":104,"open_issues_count":0,"forks_count":15,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-22T12:54:50.290Z","etag":null,"topics":["csharp","mcp","mcp-server"],"latest_commit_sha":null,"homepage":"https://csharp.starworks.cc","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sdcb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-07T02:54:56.000Z","updated_at":"2026-01-21T12:58:20.000Z","dependencies_parsed_at":"2025-07-30T03:31:16.147Z","dependency_job_id":"3635d731-9560-44a3-9c47-071d4461ef32","html_url":"https://github.com/sdcb/csharp-runner","commit_stats":null,"previous_names":["sdcb/csharp-runner"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sdcb/csharp-runner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdcb%2Fcsharp-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdcb%2Fcsharp-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdcb%2Fcsharp-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdcb%2Fcsharp-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sdcb","download_url":"https://codeload.github.com/sdcb/csharp-runner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sdcb%2Fcsharp-runner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28729535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","mcp","mcp-server"],"created_at":"2026-01-07T10:00:54.766Z","updated_at":"2026-01-24T14:22:40.719Z","avatar_url":"https://github.com/sdcb.png","language":"C#","funding_links":[],"categories":["📚 Projects (2474 total)"],"sub_categories":["MCP Servers"],"readme":"# 🚀 C\\# Runner\n\n[![.NET 10](https://img.shields.io/badge/.NET-10.0-512BD4.svg)](https://dotnet.microsoft.com/download/dotnet/10.0)\n[![Docker-Host](https://img.shields.io/docker/v/sdcb/csharp-runner-host?sort=semver\u0026logo=docker\u0026label=host)](https://hub.docker.com/r/sdcb/csharp-runner-host)\n[![Docker-Worker](https://img.shields.io/docker/v/sdcb/csharp-runner-worker?sort=semver\u0026logo=docker\u0026label=worker)](https://hub.docker.com/r/sdcb/csharp-runner-worker)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n\n**English** | [中文](./README_CN.md)\n\nC\\# Runner is a high-performance and secure platform for executing C\\# code online. It's built on a Host-Worker architecture that isolates code execution in Docker containers and supports dual protocols: HTTP and MCP (Model Context Protocol).\n\n## ✨ Core Features\n\n  - **🔒 Secure \u0026 Reliable**\n\n      - **Container Isolation**: Untrusted code runs in isolated Docker Worker containers, ensuring host safety.\n      - **Resource Limits**: Supports CPU, memory, and execution timeout limits to prevent resource abuse.\n      - **Network Isolation**: Worker containers have restricted network access.\n\n    \u003c!-- end list --\u003e\n\n      * **Worker Recycling**: Automatically recycles a Worker instance after a configured number of runs to maintain a clean environment.\n\n  - **⚡ High-Performance**\n\n      - **Worker Warm-up**: Pre-compiles code on startup to ensure optimal performance from the very first run.\n      - **Load Balancing**: Distributes tasks among multiple Workers using a Round-Robin algorithm.\n      - **Connection Pooling**: Reuses HttpClient instances to reduce network overhead.\n\n  - **🌐 Rich Functionality**\n\n      - **Dual Protocol Support**: Offers both an HTTP REST API and an MCP interface.\n      - **Streaming Output**: Streams code output, results, and errors in real-time using Server-Sent Events (SSE).\n      - **User-friendly Web UI**: Features a clean code editor with syntax highlighting and `Ctrl+Enter` shortcut for execution.\n      - **Out-of-the-Box**: Provides a complete Docker Compose solution for one-click deployment.\n\n## 🚀 Quick Start\n\n**Prerequisites:**\n\n  * Docker and Docker Compose\n\n**One-Click Deploy with Docker Compose:**\n\n```bash\n# Download the docker-compose.yml file\ncurl -L https://raw.githubusercontent.com/sdcb/csharp-runner/refs/heads/master/docker-compose.yml -o docker-compose.yml\n\n# Start the services in detached mode\ndocker compose up -d\n```\n\nFor Windows:\n\n```bash\n# Download the docker-compose.yml file\nInvoke-WebRequest -Uri \"https://raw.githubusercontent.com/sdcb/csharp-runner/refs/heads/master/docker-compose.yml\" -OutFile \"docker-compose.yml\"\n\n# Start the services in detached mode\ndocker compose -p csharp-runner up -d\n```\n\nOnce deployed, open your browser to `http://localhost:5050` to access the web UI.\n\n## 🔧 Configuration\n\n### Docker Compose\n\nThe `docker-compose.yml` file defines the Host and Worker services. You can scale the number of Workers by changing `deploy.replicas` and configure Worker behavior via `environment` variables.\n\n```yml\nservices:\n  host:\n    image: sdcb/csharp-runner-host:latest\n    container_name: csharp-runner-host\n    ports:\n      - \"5050:8080\"\n    restart: unless-stopped\n\n  worker:\n    image: sdcb/csharp-runner-worker:latest\n    environment:\n      - MaxRuns=2           # Max runs per worker (0=unlimited)\n      - Register=true       # Auto-register to the Host\n      - RegisterHostUrl=http://host:8080\n      - WarmUp=false        # Enable warm-up (recommended for standalone deployment)\n    restart: unless-stopped\n    depends_on:\n      - host\n    deploy:\n      replicas: 3\n      resources:\n        limits:\n          cpus: 0.50\n          memory: 256M\n          pids: 32\n        reservations:\n          cpus: 0.25\n          memory: 128M\n```\n\n### Worker Environment Variables\n\n| Parameter         | Description                                                        | Default         |\n| ----------------- | ------------------------------------------------------------------ | --------------- |\n| `MaxRuns`         | The maximum number of times a Worker can execute code (0=unlimited). | `0`             |\n| `Register`        | Whether to auto-register to the Host service.                      | `false`         |\n| `RegisterHostUrl` | The registration URL of the Host service.                          | `http://host`   |\n| `ExposedUrl`      | The externally exposed URL of the Worker (optional).               | `null`          |\n| `WarmUp`          | Whether to perform a warm-up on startup.                           | `false`         |\n| `MaxTimeout`      | Maximum execution timeout in milliseconds.                         | `30000`         |\n\n## 📡 API Usage\n\n### HTTP API (SSE)\n\nExecute code by sending a POST request to `/api/run`. The response is streamed as Server-Sent Events (SSE).\n\n**Request**\n\n```http\nPOST /api/run\nContent-Type: application/json\n\n{\n  \"code\": \"Console.WriteLine(\\\"Hello, World!\\\"); return 42;\",\n  \"timeout\": 30000\n}\n```\n\n**Response Stream**\n\n```http\ndata: {\"kind\":\"stdout\",\"stdOutput\":\"Hello, World!\"}\n\ndata: {\"kind\":\"result\",\"result\":42}\n\ndata: {\"kind\":\"end\",\"elapsed\":150,\"stdOutput\":\"Hello, World!\",\"stdError\":\"\"}\n```\n\n### MCP Protocol\n\nThe MCP endpoint is at `/mcp` and supports the `run_code` tool.\n\n**Request Example**\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"run_code\",\n    \"arguments\": {\n      \"code\": \"Console.WriteLine(\\\"Hello from MCP!\\\");\"\n    }\n  },\n  \"id\": 1\n}\n```\n\n## 🏗️ Architecture \u0026 Development Guide\n\n### System Architecture\n\n  - **Host**: Provides the public API and web UI. It receives requests, manages a pool of Workers, and handles load balancing.\n  - **Worker**: Runs in an isolated sandbox environment, responsible for executing the C\\# code and returning the result.\n\n### Project Structure\n\n```\nsrc/\n├── Sdcb.CSharpRunner.Host/     # Host Service (ASP.NET Core)\n├── Sdcb.CSharpRunner.Worker/   # Worker Service (Console App)\n└── Sdcb.CSharpRunner.Shared/   # Shared Library (DTOs, etc.)\n```\n\n### Local Development\n\n1.  **Run the Host Service**\n\n    ```bash\n    cd src/Sdcb.CSharpRunner.Host\n    dotnet run\n    ```\n\n2.  **Run the Worker Service**\n\n    ```bash\n    cd src/Sdcb.CSharpRunner.Worker\n    dotnet run\n    ```\n\n### Building Custom Images\n\n```bash\n# Build the Host image\ndotnet publish ./src/Sdcb.CSharpRunner.Host/Sdcb.CSharpRunner.Host.csproj -c Release /t:PublishContainer /p:ContainerRepository=csharp-runner-host\n\n# Build the Worker image\ndotnet publish ./src/Sdcb.CSharpRunner.Worker/Sdcb.CSharpRunner.Worker.csproj -c Release /t:PublishContainer /p:ContainerRepository=csharp-runner-worker\n```\n\n## 🤝 Contributing\n\nContributions via Issues and Pull Requests are welcome\\! Please follow these steps:\n\n1.  Fork the repository\n2.  Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3.  Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4.  Push to the branch (`git push origin feature/AmazingFeature`)\n5.  Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://www.google.com/search?q=LICENSE) file for details.\n\n-----\n\n⭐ If you find this project helpful, please give it a star\\!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdcb%2Fcsharp-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdcb%2Fcsharp-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdcb%2Fcsharp-runner/lists"}