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
Provider
kooshi
Release date
Jun 20, 2025
Language
JavaScript
Stats
36 stars

SharpTools is a robust service designed to empower AI agents with advanced capabilities for understanding, analyzing, 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.

Prerequisites

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

Installation

To build the SharpTools solution:

dotnet build SharpTools.sln

Server Options

You can run SharpTools in two different server modes:

SSE Server (HTTP)

The SSE server hosts the tools on an HTTP endpoint.

# 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:

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

Stdio Server

The Stdio server communicates over standard input/output. Configure it in your MCP client of choice.

VSCode Copilot example configuration:

"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:

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

Using SharpTools

SharpTools exposes various functions via MCP that can be used by AI agents to analyze and modify C# code. Here are the key functions organized by category:

Getting Started

Begin by loading your solution:

SharpTool_LoadSolution

This initializes the workspace with a given .sln file and is the primary entry point for all operations.

Solution Analysis

After loading your solution, you can explore its structure:

SharpTool_LoadProject

This provides a detailed structural overview of a specific project within the loaded solution, including namespaces and types.

Code Exploration

Explore code with these 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_AnalyzeComplexity: Analyzes code complexity metrics

Code Modification

Modify code precisely with these tools:

  • SharpTool_AddMember: Adds a new member to a specified type
  • SharpTool_OverwriteMember: Replaces or deletes an existing member
  • 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

Document Operations

Manage entire files with:

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

Additional Tools

  • SharpTool_ManageUsings: Reads or overwrites using directives
  • SharpTool_ManageAttributes: Reads or overwrites attributes
  • SharpTool_RequestNewTool: Allows requesting new tools or features

Key Features

SharpTools provides several advantages over plain text code manipulation:

  • Token Efficient Operation: Provides only high-signal context, with indentation omitted to save tokens
  • FQN Fuzzy Matching: Intelligently resolves imprecise Fully Qualified Names
  • Comprehensive Source Resolution: Retrieves source code from local files, external libraries, PDBs, or decompilation
  • Precise Code Modifications: Enables surgical code changes rather than simple text manipulation
  • Automated Git Integration: Creates dedicated branches and commits all changes with descriptive messages
  • Concise Feedback Loop: Confirms changes with precise diffs and provides immediate compilation error reports

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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