roslyn-codelens-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| solution_path | No | Path to the .sln file to analyze. If not provided, the server automatically discovers .sln files by walking up from the current directory. |
Capabilities
Features and capabilities supported by this server
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| logging | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| find_attribute_usagesA | Find all types and members decorated with a specific attribute (e.g., Obsolete, Authorize, Serializable). Returns an envelope with items, totalCount, truncated, limit, and a byProject summary. |
| get_instantiation_optionsA | Answer 'how do I construct this type?' in one call — accessible constructors, static factory methods declared anywhere in the solution, and DI registrations. Constructors report every parameter's type and name, declared accessibility, whether the constructor is compiler-supplied ( |
| inspect_external_assemblyA | Inspect a referenced closed-source assembly. mode='summary' returns namespaces + type counts; mode='namespace' returns public types and members for the given namespace. |
| get_type_overviewA | Get a comprehensive overview of a type in one call: full context (namespace, base class, interfaces, members, DI dependencies), type hierarchy (bases, interfaces, derived types), and diagnostics in the file. More efficient than calling get_symbol_context + get_type_hierarchy + get_diagnostics separately. |
| start_background_taskA | Queue a long-running tool to run in the background. Returns a taskId; poll with get_task_status. Allowed tools: rebuild_solution. |
| find_unused_symbolsA | Find potentially unused types and members (dead code detection). Checks public symbols for references across the solution. Filters out test methods, MCP tools, source-generator output, MEF-composed services, and interop-laid-out fields. Returns an envelope with items, totalCount, truncated, limit (default 500), and a summary including byKind + filteredOut counts. |
| analyze_data_flowB | Analyze data flow within a range of statements in a C# method. Returns variables declared, read, written, captured by lambdas, and flowing in/out of the region. Useful for understanding variable lifecycle before extracting code. |
| find_referencesA | Find all references to a symbol (type, method, property, field, or event) across the solution, each tagged with a kind. Kinds: |
| set_active_solutionA | Switch the active solution. All subsequent tool calls will operate on the selected solution. Use a partial, case-insensitive name (e.g. 'MyProject' matches 'C:/code/MyProject/MyProject.sln'). Returns the full path of the newly active solution. |
| list_trusted_pathsA | Return the current trust state: session-scoped paths, persistent paths, trusted roots, and analyzer policy. |
| revoke_trustA | Remove a previously trusted solution path or trusted root. Removes both session and persistent entries. |
| get_task_statusA | Get the current status of a background task by its taskId. |
| check_architectureA | Check user-supplied layering rules against the solution's real semantic type graph (resolved symbols, not |
| find_implementationsA | Find all classes/structs implementing an interface or extending a class. Returns an envelope with items, totalCount, truncated, and limit. |
| find_circular_dependenciesA | Detect circular dependencies in the project reference graph or namespace dependency graph. Returns an envelope with items sorted by cycle length desc, totalCount, truncated, and limit (default 100). |
| find_god_objectsA | Find types that combine high size with high coupling — 'god classes' that violate single-responsibility and become refactoring nightmares. Sharper signal than find_large_classes alone: a 1000-line internal helper used only by its own namespace is not flagged, but a 200-line class called from 15 different namespaces is. Two axes: size (lines/members/fields) and coupling (incoming/outgoing namespace counts). A type qualifies when it crosses ALL THREE size thresholds AND at least one coupling threshold — keeps DTOs (high field count only) and dispatchers (high member count only) off the list. Defaults: lines >= 300, members >= 15, fields >= 10, incoming-namespaces >= 5, outgoing-namespaces >= 5. Each threshold is independently configurable. BCL namespaces (System., Microsoft.) excluded from outgoing count. Test projects, generated code, interfaces, and nested types are skipped. Sort: total axes exceeded DESC, then line count DESC. |
| apply_code_actionA | Apply a code action (refactoring or fix) by its title. Use get_code_actions first to discover available actions. Defaults to preview mode (returns diff without writing files). Set preview=false to apply changes to disk. |
| find_callersA | Find every call site for a method. Returns an envelope with items, totalCount, truncated, limit, and a byProject summary. |
| rename_symbolA | Safely rename a type or member across the entire solution (Roslyn Renamer). Cascades to references, constructors, overrides, nameof, and XML doc crefs. Defaults to preview mode (returns edits without writing files); set preview=false to apply. New compiler errors the rename would introduce are reported as Conflicts, and apply mode refuses to write them unless force=true. Locals/parameters and file renames are not supported. |
| find_disposable_misuseA | Detect IDisposable / IAsyncDisposable instances at risk of leaking. Two patterns: local variables holding a disposable that aren't wrapped in using/await using/returned/assigned-to-field-or-out-parameter (warning), and bare-expression-statement discards of a disposable creator/factory (error). Returns a summary plus a per-violation list (severity error/warning, location, containing method, snippet). Skips test projects and generated code. Scope: methods only (not constructors/accessors/operators); ownership transfer via method/constructor argument is not detected. Static analysis only — no fix suggestions. |
| find_obsolete_usageA | Find every call site referencing [Obsolete]-marked symbols in the solution, grouped by deprecation message and severity. Sharper than find_attribute_usages for migration-planning workflows: tells you 'we have 5 distinct deprecations pending; this one has 80 sites and is an error; that one has 3 sites and is a warning.' Includes both source-marked and metadata-marked obsoletes (third-party NuGet deprecations are surfaced too). Symbols with zero usages are omitted (no migration needed). Sort: errors first, then by usage count descending, then by symbol name. Test projects skipped. Project filter is case-insensitive. |
| get_method_sourceA | Return the full declaration source (XML docs, attributes, signature, body — original formatting) of one or more members by name: methods (all overloads returned), constructors (request as |
| peek_ilA | Return ilasm-style IL for a single method in a referenced closed-source assembly. Input must be a fully-qualified method name with parameter types. |
| get_project_healthA | Aggregate 7 health dimensions per project in one call: complexity hotspots, large classes, naming violations, unused symbols, reflection usage, async violations, and disposable misuse. Returns counts per dimension plus the top-N hotspots inline (default 5) so the caller can prioritise without follow-up calls. Use this when answering 'how is this project doing?' / 'where should I focus?' / 'what's the technical debt picture?'. Underlying defaults: complexity threshold 10, large-class limits 20 members / 500 lines, unused symbols excludes internals. Test projects are skipped. Project filter is case-insensitive. Sort: projects ASC by name; hotspots sorted by severity proxy per dimension (cyclomatic complexity desc, line count desc, severity enum desc for async/disposable). |
| get_di_registrationsA | Scan IServiceCollection extension methods for DI registrations of a type. Returns an envelope with items sorted by service name, totalCount, truncated, and limit (default 200). |
| find_catch_blocksA | Find the |
| trust_solutionA | Mark a solution path (or directory root) as trusted for analyzer execution. Required before get_diagnostics will load Roslyn analyzer DLLs from the solution. Always confirm with the user before calling this tool — analyzer DLLs run as in-process code. |
| find_large_classesA | Find classes and structs that exceed member count or line count thresholds. Returns an envelope with items sorted worst-first (highest size first), totalCount, truncated, and limit (default 100). |
| get_public_api_surfaceA | Enumerate every public and protected type and member declared in production projects of the active solution. Returns a deterministically-sorted (name ASC) flat list of API entries (kind, fully-qualified name, accessibility, project, file, line) plus per-kind/per-project/per-accessibility summary buckets. Skips test projects, generated code, compiler-generated members, internal symbols, and protected members on sealed types (unreachable). Inherited members are not repeated under derived types — only declared members appear. |
| get_code_actionsA | List available code actions (refactorings and fixes) at a position in a C# file. Optionally specify endLine/endColumn to select a range for extract-method style refactorings. Returns action titles that can be passed to apply_code_action. Returns an envelope with items sorted by kind then title, totalCount, truncated, and limit (default 100). |
| analyze_methodA | Get a comprehensive analysis of a method in one call: signature, location, all callers, and all outgoing calls (methods this method invokes). More efficient than calling find_callers separately. |
| find_naming_violationsA | Check .NET naming convention compliance: PascalCase types/methods/properties, camelCase parameters, I-prefix interfaces, _ prefix private fields. Returns an envelope with items, totalCount, truncated, limit (default 500), and a byRule summary. |
| get_source_generatorsA | List source generators and their output per project. Returns an envelope with items sorted by project then generator name, totalCount, truncated, and limit (default 100). |
| get_extension_methodsA | Answer 'what extension members can I call on this type?' — every extension method and C# 14 extension property applicable to a receiver type, from solution source AND referenced metadata (so BCL LINQ such as |
| get_overloadsA | Return every overload of a method (or constructor) in one call — source AND metadata. Each overload includes the full signature, parameter names/types/modifiers (ref/out/in/params/optional with defaults), return type, accessibility, modifiers (static/virtual/abstract/override/async/extension), generic type parameters, XML doc summary, and source location (empty for metadata). Pass 'Type.Method' for ordinary methods or 'Type.Type' for constructors. Operator overloads are excluded — use get_operators for those. Sort: parameter count ASC, then signature ordinal ASC. |
| generate_test_skeletonA | Emits a test-class skeleton (parseable C#) for a method or type. Pass a type FQN like 'MyApp.Services.OrderService' to get a full test class with one stub per public method, or a method FQN like 'MyApp.Services.OrderService.PlaceOrder' to get a single stub. Returns framework, suggested file path, class name, full file contents (as text), and TodoNotes for things to wire up (e.g. constructor dependencies). The tool does NOT write to disk — agent decides what to do with the text. Pairs naturally with find_uncovered_symbols / get_test_summary. Stubs include happy-path Fact, Theory + InlineData for primitive-param methods, and Assert.Throws assertions per distinct direct-throw exception type. Async (Task-returning) methods detected automatically. Properties, indexers, operators, and constructors are excluded from per-method enumeration. Framework auto-detected from solution test projects (tie → xUnit); override with framework='xunit' / 'nunit' / 'mstest'. |
| unload_solutionA | Unload a previously loaded solution to free memory. Use a partial, case-insensitive name (e.g. 'DcpCore' matches the full path). If the unloaded solution was active, another loaded solution becomes active. Use this when you're done analyzing a codebase and want to reclaim memory. |
| find_tests_for_symbolA | List test methods that exercise the given production symbol. Recognises xUnit, NUnit, and MSTest. Set transitive=true to follow helper methods up to maxDepth levels (default 3, max 5). |
| find_throw_sitesA | Find every place an exception type is thrown across the solution — |
| get_diagnosticsA | List compiler errors and warnings across the solution, optionally including analyzer diagnostics. Analyzer diagnostics require the solution to be trusted (see 'trust_solution'). Returns an envelope with items, totalCount, truncated, limit, and a severity summary. |
| find_async_violationsA | Detect six classes of async/await misuse across all production projects: sync-over-async (.Result, .Wait*, GetAwaiter().GetResult()), async void outside event handlers, missing await in async methods, and fire-and-forget tasks. Returns a summary plus a per-violation list (severity error/warning, location, containing method, snippet). Skips test projects and generated code. Static analysis only — no fix suggestions. |
| list_solutionsA | List all solutions loaded by this server, showing which one is currently active. Each entry includes any projects that were skipped during load (e.g. legacy non-SDK-style projects), with the kind and reason for each skip. Returns an envelope with items sorted by solution path, totalCount, truncated, and limit (default 50). |
| list_running_tasksA | List background tasks that are running or completed within the last 5 minutes. |
| get_project_dependenciesA | Return the project reference graph (direct and transitive dependencies) |
| get_complexity_metricsA | Calculate complexity for members (methods, constructors, properties, indexers, operators). Reports both 'complexity' (cyclomatic - the number of paths, starts at 1) and 'cognitive' (how hard the code is to follow, starts at 0 - a 0 is not a bug), plus 'maxNesting'. The 'metric' parameter selects which of the two the threshold filters on and the sort uses. Returns an envelope with items sorted worst-first, totalCount, truncated, limit (default 100), and a summary with max/avg/overThreshold plus maxCognitive. |
| get_call_graphA | Transitive caller and/or callee graph for a method symbol, depth-bounded with cycle detection. Output is an adjacency-list dict per direction (callees and/or callers), where each visited symbol maps to its outgoing edges. Direction: 'callees' (what this method transitively calls), 'callers' (who reaches this method), or 'both'. External (BCL/NuGet) callees appear as terminal leaves with isExternal=true. Declared signature only on callee side — no virtual dispatch resolution; agent uses find_implementations separately if needed. Callers side resolves dispatch naturally via Roslyn SymbolFinder. Hard cap on total visited nodes (default 500) — sets truncated=true if hit; edges to truncated targets are still recorded against the source node. Use this instead of recursive find_callers / analyze_method calls when you need depth > 1. |
| get_generated_codeB | Inspect generated source code from source generators. Returns an envelope with items sorted by project then file path, totalCount, truncated, and limit (default 200). |
| get_operatorsA | Return every user-defined operator and conversion operator on a type in one call — source AND metadata. Each entry includes the operator kind (such as +, ==, implicit, explicit, plus all comparison and bitwise operators), full signature, parameter names/types/modifiers, return type, accessibility, an IsCheckedVariant flag for .NET 7+ checked operators (op_CheckedAddition etc.), XML doc summary, and source location (empty for metadata). Includes compiler-synthesized record equality operators. Returns declared operators only — operators do not inherit in C#. Pass a type name, simple or fully qualified (e.g. 'Vector2', 'MyApp.Money', 'System.Decimal'). Sort: kind ordinal ASC, then parameter count ASC, then signature ordinal ASC. |
| resolve_stack_traceA | Map a pasted .NET stack trace to file/line/symbol against the loaded solution, undoing compiler name mangling: async/iterator state machines ( |
| analyze_control_flowA | Analyze control flow within a range of statements in a C# method. Returns reachability of start/end points, return statements, and exit points. Useful for detecting unreachable code and understanding branching. |
| find_breaking_changesA | Diff the current solution's public API surface against a baseline (JSON snapshot from a prior get_public_api_surface run, or a baseline .dll file). Reports five change kinds: Removed/KindChanged/AccessibilityNarrowed (Breaking) plus Added/AccessibilityWidened (NonBreaking). Returns a summary plus a per-change list (kind, severity, fully-qualified name, entity kind, project, file, line, details). Sort: Breaking before NonBreaking, then name ASC. Limitations: return type changes, sealed-ness changes, and nullable annotation changes are not detected (PublicApiEntry schema doesn't capture them). |
| go_to_definitionA | Find the source file and line where a symbol is defined. Returns an envelope with items, totalCount, truncated, and limit. |
| load_solutionA | Load a .sln/.slnx solution at runtime and make it the active solution. Both |
| find_uncovered_symbolsA | Report public methods and properties that no test method transitively reaches (within 3 helper hops). Output sorted by cyclomatic complexity descending, with a coverage summary including a riskHotspotCount (uncovered with complexity >= 5). Recognises xUnit, NUnit, MSTest. Reference-based static analysis — does not parse runtime coverage data. |
| get_symbol_contextB | One-shot context dump for a type: namespace, base class, interfaces, injected dependencies, public members |
| search_symbolsA | Search for types, methods, properties, and fields by name (case-insensitive substring match). Returns an envelope with items sorted by match quality (exact → prefix → substring), totalCount, truncated, limit (default 200), and a byKind summary. |
| get_exception_flowA | Which exceptions can escape a method — the 'is calling this safe?' question. Walks the method's callees depth-first (cycle-safe, depth- and node-bounded) collecting every explicit throw, then propagates each one back up the call chain, testing the enclosing |
| change_signatureA | Add, remove, or reorder a method's parameters and update every call site (Roslyn's own change-signature engine). Cascades to overrides and interface implementations, rewrites named and optional arguments, and preserves an extension method's |
| get_test_summaryA | Per-project inventory of test methods. Each test reports framework (xUnit/NUnit/MSTest), attribute kind ([Fact]/[Theory]/[Test]/[TestCase]/[TestMethod]/[DataTestMethod]), data-driven row count, location, and the production symbols it references. Complements find_tests_for_symbol (which goes test → production); this goes project → tests. Use to answer 'what does this test suite cover?' or to break down test counts by framework/attribute. Production projects, generated code, and BCL/framework calls are filtered out of the per-test referenced-symbols list. Project filter is case-insensitive. Sort: tests by (file, line); projects by name ASC. |
| find_reflection_usageA | Detect dynamic/reflection-based usage like Type.GetType, Activator.CreateInstance, MethodInfo.Invoke. Returns an envelope with items, totalCount, truncated, limit (default 500), and a byKind summary. |
| rebuild_solutionA | Force a full reload of the analyzed solution — re-opens the .sln, recompiles all projects, and rebuilds all indexes. Use after changing Directory.Build.props, adding/removing NuGet packages, or when diagnostics seem stale. |
| find_event_subscribersA | Find every += and -= site for an event symbol across the solution. Accepts source events (e.g. 'MyClass.Clicked') or metadata events (e.g. 'System.Diagnostics.Process.Exited'). Each result reports the source location, the resolved handler (method FQN, or a synthetic name like 'lambda at File.cs:N' for inline handlers), and the subscription kind (Subscribe for +=, Unsubscribe for -=). Use this for memory-leak audits (compare subscribe/unsubscribe pairs), UI event subscriber inspection, or when Grep over '+= EventName' would miss qualified or fully-typed subscription sites. Returns an envelope with items sorted by file path then line, totalCount, truncated, and limit (default 500). |
| analyze_change_impactA | Analyze the blast radius of changing a symbol — shows every file, project, and call site affected. Combines find_references and find_callers into a single impact summary. Use before renaming, changing signatures, or removing a type/method. |
| get_code_fixesA | Get available code fixes for a specific diagnostic at a file location. Returns structured text edits that can be reviewed and applied. Returns an envelope with items sorted by title, totalCount, truncated, and limit (default 100). |
| get_file_overviewA | Get a summary of a C# file: which types are defined in it and any compiler diagnostics. Useful for quickly understanding a file's contents without reading it. |
| get_type_hierarchyB | Walk up (base classes, interfaces) and down (derived types) from a type |
| get_nuget_dependenciesC | List NuGet package references for projects in the solution |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MarcelRoozekrans/roslyn-codelens-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server