SharpLens
Roslyn-powered semantic analysis that goes deeper than LSP. Gives Claude compiler-accurate understanding of C# codebases: find all callers with impact analysis, detect dead code, trace call graphs with cycle detection, search symbols by filters like async methods missing CancellationToken. Also handles refactoring with preview mode (rename, extract method, change signatures) and batch operations to save tokens. Needs explicit sync_documents calls after external file edits since it maintains an in-memory workspace. Install via dotnet tool or npx, point it at your sln file, and you get 67 tools organized around navigation, diagnostics, and safe refactoring. Built for agents that need to reason about inheritance hierarchies, data flow, and breaking changes rather than just grepping strings.
- GitHub stars
- 19
- tools
- 80
- transport
- STDIO
- env vars
- 3
- last updated
- May 20, 2026
Tools
80 toolsPublic tool metadata for what this MCP can expose to an agent.
load_solutionLoad .sln/.slnx/.slnf; reports partial loads and MSBuild warnings separately
Load .sln/.slnx/.slnf; reports partial loads and MSBuild warnings separately
No parameter schema in public metadata yet.
sync_documentsSync file changes into loaded solution
Sync file changes into loaded solution
No parameter schema in public metadata yet.
health_checkServer status and load fidelity, check without reloading
Server status and load fidelity, check without reloading
No parameter schema in public metadata yet.
get_symbol_infoSemantic info at position
Semantic info at position
No parameter schema in public metadata yet.
go_to_definitionJump to symbol definition
Jump to symbol definition
No parameter schema in public metadata yet.
find_referencesAll references; each classified read/write/invocation/cast/typeof/nameof/attribute; optional kind filter
All references; each classified read/write/invocation/cast/typeof/nameof/attribute; optional kind filter
No parameter schema in public metadata yet.
find_implementationsInterface/abstract implementations
Interface/abstract implementations
No parameter schema in public metadata yet.
find_callersImpact analysis - who calls this?
Impact analysis - who calls this?
No parameter schema in public metadata yet.
get_call_graphMulti-hop callers/callees graph with depth bound and cycle detection
Multi-hop callers/callees graph with depth bound and cycle detection
No parameter schema in public metadata yet.
find_path_betweenReachability and the connecting call path(s) between two methods
Reachability and the connecting call path(s) between two methods
No parameter schema in public metadata yet.
get_type_hierarchyInheritance chain
Inheritance chain
No parameter schema in public metadata yet.
search_symbolsGlob pattern search
Glob pattern search
No parameter schema in public metadata yet.
semantic_queryMulti-filter search (async, public, etc.)
Multi-filter search (async, public, etc.)
No parameter schema in public metadata yet.
get_type_membersAll members by type name
All members by type name
No parameter schema in public metadata yet.
get_type_members_batchMultiple types in one call
Multiple types in one call
No parameter schema in public metadata yet.
get_method_signatureDetailed signature by name
Detailed signature by name
No parameter schema in public metadata yet.
get_derived_typesFind all subclasses
Find all subclasses
No parameter schema in public metadata yet.
get_base_typesFull inheritance chain
Full inheritance chain
No parameter schema in public metadata yet.
get_attributesList attributes on a symbol
List attributes on a symbol
No parameter schema in public metadata yet.
get_containing_memberEnclosing symbol at position
Enclosing symbol at position
No parameter schema in public metadata yet.
get_method_overloadsAll overloads of a method
All overloads of a method
No parameter schema in public metadata yet.
find_attribute_usagesFind types/members by attribute
Find types/members by attribute
No parameter schema in public metadata yet.
get_external_type_infoInspect NuGet/BCL/external assembly types, members and XML docs
Inspect NuGet/BCL/external assembly types, members and XML docs
No parameter schema in public metadata yet.
resolve_stack_traceMap a pasted stack trace to file/line/symbol
Map a pasted stack trace to file/line/symbol
No parameter schema in public metadata yet.
get_extension_methodsExtensions applying to a type, classic and C# 14 blocks
Extensions applying to a type, classic and C# 14 blocks
No parameter schema in public metadata yet.
get_documentationFull XML docs for a symbol with inheritdoc expanded
Full XML docs for a symbol with inheritdoc expanded
No parameter schema in public metadata yet.
get_super_methodNavigate to the base member or interface members a member implements
Navigate to the base member or interface members a member implements
No parameter schema in public metadata yet.
get_diagnosticsCompiler errors/warnings and configured analyzer findings
Compiler errors/warnings and configured analyzer findings
No parameter schema in public metadata yet.
diff_api_surfacePublic-API breaking-change report vs a git ref
Public-API breaking-change report vs a git ref
No parameter schema in public metadata yet.
get_exception_flowWhich exceptions can escape a method, and where they're caught
Which exceptions can escape a method, and where they're caught
No parameter schema in public metadata yet.
find_similar_codeStructural similarity search
Structural similarity search
No parameter schema in public metadata yet.
remove_unused_codeCompute dead-code removals and newly unused usings
Compute dead-code removals and newly unused usings
No parameter schema in public metadata yet.
find_dead_branchesUnreachable basic blocks per method
Unreachable basic blocks per method
No parameter schema in public metadata yet.
add_missing_importsCompute the usings that fix CS0246/CS0103
Compute the usings that fix CS0246/CS0103
No parameter schema in public metadata yet.
analyze_data_flowVariable assignments and usage
Variable assignments and usage
No parameter schema in public metadata yet.
analyze_control_flowBranching/reachability
Branching/reachability
No parameter schema in public metadata yet.
analyze_change_impactWhat breaks if changed?
What breaks if changed?
No parameter schema in public metadata yet.
check_type_compatibilityCan A assign to B?
Can A assign to B?
No parameter schema in public metadata yet.
get_outgoing_callsWhat does this method call?
What does this method call?
No parameter schema in public metadata yet.
find_unused_codeDead code detection
Dead code detection
No parameter schema in public metadata yet.
validate_codeCompile check without writing
Compile check without writing
No parameter schema in public metadata yet.
get_complexity_metricsCyclomatic, nesting, LOC, cognitive
Cyclomatic, nesting, LOC, cognitive
No parameter schema in public metadata yet.
find_circular_dependenciesProject and namespace cycle detection
Project and namespace cycle detection
No parameter schema in public metadata yet.
get_missing_membersUnimplemented interface/abstract members
Unimplemented interface/abstract members
No parameter schema in public metadata yet.
rename_symbolSafe rename across solution
Safe rename across solution
No parameter schema in public metadata yet.
change_signatureAdd/remove/reorder parameters
Add/remove/reorder parameters
No parameter schema in public metadata yet.
extract_methodExtract with data flow analysis
Extract with data flow analysis
No parameter schema in public metadata yet.
extract_interfaceGenerate interface from class
Generate interface from class
No parameter schema in public metadata yet.
generate_constructorFrom fields/properties
From fields/properties
No parameter schema in public metadata yet.
move_type_to_fileCompute the contents to move a type into its own file
Compute the contents to move a type into its own file
No parameter schema in public metadata yet.
split_typeCompute a partial-class split for selected members
Compute a partial-class split for selected members
No parameter schema in public metadata yet.
organize_usingsSort and remove unused
Sort and remove unused
No parameter schema in public metadata yet.
organize_usings_batchBatch organize multiple files
Batch organize multiple files
No parameter schema in public metadata yet.
format_document_batchBatch format files in project
Batch format files in project
No parameter schema in public metadata yet.
get_code_actions_at_positionAll Roslyn refactorings at position
All Roslyn refactorings at position
No parameter schema in public metadata yet.
apply_code_action_by_titleApply any refactoring by title
Apply any refactoring by title
No parameter schema in public metadata yet.
implement_missing_membersGenerate interface stubs
Generate interface stubs
No parameter schema in public metadata yet.
encapsulate_fieldField to property
Field to property
No parameter schema in public metadata yet.
inline_variableInline temp variable
Inline temp variable
No parameter schema in public metadata yet.
extract_variableExtract expression to variable
Extract expression to variable
No parameter schema in public metadata yet.
add_null_checksGenerate ArgumentNullException guards
Generate ArgumentNullException guards
No parameter schema in public metadata yet.
generate_equality_membersEquals/GetHashCode/operators
Equals/GetHashCode/operators
No parameter schema in public metadata yet.
generate_test_stubCompilable test skeleton for a method
Compilable test skeleton for a method
No parameter schema in public metadata yet.
get_type_overviewFull type info in one call
Full type info in one call
No parameter schema in public metadata yet.
analyze_methodSignature, callers, outgoing calls and location
Signature, callers, outgoing calls and location
No parameter schema in public metadata yet.
get_file_overviewFile summary with diagnostics
File summary with diagnostics
No parameter schema in public metadata yet.
get_method_sourceSource code by name
Source code by name
No parameter schema in public metadata yet.
get_method_source_batchMultiple method sources in one call
Multiple method sources in one call
No parameter schema in public metadata yet.
get_instantiation_optionsHow to create a type
How to create a type
No parameter schema in public metadata yet.
get_project_healthComposite audit dashboard per project
Composite audit dashboard per project
No parameter schema in public metadata yet.
find_god_objectsDetect over-coupled types via coupling and member-count thresholds
Detect over-coupled types via coupling and member-count thresholds
No parameter schema in public metadata yet.
find_untested_codeFind public surface no test reaches
Find public surface no test reaches
No parameter schema in public metadata yet.
find_testsWhich tests cover a symbol
Which tests cover a symbol
No parameter schema in public metadata yet.
find_type_instantiationsWhere a type is constructed
Where a type is constructed
No parameter schema in public metadata yet.
find_pattern_usagesWhere a type appears in is/as/pattern matches
Where a type appears in is/as/pattern matches
No parameter schema in public metadata yet.
find_throw_sitesWhere an exception type is thrown
Where an exception type is thrown
No parameter schema in public metadata yet.
find_catch_blocksWhere an exception type is caught
Where an exception type is caught
No parameter schema in public metadata yet.
find_async_issuesasync void, blocking-on-async, unforwarded CancellationToken
async void, blocking-on-async, unforwarded CancellationToken
No parameter schema in public metadata yet.
check_architectureEnforce namespace/project dependency rules over the type graph
Enforce namespace/project dependency rules over the type graph
No parameter schema in public metadata yet.
find_naming_violationsNaming audit honoring .editorconfig rules
Naming audit honoring .editorconfig rules
No parameter schema in public metadata yet.
Sponsors
Configuration
DOTNET_SOLUTION_PATHPath to .sln or .slnx file to auto-load on startup
ROSLYN_LOG_LEVELdefault: InformationLogging verbosity: Trace, Debug, Information, Warning, Error
ROSLYN_TIMEOUT_SECONDSdefault: 30Timeout for long-running operations
Readme
SharpLensMcp
A Model Context Protocol (MCP) server providing 92 AI-optimized tools for .NET/C# semantic code analysis, navigation, refactoring, and code generation using Microsoft Roslyn.
Built for AI coding agents - provides compiler-accurate code understanding that AI cannot infer from reading source files alone.
Installation
Via NuGet (Recommended)
dotnet tool install -g SharpLensMcp
Then run with:
sharplens
Via npm
npx -y sharplens-mcp
Build from Source
dotnet build -c Release
dotnet publish -c Release -o ./publish
Claude Code Setup
- Install the tool (pick one):
dotnet tool install -g SharpLensMcp
# or
npx -y sharplens-mcp
Details
- Repository
- github.com/pzalutski-pixel/sharplens-mcp
- Package
sharplens-mcp- Transport
- STDIO
- Registry
- MCP registry, active