← Back to directory
R

Roslyn CodeLens MCP Server

Community
Roslyn-based semantic .NET/C# intelligence for AI agents
GitHub source repository ↗
★ 42 Stars Category · Dev Tools Popular
68FMRS · C

A very comprehensive Roslyn semantic-analysis MCP server with 67 tools covering navigation, refactoring, test intelligence, quality auditing, and IL inspection. Performance is benchmarked, and a VS-style trust model guards analyzer execution. Works only with SDK-style .NET projects and requires the .NET 10 SDK. Maintained by an individual developer, not an official .NET/Roslyn product.

Reliability
9/20
Security and permissions
14/20
Maintenance
14/20
Documentation
18/20
Setup experience
13/20
Read the FMRS scoring method →

Roslyn CodeLens is a Roslyn-based MCP server that gives AI agents deep semantic understanding of .NET/C# codebases over stdio. It exposes 67 tools for navigation, call graphs, diagnostics and code fixes, safe refactoring, code-quality auditing, test intelligence, DI graphs, and IL/external-assembly inspection. Installable via npm (npx launcher), NuGet (.NET global tool), Claude Code plugin, or Docker; requires the .NET 10 SDK.

Tools

find_implementations
Find all classes/structs implementing an interface or extending a class
find_callers
Find every call site for a method, property, or constructor
find_event_subscribers
Find every += / -= site for an event symbol with resolved handler
find_tests_for_symbol
List xUnit/NUnit/MSTest methods exercising a production symbol, with optional transitive walk
get_test_summary
Per-project inventory of test methods with framework, attributes, data rows, and locations
find_uncovered_symbols
Find public methods/properties no test reaches, sorted by cyclomatic complexity
generate_test_skeleton
Emit a compilable test-class skeleton (as text) with auto-detected test framework
get_type_hierarchy
Walk base classes, interfaces, and derived types
get_di_registrations
Scan for DI service registrations (generic, typeof-pair, and factory-lambda forms)
get_instantiation_options
Answer 'how do I construct this type' with constructors, factories, DI registrations, and required members
get_project_dependencies
Get the project reference graph
get_symbol_context
One-shot context dump for any type
get_public_api_surface
Enumerate every public/protected type and member in production projects
find_breaking_changes
Diff the current API against a baseline JSON or DLL and report breaking changes
find_reflection_usage
Detect dynamic/reflection-based usage
get_exception_flow
Report exceptions that escape a method with their propagation paths
find_throw_sites
Find every site an exception type is thrown, optionally including derived types
find_catch_blocks
Find every catch for a type, flagging filtered, rethrowing, and swallowing handlers
find_references
Find all references to a symbol, tagged with kinds like read/write/invocation
go_to_definition
Find the source file and line where a symbol is defined
get_method_source
Fetch full declaration source for one or many members by name in a single call
resolve_stack_trace
Map a pasted .NET stack trace to file/line/symbol, undoing compiler name mangling
get_diagnostics
List compiler errors, warnings, and Roslyn analyzer diagnostics
get_code_fixes
Get available code fixes with structured text edits for any diagnostic
search_symbols
Fuzzy workspace symbol search by name
get_nuget_dependencies
List NuGet package references per project
find_attribute_usages
Find types and members decorated with a specific attribute
find_obsolete_usage
List every [Obsolete] call site grouped by deprecation message and severity
find_circular_dependencies
Detect cycles in project or namespace dependency graphs
check_architecture
Enforce layering rules against the real semantic type graph
get_complexity_metrics
Report cyclomatic complexity, cognitive complexity, and max nesting depth per member
find_naming_violations
Check .NET naming convention compliance
find_async_violations
Detect sync-over-async, async void misuse, missing awaits, and fire-and-forget tasks
find_disposable_misuse
Detect IDisposable/IAsyncDisposable instances not wrapped in using/await using
find_large_classes
Find oversized types by member or line count
find_god_objects
Find types combining high size with high cross-namespace coupling
find_unused_symbols
Dead code detection via reference analysis with automatic filtering of tests and generated code
get_project_health
Composite audit aggregating 7 quality dimensions per project
get_source_generators
List source generators and their output per project
get_generated_code
Inspect generated source code from source generators
inspect_external_assembly
Browse types, members, and XML docs from closed-source assemblies
peek_il
Decompile any method to ilasm-style IL bytecode
get_code_actions
Discover available refactorings and fixes at any position
apply_code_action
Execute any Roslyn refactoring by title, with preview mode
rename_symbol
Solution-wide safe rename via Roslyn's Renamer with preview and conflict reporting
change_signature
Add, remove, and reorder method parameters and rewrite every call site
list_solutions
List all loaded solutions and which one is currently active
set_active_solution
Switch the active solution by partial name
load_solution
Load an additional .sln/.slnx at runtime and make it active
unload_solution
Unload a loaded solution to free memory
rebuild_solution
Force a full reload of the analyzed solution
start_background_task
Queue a long-running tool to run in the background
get_task_status
Get status, result, or error of a background task by taskId
list_running_tasks
List background tasks running or completed within the last 5 minutes
trust_solution
Authorize a solution to run Roslyn analyzers
list_trusted_paths
Inspect the persistent trust store and session-trusted solutions
revoke_trust
Revoke previously-granted trust for a solution path
analyze_data_flow
Variable read/write/capture analysis within a statement range
analyze_control_flow
Branch/loop reachability analysis within a statement range
analyze_change_impact
Show all files, projects, and call sites affected by changing a symbol
get_type_overview
Compound tool: type context + hierarchy + file diagnostics in one call
analyze_method
Compound tool: method signature + callers + outgoing calls in one call
get_overloads
Every overload of a method/constructor with full parameter detail
get_extension_methods
Every extension member applicable to a type, including C# 14 extension blocks
get_operators
Every user-defined and conversion operator on a type
get_call_graph
Transitive caller/callee graph with depth bound and cycle detection
get_file_overview
Compound tool: types in a file + file-scoped diagnostics in one call

Setup

npm: add "mcpServers": {"roslyn-codelens": {"type": "stdio", "command": "npx", "args": ["-y", "roslyn-codelens-mcp"]}} to your MCP client config; the .NET 10 SDK must be on PATH. NuGet: run dotnet tool install -g RoslynCodeLens.Mcp then configure command roslyn-codelens-mcp, or use dnx RoslynCodeLens.Mcp --yes. Claude Code: claude install gh:MarcelRoozekrans/roslyn-codelens-mcp. Docker is also supported, bind-mounting the solution at /workspace (solution must be restored).

claude_desktop_config.json
{"mcpServers":{"roslyn-codelens":{"type":"stdio","command":"npx","args":["-y","roslyn-codelens-mcp"]}}}

Fit and risk

Best for

  • .NET/C# developers using MCP clients like Claude Code or VS Code
  • AI-assisted development workflows needing deep static analysis and safe refactoring
  • Teams maintaining large SDK-style .NET solutions

Not for

  • Non-.NET/C# codebases
  • Legacy non-SDK-style csproj projects (skipped with a warning)
  • Environments without the .NET 10 SDK (unless using Docker)

Required permissions

  • Reads and analyzes .NET solutions and source files on disk
  • Tools like apply_code_action can write/modify source files (preview mode available)
  • Running Roslyn analyzer DLLs requires explicit trust via trust_solution

Risks and side effects

  • Analyzer DLLs execute in-process; the trust model restricts them to NuGet global packages, the dotnet SDK dir, or solution bin/obj, but grant trust carefully
  • apply_code_action, rename_symbol, and change_signature modify source files directly; prefer preview mode first
  • The stdio server has read/write access to the loaded codebase
  • Solutions must be NuGet-restored before loading or reference resolution may fail

Troubleshooting

  1. Verify the .NET 10 SDK is installed and on PATH (required by the npx launcher)
  2. Solutions must be compilable SDK-style projects; legacy projects are skipped and listed in SkippedProjects
  3. If diagnostics with analyzers return SolutionNotTrusted, authorize the solution via trust_solution
  4. Project load timeouts (default 300s) are recorded as SkippedProjects; adjust ROSLYN_CODELENS_OPEN_PROJECT_TIMEOUT_SECONDS
  5. Docker output reports container paths, and the mounted solution must be restored
  6. If a symbol is not found, confirm the solution is loaded and active via list_solutions

Use cases

Give AI agents semantic navigation and call-graph analysis of .NET codebases
Perform safe solution-wide renames and signature changes
Audit code quality: complexity, naming, async misuse, dead code
Find untested public symbols via test intelligence and generate test skeletons
Inspect types and IL of closed-source NuGet dependencies

Supported clients

Claude CodeFull support
VS CodeFull support
Visual StudioFull support