Roslyn CodeLens — Claude Code MCP server: features and setup
This MCP server gives agents Roslyn-based insight into .NET code, from symbol relationships to diagnostics and fixes. Use it to navigate a codebase, inspect tests, or review API changes.
claude mcp add roslyn-codelens -- npx -y roslyn-codelens-mcpWhat Roslyn CodeLens does
Roslyn CodeLens lets an agent inspect .NET code with semantic context. It can locate interface implementations, method callers, and symbol references, then show type hierarchies, DI registrations, and compiler or analyzer diagnostics with available fixes. It can also trace exceptions through methods or map a .NET stack trace to source locations.
For test work, the server finds tests that exercise a symbol, summarizes test methods, and identifies public methods and properties that tests do not reach. It can draft a test-class skeleton for xUnit, NUnit, or MSTest. The result is text, not a finished test; constructor dependencies appear as TodoNotes.
API review tools list the public surface and compare it with a baseline JSON file or DLL. The server can be added to Claude Code with npx. Its semantic analysis is aimed at .NET code, so it is not a general-purpose code intelligence server for unrelated languages.
What it helps with
- locate implementations of an interface or base class
- trace calls to a method across the project
- find public members that tests do not reach
- compare the public API against a baseline
- inspect compiler diagnostics and available fixes
Example prompts for the agent
- Find every implementation of
IOrderServiceand show where each one is defined. - Check which tests exercise
CalculateTotaland identify public methods that tests do not reach. - Compare the current public API with the baseline DLL and report breaking changes.
How to install Roslyn CodeLens
Platform CLI
claude mcp add roslyn-codelens -- npx -y roslyn-codelens-mcpPlatform CLI
codex mcp add roslyn-codelens -- npx -y roslyn-codelens-mcpConfig file
{
"mcpServers": {
"roslyn-codelens": {
"command": "npx",
"args": [
"-y",
"roslyn-codelens-mcp"
]
}
}
}Config file
{
"servers": {
"roslyn-codelens": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"roslyn-codelens-mcp"
]
}
}
}Platform CLI
gemini mcp add roslyn-codelens npx -y roslyn-codelens-mcpStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Roslyn CodeLens
How do I install Roslyn CodeLens in Claude Code?
Run claude mcp add roslyn-codelens -- npx -y roslyn-codelens-mcp. This registers Roslyn CodeLens as an MCP server in Claude Code.
What does Roslyn CodeLens do?
It gives agents semantic insight into .NET code, including symbol references, callers, tests, DI registrations, and diagnostics. It can also inspect public API changes.
Which test frameworks can it use for generated test skeletons?
It detects xUnit, NUnit, and MSTest when generating a test-class skeleton. Constructor dependencies are included as TodoNotes.