Sponsored by Deepsite.site

Roslyn Code Lens

Created By
MarcelRoozekrans10 days ago
Overview

Roslyn CodeLens MCP Server

NuGet NuGet Downloads Build Status License

A Roslyn-based MCP server that gives AI agents deep semantic understanding of .NET codebases — type hierarchies, call graphs, DI registrations, diagnostics, and more.

roslyn-codelens-mcp MCP server

Features

  • 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
  • get_type_hierarchy — Walk base classes, interfaces, and derived types
  • get_di_registrations — Scan for DI service registrations
  • get_project_dependencies — Get the project reference graph
  • get_symbol_context — One-shot context dump for any type
  • find_reflection_usage — Detect dynamic/reflection-based usage
  • find_references — Find all references to any symbol (types, methods, properties, fields, events)
  • go_to_definition — Find the source file and line where a symbol is defined
  • 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_circular_dependencies — Detect cycles in project or namespace dependency graphs
  • get_complexity_metrics — Cyclomatic complexity analysis per method
  • find_naming_violations — Check .NET naming convention compliance
  • find_large_classes — Find oversized types by member or line count
  • find_unused_symbols — Dead code detection via reference analysis
  • get_source_generators — List source generators and their output per project
  • get_generated_code — Inspect generated source code from source generators
  • rebuild_solution — Force a full reload of the analyzed solution

Quick Start

VS Code / Visual Studio (via dnx)

Add to your MCP settings (.vscode/mcp.json or VS settings):

{
  "servers": {
    "roslyn-codelens": {
      "type": "stdio",
      "command": "dnx",
      "args": ["RoslynCodeLens.Mcp", "--yes"]
    }
  }
}

Claude Code Plugin

claude install gh:MarcelRoozekrans/roslyn-codelens-mcp

.NET Global Tool

dotnet tool install -g RoslynCodeLens.Mcp

Then add to your MCP client config:

{
  "mcpServers": {
    "roslyn-codelens": {
      "command": "roslyn-codelens-mcp",
      "args": [],
      "transport": "stdio"
    }
  }
}

Usage

The server automatically discovers .sln files by walking up from the current directory. You can also pass a solution path directly:

roslyn-codelens-mcp /path/to/MySolution.sln

Performance

All type lookups use pre-built reverse inheritance maps, member indexes, and attribute indexes for O(1) access. Benchmarked on an i9-12900HK with .NET 10.0.3:

ToolLatencyMemory
find_circular_dependencies288 ns1.3 KB
get_project_dependencies299 ns1.2 KB
go_to_definition442 ns568 B
get_type_hierarchy720 ns856 B
find_implementations804 ns704 B
get_symbol_context1.1 µs1.0 KB
get_source_generators2.6 µs8.3 KB
find_attribute_usages6.8 µs312 B
get_generated_code13 µs9.8 KB
get_diagnostics27 µs23 KB
get_complexity_metrics50 µs5.8 KB
find_large_classes60 µs1.2 KB
get_di_registrations60 µs13 KB
get_nuget_dependencies62 µs16 KB
find_reflection_usage82 µs15 KB
find_callers182 µs38 KB
search_symbols517 µs2.4 KB
find_references927 µs208 KB
find_unused_symbols1.1 ms212 KB
find_naming_violations5.0 ms670 KB
Solution loading (one-time)~928 ms8 MB

Hot Reload

The server watches .cs, .csproj, .props, and .targets files for changes. When a change is detected, affected projects are lazily re-compiled on the next tool query — only stale projects and their downstream dependents are re-compiled, not the full solution.

Location-returning tools include an IsGenerated flag to distinguish source-generator output from hand-written code.

Requirements

  • .NET 10 SDK
  • A .NET solution with compilable projects

Development

dotnet build
dotnet test
dotnet run --project benchmarks/RoslynCodeLens.Benchmarks -c Release

License

MIT

Server Config

{
  "mcpServers": {
    "roslyn-codelens": {
      "type": "stdio",
      "command": "dnx",
      "args": [
        "RoslynCodeLens.Mcp",
        "--yes"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
DeepChatYour AI Partner on Desktop
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server