CSharpMCP
@li-zhixin
About CSharpMCP
A Roslyn-based mcp server for dynamically executing C# code snippets
Config
No standard config provided
This server doesn't expose a parseable MCP config block in its README. See the repository for install instructions.
RepositoryTools
3Execute the provided C# code, and the state (like variables) will be preserved each time.
Clean the code execution context, all states will be cleared.
Get the history code.
Overview
What is CSharpMCP?
CSharpMCP is a Model Context Protocol (MCP) server for executing C# code using the Roslyn compiler. It is intended for developers who need to run C# snippets programmatically, with state persistence across executions.
How to use CSharpMCP?
To use CSharpMCP, configure it as an MCP server in your MCP client application. To reference existing projects, compile the project and pass the path of the resulting DLL as a startup parameter; the server will add those assemblies as references. Invoke the provided tools (RunAsync, CleanExecuteContext, GetHistoryCode) from your MCP client.
Key features of CSharpMCP
- Execute C# code snippets with Roslyn
- State (variables) preserved across calls
- Clear execution context and reset state
- Retrieve previously executed code history
- Support for referencing external compiled DLLs
Use cases of CSharpMCP
- Running C# scripts interactively within an MCP-aware environment
- Prototyping C# logic without creating a full project
- Testing small code fragments with persistent state
- Integrating C# code execution into AI-assisted coding workflows
FAQ from CSharpMCP
What does RunAsync do?
RunAsync executes the provided C# code and preserves the state (variables) between calls, allowing incremental code execution.
How do I clean the execution state?
Use the CleanExecuteContext tool to clear all state and reset the execution context.
Can I use existing C# libraries?
Yes. Compile the project to a DLL, then pass that DLL path as a startup parameter when launching CSharpMCP.
What are the security implications?
This server executes arbitrary C# code on the local machine. Use with caution and only in trusted environments.
How do I retrieve previously executed code?
Use the GetHistoryCode tool to retrieve the full history of code that has been executed.
Frequently asked questions
What does RunAsync do?
RunAsync executes the provided C# code and preserves the state (variables) between calls, allowing incremental code execution.
How do I clean the execution state?
Use the CleanExecuteContext tool to clear all state and reset the execution context.
Can I use existing C# libraries?
Yes. Compile the project to a DLL, then pass that DLL path as a startup parameter when launching CSharpMCP.
What are the security implications?
This server executes arbitrary C# code on the local machine. Use with caution and only in trusted environments.
How do I retrieve previously executed code?
Use the GetHistoryCode tool to retrieve the full history of code that has been executed.
Basic information
More Other MCP servers
🪟 Windows-MCP
CursorTouchMCP Server for Computer Use in Windows
Mobile Mcp
mobile-nextModel Context Protocol Server for Mobile Automation and Scraping (iOS, Android, Emulators, Simulators and Real Devices)
MCP Registry
modelcontextprotocolA community driven registry service for Model Context Protocol (MCP) servers.
🚀 Model Context Protocol (MCP) Curriculum for Beginners
microsoftThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable,

DeepMark
DeepMark helps teachers deliver rapid, consistent marking with meaningful feedback for every student — in a fraction of the time. What once took a week, now takes one free period.
Comments