1. Conduid
  2. Data
  3. pzalutski-pixel/sharplens-mcp
MCP server · Data

pzalutski-pixel/sharplens-mcp

Roslyn-powered MCP server for AI-driven C# semantic analysis, refactoring, and code generation

56Fair

Scored 3 days ago · breakdown

About pzalutski-pixel/sharplens-mcp

pzalutski-pixel/sharplens-mcp is an MCP server published by pzalutski-pixel in the Data category: roslyn-powered MCP server for AI-driven C# semantic analysis, refactoring, and code generation.

The repository has 8 stars and 2 forks, with the last commit 2 months ago. Recent commit activity is the strongest signal that reported issues will get attention.

Install

From source
git clone https://github.com/pzalutski-pixel/sharplens-mcp

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Tools (24)

find_attribute_usagesFind types/members by attribute

Parameters not published.

find_callersImpact analysis - who calls this?

Parameters not published.

find_implementationsInterface/abstract implementations

Parameters not published.

find_path_betweenReachability + the connecting call path(s) between two methods; follows dispatch, with barriers and a checkpoint

Parameters not published.

find_referencesAll references; each classified read/write/invocation/cast/typeof/nameof/attribute; optional `kind` filter

Parameters not published.

get_attributesList attributes on a symbol

Parameters not published.

get_base_typesFull inheritance chain

Parameters not published.

get_call_graphMulti-hop callers/callees graph with depth bound + cycle detection

Parameters not published.

get_containing_memberEnclosing symbol at position

Parameters not published.

get_derived_typesFind all subclasses

Parameters not published.

Show all 24 tools
get_documentationFull XML docs for a symbol with `<inheritdoc>` expanded

Parameters not published.

get_extension_methodsExtensions applying to a type — classic and C# 14 blocks

Parameters not published.

get_external_type_infoInspect NuGet/BCL/external assembly types — members + XML docs

Parameters not published.

get_method_overloadsAll overloads of a method

Parameters not published.

get_method_signatureDetailed signature by name

Parameters not published.

get_super_methodNavigate to the base member / interface members a member implements

Parameters not published.

get_symbol_infoSemantic info at position

Parameters not published.

get_type_hierarchyInheritance chain

Parameters not published.

get_type_membersAll members by type name

Parameters not published.

get_type_members_batchMultiple types in one call

Parameters not published.

go_to_definitionJump to symbol definition

Parameters not published.

resolve_stack_traceMap a pasted stack trace to file/line/symbol, mangling undone

Parameters not published.

search_symbolsGlob pattern search (`*Handler`, `Get*`)

Parameters not published.

semantic_queryMulti-filter search (async, public, etc.)

Parameters not published.

Ask AI

✦

Ask AI about pzalutski-pixel/sharplens-mcp

Powered by Claude · Grounded in docs

I know everything about pzalutski-pixel/sharplens-mcp. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

  • ✓README presentThe repository ships documentation.
  • ✓License declaredUsable under a stated license.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

3 checks have not been run yet.

Releases

v1.6.3v1.6.3 · 16 Aug 2026Patch release — fixes a silent partial-load blind spot in `load_solution`. Fixed `load_solution`** no longer silently drops projects it can't load. When MSBuild can't resolve a `ProjectReference` (or a project fails to load for any…
v1.6.2v1.6.2 · 8 Aug 2026Adds `find_path_between` — point-to-point reachability over the call graph. Added `find_path_between`** — can any source method reach any target method, and through what call chain? A bounded bidirectional search that fills the gap between…
v1.6.1v1.6.1 · 6 Aug 2026Patch release — two bug fixes reported against 1.6.0. Fixed `get_missing_members`** no longer reports an inherited abstract member as missing when an intermediate abstract base already overrides it. Satisfaction is resolved by walking the…
v1.6.0SharpLensMcp 1.6.0 · 3 Jul 2026MCP server for .NET/C# — **91** semantic analysis, navigation, refactoring, and code-generation tools built on Microsoft Roslyn 5.3. Added — 24 new tools (67 → 91) `move_type_to_file`, `split_type` — move a type into its own file, or split…
v1.5.3v1.5.3 - 5 new audit tools + 20 bug fixes · 20 May 2026Added `get_external_type_info` — inspect NuGet/BCL/external-assembly types: members, signatures, XML doc summaries `get_call_graph` — multi-hop callers/callees with depth/node caps and cycle detection `find_untested_code` — public surface…

README

SharpLensMcp

NuGet npm

A Model Context Protocol (MCP) server providing 62 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

  1. Install the tool (pick one):
dotnet tool install -g SharpLensMcp
# or
npx -y sharplens-mcp
  1. Create .mcp.json in your project root:
{
  "mcpServers": {
    "sharplens": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "sharplens-mcp"],
      "env": {
        "DOTNET_SOLUTION_PATH": "/path/to/your/Solution.sln (or .slnx)"
      }
    }
  }
}
  1. Restart Claude Code to load the MCP server

  2. Verify by asking Claude to run a health check on the Roslyn server

Why Use This with Claude Code?

Claude Code has native LSP support for basic navigation (go-to-definition, find references). SharpLensMcp adds deep semantic analysis:

Capability Native LSP SharpLensMcp
Go to definition ✅ ✅
Find references ✅ ✅
Find async methods missing CancellationToken ❌ ✅
Impact analysis (what breaks?) ❌ ✅
Dead code detection ❌ ✅
Complexity metrics ❌ ✅
Safe refactoring with preview ❌ ✅
Batch operations ❌ ✅

Configuration

Environment Variable Description Default
DOTNET_SOLUTION_PATH Path to .sln or .slnx file to auto-load on startup None (must call load_solution)
SHARPLENS_ABSOLUTE_PATHS Use absolute paths instead of relative false (relative paths save tokens)
ROSLYN_LOG_LEVEL Logging verbosity: Trace, Debug, Information, Warning, Error Information
ROSLYN_TIMEOUT_SECONDS Timeout for long-running operations 30
ROSLYN_MAX_DIAGNOSTICS Maximum diagnostics to return 100
ROSLYN_ENABLE_SEMANTIC_CACHE Enable semantic model caching true (set to false to disable)

If DOTNET_SOLUTION_PATH is not set, you must call the load_solution tool before using other tools.

AI Agent Configuration Tips

AI models may have trained bias toward using their native tools (Grep, Read, LSP) instead of MCP server tools, even when SharpLensMcp provides better capabilities.

To ensure optimal tool usage:

  1. Claude Code: Add to your project's CLAUDE.md:

    For C# code analysis, prefer SharpLensMcp tools over native tools:
    - Use `roslyn:search_symbols` instead of Grep for finding symbols
    - Use `roslyn:get_method_source` instead of Read for viewing methods
    - Use `roslyn:find_references` for semantic (not text) references
    
  2. Other MCP clients: Configure tool priority in your agent's system prompt

The semantic analysis from Roslyn is more accurate than text-based search, especially for overloaded methods, partial classes, and inheritance hierarchies.

Agent Responsibility: Document Synchronization

Important: SharpLensMcp maintains an in-memory representation of your solution for fast queries. When files are modified externally (via Edit/Write tools), the agent is responsible for synchronizing changes.

When to call sync_documents:

Action Call sync_documents?
Used Edit tool to modify .cs files ✅ Yes
Used Write tool to create new .cs files ✅ Yes
Deleted .cs files ✅ Yes
Used SharpLensMcp refactoring tools (rename, extract, etc.) ❌ No (auto-updated)
Modified .csproj files ❌ No (use load_solution instead)

Usage:

# After editing specific files
sync_documents(filePaths: ["src/MyClass.cs", "src/MyService.cs"])

# After bulk changes - sync all documents
sync_documents()

Why this design?

This mirrors how LSP (Language Server Protocol) works - the client (editor) notifies the server of changes. This approach:

  • Eliminates race conditions (agent controls timing)
  • Avoids file watcher complexity and platform quirks
  • Is faster than full solution reload
  • Gives agents explicit control over workspace state

If you don't sync: Queries may return stale data (old method signatures, missing new files, etc.)

Features

  • 62 Semantic Analysis Tools - Navigation, refactoring, code generation, diagnostics, discovery
  • AI-Optimized Descriptions - Clear USAGE/OUTPUT/WORKFLOW patterns
  • Structured Responses - Consistent success/error/data format with suggestedNextTools
  • Zero-Based Coordinates - Clear warnings to prevent off-by-one errors
  • Preview Mode - Safe refactoring with preview before apply
  • Batch Operations - Multiple lookups in one call to reduce context usage

Tool Categories

Navigation & Discovery (17 tools)

Tool Description
get_symbol_info Semantic info at position
go_to_definition Jump to symbol definition
find_references All references across solution
find_implementations Interface/abstract implementations
find_callers Impact analysis - who calls this?
get_type_hierarchy Inheritance chain
search_symbols Glob pattern search (*Handler, Get*)
semantic_query Multi-filter search (async, public, etc.)
get_type_members All members by type name
get_type_members_batch Multiple types in one call
get_method_signature Detailed signature by name
get_derived_types Find all subclasses
get_base_types Full inheritance chain
get_attributes List attributes on a symbol
get_containing_member Enclosing symbol at position
get_method_overloads All overloads of a method
find_attribute_usages Find types/members by attribute

Analysis (11 tools)

Tool Description
get_diagnostics Compiler errors/warnings
analyze_data_flow Variable assignments and usage
analyze_control_flow Branching/reachability
analyze_change_impact What breaks if changed?
check_type_compatibility Can A assign to B?
get_outgoing_calls What does this method call?
find_unused_code Dead code detection
validate_code Compile check without writing
get_complexity_metrics Cyclomatic, nesting, LOC, cognitive
find_circular_dependencies Project and namespace cycle detection
get_missing_members Unimplemented interface/abstract members

Refactoring (14 tools)

Tool Description
rename_symbol Safe rename across solution
change_signature Add/remove/reorder parameters
extract_method Extract with data flow analysis
extract_interface Generate interface from class
generate_constructor From fields/properties
organize_usings Sort and remove unused
organize_usings_batch Batch organize multiple files
format_document_batch Batch format files in project
get_code_actions_at_position All Roslyn refactorings at position
apply_code_action_by_title Apply any refactoring by title
implement_missing_members Generate interface stubs
encapsulate_field Field to property
inline_variable Inline temp variable
extract_variable Extract expression to variable

Code Generation (2 tools)

Tool Description
add_null_checks Generate ArgumentNullException guards
generate_equality_members Equals/GetHashCode/operators

Compound Tools (6 tools)

Tool Description
get_type_overview Full type info in one call
analyze_method Signature + callers + outgoing calls + location
get_file_overview File summary with diagnostics
get_method_source Source code by name
get_method_source_batch Multiple method sources in one call
get_instantiation_options How to create a type

Discovery (2 tools)

Tool Description
get_di_registrations Scan DI service registrations
find_reflection_usage Detect reflection/dynamic usage

Infrastructure (10 tools)

Tool Description
health_check Server status
load_solution Load .sln/.slnx for analysis
sync_documents Sync file changes into loaded solution
get_project_structure Solution structure
dependency_graph Project dependencies
get_code_fixes Available fixes for a diagnostic
apply_code_fix Apply a specific code fix
get_nuget_dependencies NuGet package listing per project
get_source_generators List active source generators
get_generated_code View generated source code

Other MCP Clients

For MCP clients other than Claude Code, add to your configuration:

{
  "mcpServers": {
    "sharplens": {
      "command": "sharplens",
      "args": [],
      "env": {
        "DOTNET_SOLUTION_PATH": "/path/to/your/Solution.sln (or .slnx)"
      }
    }
  }
}

Usage

  1. Load a solution: Call roslyn:load_solution with path to .sln or .slnx file (or set DOTNET_SOLUTION_PATH)
  2. Analyze code: Use any of the 57 tools for navigation, analysis, refactoring
  3. Refactor safely: Preview changes before applying with preview: true

Architecture

MCP Client (AI Agent)
        | stdin/stdout (JSON-RPC 2.0)
        v
   SharpLensMcp
   - Protocol handling
   - 57 AI-optimized tools
        |
        v
Microsoft.CodeAnalysis (Roslyn)
  - MSBuildWorkspace
  - SemanticModel
  - SymbolFinder

Requirements

  • .NET 8.0 SDK or later — works with .NET 8, 9, 10, and future versions. Analyzes any .NET 8+ project/solution.
  • MCP-compatible AI agent

Development

Adding New Tools

  1. Add method to src/RoslynService.cs:
public async Task<object> YourToolAsync(string param1, int? param2 = null)
{
    EnsureSolutionLoaded();
    // Your logic...
    return CreateSuccessResponse(
        data: new { /* results */ },
        suggestedNextTools: new[] { "next_tool_hint" }
    );
}
  1. Add tool definition to src/McpServer.cs in HandleListToolsAsync

  2. Add routing to src/McpServer.cs in HandleToolCallAsync switch

  3. Build and publish:

dotnet build -c Release
dotnet publish -c Release -o ./publish

Key Files

File Purpose
src/RoslynService.cs Tool implementations (57 methods)
src/McpServer.cs MCP protocol, tool definitions, routing

License

MIT - See LICENSE for details.

README copy captured when this server was indexed; it may lag the repository. The original is authoritative.

Questions

About pzalutski-pixel/sharplens-mcp

How do I install pzalutski-pixel/sharplens-mcp?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is pzalutski-pixel/sharplens-mcp safe to use with an AI agent?

Its trust score is 56 out of 100 (fair). It passes 2 of the 3 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is pzalutski-pixel/sharplens-mcp still maintained?

Yes — the latest release is v1.6.3 (16 Aug 2026), and the last commit was 2 months ago. The repository has 8 stars.