SharpTools (Roslyn C# Analysis) MCP server

Provides Roslyn-powered C# codebase analysis and modification with surgical member additions, fuzzy FQN matching, source resolution from multiple sources, and automated Git integration for precise code manipulation with built-in undo capabilities.
Back to servers
Setup instructions
Provider
kooshi
Release date
Jun 20, 2025
Language
JavaScript
Stats
122 stars

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.

Installation

Prerequisites

  • .NET 8+ SDK for running the server
  • The .NET SDK of your target solution

Building the Application

To build the entire solution:

dotnet build SharpTools.sln

Running the Servers

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.

SSE Server (HTTP)

# 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

Key Options for SSE Server

  • --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 features

Stdio Server

The 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"
            ]
        }
    }
}

Key Options for Stdio Server

  • --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 features

Available Tools

SharpTools exposes the following tools via MCP:

Solution Tools

  • SharpTool_LoadSolution: Initializes the workspace with a given .sln file
  • SharpTool_LoadProject: Provides a detailed structural overview of a specific project

Analysis Tools

  • SharpTool_GetMembers: Lists members of a type, including signatures and documentation
  • SharpTool_ViewDefinition: Displays the source code of a symbol with contextual information
  • SharpTool_ListImplementations: Finds all implementations of an interface/abstract method
  • SharpTool_FindReferences: Locates all usages of a symbol across the solution
  • SharpTool_SearchDefinitions: Performs regex-based search across symbol declarations
  • SharpTool_ManageUsings: Reads or overwrites using directives in a document
  • SharpTool_ManageAttributes: Reads or overwrites attributes on a specific declaration
  • SharpTool_AnalyzeComplexity: Performs complexity analysis on methods, classes, or projects

Document Tools

  • SharpTool_ReadRawFromRoslynDocument: Reads the raw content of a file
  • SharpTool_CreateRoslynDocument: Creates a new file with specified content
  • SharpTool_OverwriteRoslynDocument: Overwrites an existing file with new content
  • SharpTool_ReadTypesFromRoslynDocument: Lists all types and their members in a source file

Modification Tools

  • SharpTool_AddMember: Adds a new member to a specified type
  • SharpTool_OverwriteMember: Replaces the definition of an existing member or type
  • SharpTool_RenameSymbol: Renames a symbol and updates all references
  • SharpTool_FindAndReplace: Performs regex-based find and replace operations
  • SharpTool_MoveMember: Moves a member from one type/namespace to another
  • SharpTool_Undo: Reverts the last applied change using Git integration

Misc Tools

  • SharpTool_RequestNewTool: Allows requesting new tools or features

Features

  • Dynamic Project Structure Mapping: Generates a map of the solution with namespaces and types
  • Contextual Navigation Aids: Provides simplified call graphs and dependency trees
  • Token Efficient Operation: Designed to provide high-signal context without overwhelming the agent
  • FQN Fuzzy Matching: Intelligently resolves potentially imprecise Fully Qualified Names
  • Comprehensive Source Resolution: Retrieves source code from local files, SourceLink, PDBs, or decompilation
  • Precise, Roslyn-Based Modifications: Enables surgical code changes rather than simple text manipulation
  • Automated Git Integration: Creates dedicated branches, commits code changes, and offers undo functionality
  • Concise AI Feedback Loop: Confirms changes with precise diffs and provides immediate compilation error reports
  • Proactive Code Quality Analysis: Detects high code complexity and potential code duplicates
  • Broad Project Support: Runs on multiple platforms and supports various .NET versions and project formats

How to install this MCP server

For Claude Code

To 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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. 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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later