RoslynMCP
A Model Context Protocol (MCP) server that provides C# code analysis capabilities using Microsoft Roslyn
claude mcp add --transport stdio carquiza-roslynmcp dotnet run --project /path/to/RoslynMCP/RoslynMcpServer \ --env LOG_LEVEL="Information" \ --env DOTNET_ENVIRONMENT="Production"
How to use
Roslyn MCP Server provides code analysis and navigation capabilities for C# projects by integrating with the Roslyn compiler. It exposes tools for wildcard symbol search, locating symbol references across solutions, retrieving detailed symbol information, analyzing project dependencies, and assessing code complexity. Once connected to Claude Desktop, this server enables natural-language style queries to perform actions such as finding all methods matching a pattern, listing references to a symbol, or analyzing a solution’s dependency graph. The server is designed for performance with multi-level caching and incremental analysis to handle large codebases while maintaining security through input validation and path sanitization. To use it, configure Claude Desktop to point at the running server by specifying the dotnet-based command and the appropriate project path, then select the Roslyn MCP tool from the available options to issue queries like “Search for all classes ending with Service” or “Analyze dependencies for the solution at C:\Projects\MySolution.sln.”
How to install
Prerequisites:
- .NET 8.0 SDK or later
- A supported IDE (Visual Studio 2022 or VS Code) for development
- Claude Desktop installed for MCP integration
Installation steps:
-
Clone the repository: git clone https://github.com/carquiza/RoslynMCP.git cd RoslynMCP/RoslynMcpServer
-
Restore dependencies: dotnet restore
-
Build the project: dotnet build
-
Run the server locally (optional for testing): dotnet run
-
Connect to Claude Desktop:
- Configure Claude Desktop to use the MCP server with the command: dotnet run --project /path/to/RoslynMCP/RoslynMcpServer Ensure the working directory and project path reflect your environment.
-
Optional: Run tests or development workflow as described in the repository documentation.
Additional notes
Tips and notes:
- Ensure you have the .NET 8 SDK installed and the environment variables set as needed for production logging.
- When configuring Claude Desktop, replace /path/to/RoslynMCP/RoslynMcpServer with the absolute path to your local RoslynMCP server project.
- The server supports multi-level caching for performance; clearing caches may be useful if analyzing drastically changed codebases.
- If you encounter path or permission issues, verify that the process has access to the solution files and that the configured environment variables are valid.
- The available tools include: SearchSymbols, FindReferences, GetSymbolInfo, AnalyzeDependencies, and AnalyzeCodeComplexity.
Related MCP Servers
mssql
MSSQL Server MCP implementation written in C#
McpDotNet.Extensions.SemanticKernel
Microsoft SemanticKernel integration for the Model Context Protocol (MCP). Enables seamless use of MCP tools as AI functions.
DatabaseMcpServer
MCP server from ttcc666/DatabaseMcpServer
mcp-dataverse
MCP Server for querying Dataverse using SQL
xperience-community
ASP.NET Core MCP server for Xperience by Kentico projects
console-to-http
Example of converting a stdio MCP server to HTTP using ModelContextProtocol.AspNetCore