csharp-code-sandbox-mcp

csharp-code-sandbox-mcp

3.4

C# Code Sandbox MCP is a server that allows for the execution of arbitrary C# scripts. It requires the dotnet-script tool and is inspired by the node-code-sandbox-mcp project.

C# Code Sandbox MCP

A C#–based Model Context Protocol (MCP) server that executes arbitrary C# scripts.

Demo

Prerequisites

This project depends on the dotnet-script tool. Ensure it is installed globally on your system:

# Install dotnet-script globally
> dotnet tool install dotnet-script -g

Building the Project

To build the project, navigate to the root directory and run:

> dotnet build

Running the Server

To run the server, you need to configure the AI agent with the following settings:

"mcp": {
    "servers": {
        "CSharpSandBox": {
            "type": "stdio",
            "command": "dotnet",
            "args": [
                "run",
                "--project",
                "{PROJECT-PATH}\\csharp-code-sandbox-mcp\\src\\MCPServer\\MCPServer.csproj",
                "--no-build"
            ]
        }
    }
}

Replace {PROJECT-PATH} with the absolute path to the project directory.

Acknowledgments

Thanks to the project node-code-sandbox-mcp by alfonsograziano for the inspiration behind this work.

License

This project is licensed under the MIT License. See the file for details.