Skip to main content

roslyn-codelens-mcp

roslyn-codelens-mcp is a Model Context Protocol server that gives AI agents deep semantic understanding of .NET codebases — without needing to grep source files or know where symbols appear in the editor.

Why symbol names instead of coordinates?

Most code intelligence tools require (filePath, line, column) — you need to already know where a symbol lives. roslyn-codelens-mcp uses symbol names ("IGreeter", "Greeter.Greet"). The server resolves them through a pre-built index, so tools work without an open editor.

What it does

  • Navigate — go to definitions, find references, callers, implementations, attribute usages
  • Analyse — type hierarchies, method flow, data flow, change impact
  • Diagnose & refactor — diagnostics, code fixes, code actions with diff preview
  • Inspect quality — unused symbols, complexity, naming violations, circular dependencies
  • Understand DI — find registrations, lifetimes, constructor wiring
  • Inspect assemblies — browse NuGet package APIs, peek IL disassembly

Quick start

dotnet tool install -g RoslynCodeLens.Mcp

Then add to your .mcp.json:

{
"mcpServers": {
"roslyn-codelens": {
"command": "roslyn-codelens-mcp",
"args": ["--solution", "/path/to/your/Solution.sln"]
}
}
}

See Installation for full setup details.

Working with results

List-returning tools (everything that produces "all X" or "every Y") cap their items at a per-tool default and wrap them in an envelope:

{ "items": [ ... ], "totalCount": 142, "truncated": false, "limit": 500, "summary": { ... } }

If truncated is true, items is the top N by the tool's natural sort order (errors first, worst-first, most-relevant-first). Raise limit only if the tail matters for what you're doing — usually it won't.

When a tool can't proceed, the response is an isError: true content block whose JSON body has { code, message, details? }. Codes are stable: SymbolNotFound, SolutionNotTrusted, AmbiguousMatch, FileNotFound, ProjectNotFound, InvalidArgument, Internal. See the main README for examples.