home / mcp / sharptools mcp server

SharpTools MCP Server

Provides Roslyn-based C# analysis and precise code modifications via an MCP interface over SSE and Stdio for seamless AI-assisted development.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kooshi-sharptoolsmcp": {
      "command": "/path/to/repo/SharpToolsMCP/SharpTools.StdioServer/bin/Debug/net8.0/SharpTools.StdioServer",
      "args": [
        "--log-directory",
        "/var/log/sharptools/",
        "--log-level",
        "Debug"
      ]
    }
  }
}

SharpTools MCP Server exposes Roslyn-based tooling over MCP, enabling your AI agents to analyze, navigate, modify, and reason about C# code with precise, Roslyn-driven operations. It provides a practical bridge between code understanding and autonomous edits, supported by automated Git integration and clear, incremental feedback.

How to use

You connect to the SharpTools MCP Server from an MCP client to load your solution, inspect namespaces and types, view symbol definitions, and perform surgical code changes. Use the provided tools to load a solution, examine members, view definitions, find references, analyze complexity, and apply safe edits with automatic diff-based feedback and in-tool compilation checks.

How to install

Prerequisites: install the .NET 8+ SDK and ensure your target solution’s .NET version is installed.

1. Build the SharpTools solution to produce all server components. 2. Run the Stdio MCP server or the SSE HTTP server as described below to expose MCP endpoints.

Additional notes

The MCP interface is exposed via two main methods: Server-Sent Events for remote clients and standard I/O for local process communication. The Stdio server is configured to log its activity and operate with a named log directory and log level.

{
  "mcpServers": {
    "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"
      ],
      "env": []
    }
  }
}

Troubleshooting and tips

If you need to inspect the exact changes that SharpTools proposes, you will see precise diffs rather than full code blocks. If a modification introduces compile-time errors, you’ll receive immediate feedback so you can adjust before committing.

Available tools

SharpTool_LoadSolution

Initializes the workspace with a given .sln file to load the solution into SharpTools for subsequent analysis and modifications.

SharpTool_LoadProject

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

SharpTool_GetMembers

Lists members (methods, properties, etc.) of a type, including signatures and XML documentation.

SharpTool_ViewDefinition

Displays the source code of a symbol, with contextual information such as call graphs and type references.

SharpTool_ListImplementations

Finds all implementations of an interface or abstract method, or derived classes of a base class.

SharpTool_FindReferences

Locates all usages of a symbol across the solution, with contextual code snippets.

SharpTool_SearchDefinitions

Performs a regex-based search across symbol declarations and signatures in source code and assemblies.

SharpTool_ManageUsings

Reads or overwrites using directives in a document.

SharpTool_ManageAttributes

Reads or overwrites attributes on a declaration.

SharpTool_AnalyzeComplexity

Performs complexity analysis (cyclomatic, cognitive, coupling, etc.) on methods, classes, or projects.

SharpTool_ReadRawFromRoslynDocument

Reads the raw content of a file with indentation omitted.

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 defined within a specific source file.

SharpTool_AddMember

Adds a new member (method, property, field, nested type, etc.) to a specified type.

SharpTool_OverwriteMember

Replaces the definition of an existing member or type with new code, or deletes it.

SharpTool_RenameSymbol

Renames a symbol and updates all its references throughout the solution.

SharpTool_FindAndReplace

Performs regex-based find and replace operations within a symbol's declaration or across files matching a glob pattern.

SharpTool_MoveMember

Moves a member from one type or namespace to another.

SharpTool_Undo

Reverts the last applied change using Git integration.