CSharpMCP logo

CSharpMCP

by li-zhixin

CSharpMCP is an mcp server designed for executing C# code using Roslyn. It allows for dynamic code execution with state preservation.

View on GitHub

Last updated: N/A

What is CSharpMCP?

CSharpMCP is a server that executes C# code using the Roslyn compiler. It provides tools to run code, manage execution context, and retrieve code history.

How to use CSharpMCP?

To use CSharpMCP, you can utilize the available tools like RunAsync to execute C# code. The state is preserved between executions. CleanExecuteContext clears the execution context. To reference existing projects, compile them and provide the path of the compiled DLL as a startup parameter.

Key features of CSharpMCP

  • RunAsync for code execution with state preservation

  • CleanExecuteContext for clearing the execution context

  • GetHistoryCode for retrieving code history

  • Automatic reference addition for compiled DLLs

Use cases of CSharpMCP

  • Dynamic code evaluation

  • Scripting engine

  • Interactive C# development

  • Extending applications with C# code

FAQ from CSharpMCP

What is RunAsync?

RunAsync executes the provided C# code and preserves the state between executions.

How do I clear the execution context?

Use CleanExecuteContext to clear the code execution context and all states.

How can I access the history of executed code?

Use GetHistoryCode to retrieve the history of executed code.

How do I reference existing projects?

Compile the existing project and provide the path of the compiled DLL as a startup parameter.

Is CSharpMCP safe to use?

Use with caution. CSharpMCP executes code on the local machine, so ensure the code being executed is from a trusted source.