RoslynMCP
A Model Context Protocol (MCP) server that provides C# code analysis capabilities using Microsoft Roslyn
Documentation
Roslyn MCP Server
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.
Features
- Wildcard Symbol Search - Find classes, methods, and properties using pattern matching (`*Service`, `Get*User`, etc.)
- Reference Tracking - Locate all usages of symbols across entire solutions
- Symbol Information - Get detailed information about types, methods, properties, and more
- Dependency Analysis - Analyze project dependencies and namespace usage patterns
- Code Complexity Analysis - Identify high-complexity methods using cyclomatic complexity metrics
- Performance Optimized - Multi-level caching and incremental analysis for large codebases
- Security - Input validation and path sanitization
Prerequisites
- .NET 8.0 SDK or later
- Visual Studio 2022 or VS Code (recommended for development)
- Claude Desktop application
Installation
1. Clone or download the project
git clone https://github.com/carquiza/RoslynMCP.git
cd RoslynMCP/RoslynMcpServer2. Restore NuGet packages
dotnet restore3. Build the project
dotnet build4. Test the server (optional)
dotnet runQuick Setup
Windows
Run the PowerShell setup script:
.\setup.ps1Linux/macOS
Run the installation test:
./test-installation.shClaude Desktop Configuration
To connect this MCP server to Claude Desktop, you need to modify the Claude Desktop configuration file:
Configuration File Location
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
Configuration Content
Add 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.
Usage
Once configured, restart Claude Desktop. You should see the Roslyn MCP Server appear in the available tools. Here are some example queries:
Search for Symbols
Search for all classes ending with 'Service' in my solution at C:\MyProject\MyProject.slnFind References
Find all references to the UserRepository class in C:\MyProject\MyProject.slnGet Symbol Information
Get information about the CalculateTotal method in C:\MyProject\MyProject.slnAnalyze Dependencies
Analyze dependencies for the solution at C:\MyProject\MyProject.slnCode Complexity Analysis
Find methods with complexity higher than 7 in C:\MyProject\MyProject.slnAvailable Tools
1. SearchSymbols - Search for symbols using wildcard patterns
2. FindReferences - Find all references to a specific symbol
3. GetSymbolInfo - Get detailed information about a symbol
4. AnalyzeDependencies - Analyze project dependencies and usage patterns
5. AnalyzeCodeComplexity - Identify high-complexity methods
Development and Testing
Using MCP Inspector
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 ./RoslynMcpServerArchitecture
The server features a modular architecture with:
- MCP Server Layer: Handles communication with Claude Desktop
- Roslyn Integration Layer: Manages workspaces and compilations
- Search Engine Layer: Implements symbol search and analysis
- Multi-level Caching: Performance optimization for large codebases
- Security Layer: Input validation and sanitization
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Christopher Arquiza
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Frequently asked questions
What is RoslynMCP?
RoslynMCP is A Model Context Protocol (MCP) server that provides C# code analysis capabilities using Microsoft Roslyn
How do I install RoslynMCP?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is RoslynMCP open source?
Yes — it is hosted on GitHub at https://github.com/carquiza/RoslynMCP and has 59 stars.
Related MCP tools
Unity MCP acts as a bridge between AI assistants and your Unity Editor. Give your LLM tools to manage assets, control scenes, edit scripts, and automate tasks within Unity.
AI Skills, MCP Tools, and CLI for Unity Engine. Full AI develop and test loop. Use cli for quick setup. Efficient token usage, advanced tools. Any C# method may be turned into a tool by a single line. Works with Claude Code, Gemini, Copilot, Cursor and any other absolutely for free.
Catalog of official Microsoft MCP (Model Context Protocol) server implementations for AI-powered data access and tool integration
An MCP server that allows MCP clients like Claude Desktop or Cursor to perform actions in the Unity Editor C#-based implementation.
The official C# SDK for Model Context Protocol servers and clients. Maintained in collaboration with Microsoft. Trusted by 3500+ developers.
Model Context Protocol (MCP) plugin to connect with Unity Editor — designed for OpenAI, Gemini, Claude, Deepseek and Grok interoperability
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP