SharpTools is a C# analysis and modification server designed to empower AI agents with advanced capabilities for understanding and modifying C# codebases. It leverages the .NET Compiler Platform (Roslyn) to provide deep static analysis and precise code manipulation, functioning essentially as a simple IDE made for AI users.
To build the entire solution:
dotnet build SharpTools.sln
SharpTools can be run in two modes: as an SSE (Server-Sent Events) server over HTTP or as a Stdio server communicating over standard input/output.
# Navigate to the SseServer project directory
cd SharpTools.SseServer
# Run with default options (port 3001)
dotnet run
# Run with specific options
dotnet run -- --port 3005 --log-file ./logs/mcp-sse-server.log --log-level Debug
--port <number>: Port to listen on (default: 3001)--log-file <path>: Path to a log file--log-level <level>: Minimum log level (Verbose, Debug, Information, Warning, Error, Fatal)--load-solution <path>: Path to a .sln file to load on startup--build-configuration <config>: Build configuration to use (e.g., Debug, Release)--disable-git: Disables all Git integration featuresThe Stdio server communicates over standard input/output. Here's a VSCode Copilot configuration example:
"mcp": {
"servers": {
"SharpTools": {
"type": "stdio",
"command": "/path/to/repo/SharpToolsMCP/SharpTools.StdioServer/bin/Debug/net8.0/SharpTools.StdioServer",
"args": [
"--log-directory",
"/var/log/sharptools/",
"--log-level",
"Debug"
]
}
}
}
--log-directory <path>: Directory to store log files--log-level <level>: Minimum log level--load-solution <path>: Path to a .sln file to load on startup--build-configuration <config>: Build configuration to use--disable-git: Disables all Git integration featuresSharpTools exposes the following tools via MCP:
SharpTool_LoadSolution: Initializes the workspace with a given .sln fileSharpTool_LoadProject: Provides a detailed structural overview of a specific projectSharpTool_GetMembers: Lists members of a type, including signatures and documentationSharpTool_ViewDefinition: Displays the source code of a symbol with contextual informationSharpTool_ListImplementations: Finds all implementations of an interface/abstract methodSharpTool_FindReferences: Locates all usages of a symbol across the solutionSharpTool_SearchDefinitions: Performs regex-based search across symbol declarationsSharpTool_ManageUsings: Reads or overwrites using directives in a documentSharpTool_ManageAttributes: Reads or overwrites attributes on a specific declarationSharpTool_AnalyzeComplexity: Performs complexity analysis on methods, classes, or projectsSharpTool_ReadRawFromRoslynDocument: Reads the raw content of a fileSharpTool_CreateRoslynDocument: Creates a new file with specified contentSharpTool_OverwriteRoslynDocument: Overwrites an existing file with new contentSharpTool_ReadTypesFromRoslynDocument: Lists all types and their members in a source fileSharpTool_AddMember: Adds a new member to a specified typeSharpTool_OverwriteMember: Replaces the definition of an existing member or typeSharpTool_RenameSymbol: Renames a symbol and updates all referencesSharpTool_FindAndReplace: Performs regex-based find and replace operationsSharpTool_MoveMember: Moves a member from one type/namespace to anotherSharpTool_Undo: Reverts the last applied change using Git integrationSharpTool_RequestNewTool: Allows requesting new tools or featuresTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "SharpTools" '{"command":"dotnet","args":["run","--project","SharpTools.StdioServer/SharpTools.StdioServer.csproj"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"SharpTools": {
"command": "dotnet",
"args": [
"run",
"--project",
"SharpTools.StdioServer/SharpTools.StdioServer.csproj"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"SharpTools": {
"command": "dotnet",
"args": [
"run",
"--project",
"SharpTools.StdioServer/SharpTools.StdioServer.csproj"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect