Roslyn
STDIO基于Roslyn编译器的C#代码分析导航服务器
基于Roslyn编译器的C#代码分析导航服务器
A C# MCP (Model Context Protocol) server that integrates with Microsoft's Roslyn compiler platform to provide Claude Desktop with code analysis and navigation capabilities for C# codebases.
*Service, Get*User, etc.)Clone or download the project
git clone https://github.com/carquiza/RoslynMCP.git cd RoslynMCP/RoslynMcpServer
Restore NuGet packages
dotnet restore
Build the project
dotnet build
Test the server (optional)
dotnet run
Run the PowerShell setup script:
.\setup.ps1
Run the installation test:
./test-installation.sh
To connect this MCP server to Claude Desktop, you need to modify the Claude Desktop configuration file:
%APPDATA%\Claude\claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.jsonAdd the following to your claude_desktop_config.json file:
{ "mcpServers": { "roslyn-code-navigator": { "command": "dotnet", "args": [ "run", "--project", "/path/to/RoslynMCP/RoslynMcpServer" ], "env": { "DOTNET_ENVIRONMENT": "Production", "LOG_LEVEL": "Information" } } } }
Important: Replace /path/to/RoslynMCP/RoslynMcpServer with the actual absolute path to your project directory.
Once configured, restart Claude Desktop. You should see the Roslyn MCP Server appear in the available tools. Here are some example queries:
Search for all classes ending with 'Service' in my solution at C:\MyProject\MyProject.sln
Find all references to the UserRepository class in C:\MyProject\MyProject.sln
Get information about the CalculateTotal method in C:\MyProject\MyProject.sln
Analyze dependencies for the solution at C:\MyProject\MyProject.sln
Find methods with complexity higher than 7 in C:\MyProject\MyProject.sln
For development and testing, you can use the MCP Inspector:
# Install the inspector npm install -g @modelcontextprotocol/inspector # Test your server npx @modelcontextprotocol/inspector dotnet run --project ./RoslynMcpServer
The server features a modular architecture with:
This project is licensed under the MIT License - see the LICENSE file for details.
Christopher Arquiza
Contributions are welcome! Please feel free to submit a Pull Request.