### Run SharpLensMcp after NuGet installation Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Execute the installed SharpLensMcp tool from the command line. This command starts the MCP server. ```bash sharplens ``` -------------------------------- ### Claude Code Setup: Install SharpLensMcp Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Instructions for installing SharpLensMcp, offering both NuGet and npm options. Choose one method for installation. ```bash dotnet tool install -g SharpLensMcp # or npx -y sharplens-mcp ``` -------------------------------- ### Install and Run SharpLensMcp Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Commands to install the tool globally via NuGet or execute it directly using npx. ```bash # Install globally dotnet tool install -g SharpLensMcp # Run the server sharplens ``` ```bash npx -y sharplens-mcp ``` -------------------------------- ### Install SharpLensMcp via NuGet Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Install the SharpLensMcp command-line tool globally using the .NET CLI. This is the recommended installation method. ```bash dotnet tool install -g SharpLensMcp ``` -------------------------------- ### Install SharpLensMcp via npm Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Install and run the SharpLensMcp package using npm. This is an alternative installation method. ```bash npx -y sharplens-mcp ``` -------------------------------- ### Claude Code Setup: .mcp.json Configuration Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Example configuration file for setting up SharpLensMcp as an MCP server within a project. This file defines the server type, command, arguments, and environment variables. ```json { "mcpServers": { "sharplens": { "type": "stdio", "command": "npx", "args": ["-y", "sharplens-mcp"], "env": { "DOTNET_SOLUTION_PATH": "/path/to/your/Solution.sln (or .slnx)" } } } } ``` -------------------------------- ### MCP Client Configuration Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Configuration example for other MCP clients to connect to SharpLens. ```APIDOC ## MCP Client Configuration ### Description Configuration example for other MCP clients to connect to SharpLens. ### Configuration ```json { "mcpServers": { "sharplens": { "command": "sharplens", "args": [], "env": { "DOTNET_SOLUTION_PATH": "/path/to/your/Solution.sln (or .slnx)" } } } } ``` ``` -------------------------------- ### Get NuGet Dependencies Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Lists all NuGet package references for a specified project. ```json { "name": "roslyn:get_nuget_dependencies", "arguments": { "projectName": "MyApp.Api" } } ``` -------------------------------- ### Get File Overview Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Provides a comprehensive overview of a file, including diagnostics summary, type declarations, namespace, and line count. ```json { "name": "roslyn:get_file_overview", "arguments": { "filePath": "/path/to/src/MyService.cs" } } ``` -------------------------------- ### Get Instantiation Options Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves all available methods for creating an instance of a type, such as constructors, factory methods, and builder patterns. Provides hints for types implementing IDisposable. ```json { "name": "roslyn:get_instantiation_options", "arguments": { "typeName": "HttpClient" } } ``` -------------------------------- ### Get Dependency Injection Registrations Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Scans a project for dependency injection service registrations, returning details on AddScoped, AddTransient, and AddSingleton. ```json { "name": "roslyn:get_di_registrations", "arguments": { "projectName": "MyApp.Api" } } ``` -------------------------------- ### Sync Documents with SharpLensMcp Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Example usage of the `sync_documents` function to update SharpLensMcp's in-memory representation of the solution after external file modifications. This is crucial for query accuracy. ```bash # After editing specific files sync_documents(filePaths: ["src/MyClass.cs", "src/MyService.cs"]) # After bulk changes - sync all documents sync_documents() ``` -------------------------------- ### Get Type Overview Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves a comprehensive overview of a type, including its information, base types, and member counts. ```json { "name": "roslyn:get_type_overview", "arguments": { "typeName": "UserService" } } ``` -------------------------------- ### Uninstall SharpLens MCP .NET Tool Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/npm/README.md If installed via npx, use this dotnet CLI command to uninstall the SharpLensMcp .NET global tool. ```bash dotnet tool uninstall --global SharpLensMcp ``` -------------------------------- ### Get Complexity Metrics via roslyn:get_complexity_metrics Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Calculates complexity metrics for a specific method or an entire file. ```json // For entire file { "name": "roslyn:get_complexity_metrics", "arguments": { "filePath": "/path/to/src/ComplexService.cs" } } // For specific method { "name": "roslyn:get_complexity_metrics", "arguments": { "filePath": "/path/to/src/ComplexService.cs", "line": 25, "column": 10, "metrics": ["cyclomatic", "nesting", "cognitive"] } } // Response { "success": true, "data": { "cyclomatic": 12, "nesting": 4, "loc": 85, "parameters": 5, "cognitive": 18 } } ``` -------------------------------- ### Get Diagnostics via roslyn:get_diagnostics Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves compiler errors, warnings, and info messages for a specific file or an entire project. ```json // For specific file { "name": "roslyn:get_diagnostics", "arguments": { "filePath": "/path/to/src/MyClass.cs", "severity": "Error" } } // For entire project { "name": "roslyn:get_diagnostics", "arguments": { "projectPath": "/path/to/MyProject.csproj" } } ``` -------------------------------- ### roslyn:get_code_actions_at_position Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Get all available code actions (fixes + refactorings) at a position. ```APIDOC ## POST roslyn:get_code_actions_at_position ### Description Get all available code actions (fixes + refactorings) at a position. ### Request Body - **filePath** (string) - Required - Path to the source file. - **line** (integer) - Required - Line number. - **column** (integer) - Required - Column number. - **includeCodeFixes** (boolean) - Optional - Include code fixes. - **includeRefactorings** (boolean) - Optional - Include refactorings. ### Request Example { "name": "roslyn:get_code_actions_at_position", "arguments": { "filePath": "/path/to/src/MyClass.cs", "line": 15, "column": 10, "includeCodeFixes": true, "includeRefactorings": true } } ``` -------------------------------- ### Get Symbol Info Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves detailed semantic information about a code symbol at a specific file position. Uses zero-based coordinates for line and column. ```json // Request (editor line 14 → pass line 13) { "name": "roslyn:get_symbol_info", "arguments": { "filePath": "/path/to/src/MyService.cs", "line": 13, "column": 15 } } // Response { "success": true, "data": { "name": "ProcessData", "kind": "Method", "fullyQualifiedName": "MyNamespace.MyService.ProcessData(string)", "containingType": "MyNamespace.MyService", "containingNamespace": "MyNamespace", "returnType": "Task", "isAsync": true, "parameters": [ { "name": "input", "type": "string" } ], "location": { "filePath": "src/MyService.cs", "line": 13, "column": 15 } } } ``` -------------------------------- ### Get Method Source Code in Batch Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Fetch source code for multiple methods efficiently in a single call using 'roslyn:get_method_source_batch'. Useful for bulk analysis or refactoring. ```json { "name": "roslyn:get_method_source_batch", "arguments": { "methods": [ { "typeName": "UserService", "methodName": "ValidateUser" }, { "typeName": "UserService", "methodName": "CreateUser" }, { "typeName": "OrderService", "methodName": "ProcessOrder" } ], "maxMethods": 20 } } ``` -------------------------------- ### Get Method Source Code Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieve the complete source code of a method using 'roslyn:get_method_source'. Provides the method's signature, location, and full source text. ```json { "name": "roslyn:get_method_source", "arguments": { "typeName": "UserService", "methodName": "ValidateUser" } } ``` ```json { "success": true, "data": { "typeName": "MyApp.Services.UserService", "methodName": "ValidateUser", "signature": "bool UserService.ValidateUser(User user)", "location": { "filePath": "src/Services/UserService.cs", "startLine": 45, "endLine": 58 }, "fullSource": "private bool ValidateUser(User user)\n{\n if (user == null) return false;\n return !string.IsNullOrEmpty(user.Email);\n}", "lineCount": 5 } } ``` -------------------------------- ### Claude Code: Prefer SharpLensMcp Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Configuration snippet for `CLAUDE.md` to guide Claude Code AI to prefer SharpLensMcp tools over native LSP tools for C# code analysis, ensuring more accurate results. ```markdown 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 ``` -------------------------------- ### Get Base Types Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieve the complete inheritance chain for a given type by name using 'roslyn:get_base_types'. This helps in understanding a type's lineage. ```json { "name": "roslyn:get_base_types", "arguments": { "typeName": "SqlUserRepository" } } ``` -------------------------------- ### Get Type Hierarchy Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Explore the inheritance structure of a type using 'roslyn:get_type_hierarchy'. This command returns base types, interfaces, and derived types. ```json { "name": "roslyn:get_type_hierarchy", "arguments": { "filePath": "/path/to/src/BaseService.cs", "line": 10, "column": 17, "maxDerivedTypes": 50 } } ``` ```json { "success": true, "data": { "typeName": "MyApp.Services.BaseService", "baseTypes": [ { "name": "object", "kind": "Class" } ], "interfaces": [ { "name": "IService", "kind": "Interface" } ], "derivedTypes": [ { "name": "UserService", "kind": "Class" }, { "name": "ProductService", "kind": "Class" } ] } } ``` -------------------------------- ### Get Type Members in Batch Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Efficiently fetch members for multiple types simultaneously with 'roslyn:get_type_members_batch'. Allows specifying member kind, verbosity, and maximum results per type. ```json { "name": "roslyn:get_type_members_batch", "arguments": { "typeNames": ["UserService", "ProductService", "OrderController"], "memberKind": "Method", "verbosity": "summary", "maxResultsPerType": 50 } } ``` -------------------------------- ### Get Method Signature Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Obtain detailed signature information for a specific method, including parameters, return type, and modifiers, using 'roslyn:get_method_signature'. Useful for overload resolution. ```json { "name": "roslyn:get_method_signature", "arguments": { "typeName": "UserService", "methodName": "GetUserByIdAsync", "overloadIndex": 0 } } ``` ```json { "success": true, "data": { "signature": "Task UserService.GetUserByIdAsync(int id, CancellationToken cancellationToken)", "parameters": [ { "name": "id", "type": "int", "isOptional": false }, { "name": "cancellationToken", "type": "CancellationToken", "isOptional": true } ], "returnType": "Task", "isAsync": true } } ``` -------------------------------- ### Build SharpLensMcp from Source Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Build and publish the SharpLensMcp project from its source code using the .NET CLI. This is useful for development or custom builds. ```bash dotnet build -c Release dotnet publish -c Release -o ./publish ``` -------------------------------- ### Configure MCP Server with SharpLens Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/npm/README.md This JSON configuration sets up an MCP server using sharplens-mcp via stdio. Ensure the DOTNET_SOLUTION_PATH environment variable points to your solution file. ```json { "mcpServers": { "sharplens": { "type": "stdio", "command": "npx", "args": ["-y", "sharplens-mcp"], "env": { "DOTNET_SOLUTION_PATH": "/path/to/your/Solution.sln" } } } } ``` -------------------------------- ### Infrastructure Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools for managing the SharpLens environment and solution loading. ```APIDOC ## Infrastructure Tools ### Description Tools for managing the SharpLens environment and solution loading. ### Tools - **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. ``` -------------------------------- ### POST roslyn:get_project_structure Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves the solution and project structure including references and documents. ```APIDOC ## POST roslyn:get_project_structure ### Description Get solution/project structure including references and documents. ### Method POST ### Endpoint tools/call ### Request Body - **name** (string) - Required - "roslyn:get_project_structure" - **arguments** (object) - Optional - Configuration for structure retrieval (summaryOnly, includeReferences, includeDocuments, maxProjects) ``` -------------------------------- ### Get Derived Types Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Find all types that inherit from a specified base type using 'roslyn:get_derived_types'. Supports transitive inheritance to discover all descendants. ```json { "name": "roslyn:get_derived_types", "arguments": { "baseTypeName": "BaseService", "includeTransitive": true, "maxResults": 100 } } ``` -------------------------------- ### POST roslyn:load_solution Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Loads a .NET solution for analysis. Must be called before using any other analysis tools unless DOTNET_SOLUTION_PATH is set. ```APIDOC ## POST roslyn:load_solution ### Description Load a .NET solution for analysis. Must be called before using any other analysis tools unless DOTNET_SOLUTION_PATH is set. ### Method POST ### Endpoint tools/call ### Request Body - **name** (string) - Required - "roslyn:load_solution" - **arguments** (object) - Required - Contains solutionPath ### Response #### Success Response (200) - **success** (boolean) - Operation status - **data** (object) - Solution metadata including project and document counts ``` -------------------------------- ### Configure SharpLens MCP Server Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Add this configuration to your MCP client settings to integrate the SharpLens server, ensuring the DOTNET_SOLUTION_PATH environment variable points to your target solution file. ```json { "mcpServers": { "sharplens": { "command": "sharplens", "args": [], "env": { "DOTNET_SOLUTION_PATH": "/path/to/your/Solution.sln (or .slnx)" } } } } ``` -------------------------------- ### Organize Usings in Batch Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Organizes using directives for multiple C# files in a project, with an option for previewing changes. ```json { "name": "roslyn:organize_usings_batch", "arguments": { "projectName": "MyApp.Services", "filePattern": "*.cs", "preview": true } } ``` -------------------------------- ### Call roslyn:load_solution Tool Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt JSON-RPC request and response for loading a .NET solution into the analysis workspace. ```json // Request { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "roslyn:load_solution", "arguments": { "solutionPath": "/path/to/MySolution.sln" } } } // Response { "success": true, "data": { "solutionPath": "/path/to/MySolution.sln", "projectCount": 8, "documentCount": 245 }, "meta": { "suggestedNextTools": [ "get_project_structure to see solution structure", "search_symbols to find code", "get_diagnostics to check for issues" ] } } ``` -------------------------------- ### Generate Project Dependency Graph Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Visualizes project dependencies as a graph in either JSON or Mermaid diagram format. ```json { "name": "roslyn:dependency_graph", "arguments": { "format": "json" } } ``` ```json { "name": "roslyn:dependency_graph", "arguments": { "format": "mermaid" } } ``` -------------------------------- ### POST roslyn:sync_documents Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Synchronizes document changes from disk into the loaded solution. ```APIDOC ## POST roslyn:sync_documents ### Description Synchronize document changes from disk into the loaded solution. Call this after using Edit/Write tools to ensure Roslyn has fresh content. ### Method POST ### Endpoint tools/call ### Request Body - **name** (string) - Required - "roslyn:sync_documents" - **arguments** (object) - Optional - Contains filePaths array ### Response #### Success Response (200) - **success** (boolean) - Operation status - **data** (object) - Sync statistics including updated, added, and removed counts ``` -------------------------------- ### Call roslyn:sync_documents Tool Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt JSON-RPC requests for synchronizing specific files or the entire solution after modifications. ```json // Sync specific files after editing { "name": "roslyn:sync_documents", "arguments": { "filePaths": ["src/MyClass.cs", "src/MyService.cs"] } } // Sync all documents (refresh entire solution) { "name": "roslyn:sync_documents", "arguments": {} } // Response { "success": true, "data": { "updated": 2, "added": 0, "removed": 0, "totalSynced": 2, "updatedFiles": ["src/MyClass.cs", "src/MyService.cs"] } } ``` -------------------------------- ### Call roslyn:get_project_structure Tool Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt JSON-RPC requests for retrieving project structure, supporting summary-only or full-detail modes. ```json // Request for large solutions { "name": "roslyn:get_project_structure", "arguments": { "summaryOnly": true, "projectNamePattern": "*.Application" } } // Full structure request { "name": "roslyn:get_project_structure", "arguments": { "includeReferences": true, "includeDocuments": true, "maxProjects": 10 } } ``` -------------------------------- ### Get Type Members Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieve members (methods, properties, fields, events) of a type using 'roslyn:get_type_members'. Supports filtering by member kind and including inherited members. ```json { "name": "roslyn:get_type_members", "arguments": { "typeName": "UserService" } } ``` ```json { "name": "roslyn:get_type_members", "arguments": { "typeName": "MyNamespace.UserService", "includeInherited": true, "memberKind": "Method", "verbosity": "compact" } } ``` -------------------------------- ### Implement a New Tool in RoslynService Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Add a new tool method to the RoslynService class. Ensure the solution is loaded before executing logic and return a success response with optional next tool hints. ```csharp public async Task YourToolAsync(string param1, int? param2 = null) { EnsureSolutionLoaded(); // Your logic... return CreateSuccessResponse( data: new { /* results */ }, suggestedNextTools: new[] { "next_tool_hint" } ); } ``` -------------------------------- ### Go To Definition Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Navigates directly to the definition of a code symbol. Returns the definition location without searching for all references. ```json // Request { "name": "roslyn:go_to_definition", "arguments": { "filePath": "/path/to/src/Controller.cs", "line": 25, "column": 12 } } // Response { "success": true, "data": { "symbol": { "name": "UserService", "kind": "NamedType", "fullyQualifiedName": "MyApp.Services.UserService" }, "definition": { "filePath": "src/Services/UserService.cs", "line": 8, "column": 17 } } } ``` -------------------------------- ### Generate Constructor from Fields/Properties Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Generates a constructor for a given type, optionally including properties. Specify the file path, line, and column for insertion. ```json { "name": "roslyn:generate_constructor", "arguments": { "filePath": "/path/to/src/UserDto.cs", "line": 5, "column": 17, "includeProperties": true } } ``` -------------------------------- ### Compound Analysis Tools Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Tools for retrieving comprehensive overviews of types, methods, and files. ```APIDOC ## POST roslyn:get_type_overview ### Description Get comprehensive type overview: type info, base types, and member counts. ## POST roslyn:analyze_method ### Description Get comprehensive method analysis: signature, callers, outgoing calls, and location. ## POST roslyn:get_file_overview ### Description Get comprehensive file overview: diagnostics summary, type declarations, namespace, and line count. ## POST roslyn:get_instantiation_options ### Description Get all ways to create an instance of a type: constructors, factory methods, and builder patterns. ``` -------------------------------- ### Discovery Tools Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Tools for scanning project structure, dependencies, and attribute usage. ```APIDOC ## POST roslyn:find_attribute_usages ### Description Find all types and members decorated with a specific attribute. ## POST roslyn:get_di_registrations ### Description Scan for dependency injection service registrations. ## POST roslyn:find_reflection_usage ### Description Detect dynamic/reflection-based type and method usage. ## POST roslyn:find_circular_dependencies ### Description Detect cycles in project or namespace dependency graphs. ## POST roslyn:get_nuget_dependencies ### Description List NuGet package references per project. ## POST roslyn:dependency_graph ### Description Visualize project dependencies as a graph (JSON or Mermaid). ``` -------------------------------- ### Apply a code action with roslyn:apply_code_action_by_title Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Executes a specific code action identified by its title. ```json // Request { "name": "roslyn:apply_code_action_by_title", "arguments": { "filePath": "/path/to/src/MyClass.cs", "line": 15, "column": 10, "title": "Convert to expression body", "preview": true } } ``` -------------------------------- ### Organize Usings in a File Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Sorts and removes unused using directives within a specified C# file. ```json { "name": "roslyn:organize_usings", "arguments": { "filePath": "/path/to/src/MyClass.cs" } } ``` -------------------------------- ### Find References Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Locates all occurrences of a symbol throughout the entire solution. Can be limited by maxResults. ```json // Request { "name": "roslyn:find_references", "arguments": { "filePath": "/path/to/src/UserService.cs", "line": 10, "column": 20, "maxResults": 50 } } // Response { "success": true, "data": { "symbolName": "GetUserById", "symbolKind": "Method", "totalReferences": 15, "references": [ { "filePath": "src/Controllers/UserController.cs", "line": 45, "column": 28, "lineText": "var user = await _userService.GetUserById(id);", "kind": "read" } ] } } ``` -------------------------------- ### Find Implementations Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Identifies all implementations of a given interface or abstract class. Results can be limited by maxResults. ```json // Request { "name": "roslyn:find_implementations", "arguments": { "filePath": "/path/to/src/IUserRepository.cs", "line": 5, "column": 18, "maxResults": 50 } } // Response { "success": true, "data": { "baseType": "MyApp.Interfaces.IUserRepository", "totalImplementations": 2, "implementations": [ { "name": "MyApp.Data.SqlUserRepository", "kind": "Class", "locations": [{ "filePath": "src/Data/SqlUserRepository.cs", "line": 12, "column": 17 }] }, { "name": "MyApp.Data.InMemoryUserRepository", "kind": "Class", "locations": [{ "filePath": "src/Data/InMemoryUserRepository.cs", "line": 8, "column": 17 }] } ] } } ``` -------------------------------- ### Navigation & Discovery Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools for navigating code, finding symbols, and discovering code relationships. ```APIDOC ## Navigation & Discovery Tools ### Description Tools for navigating code, finding symbols, and discovering code relationships. ### Tools - **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. ``` -------------------------------- ### roslyn:go_to_definition Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Navigates directly to the definition of a code symbol at a specified location. ```APIDOC ## roslyn:go_to_definition ### Description Fast navigation to symbol definition. Returns the definition location without finding all references. ### Method POST ### Endpoint /roslyn/go_to_definition ### Request Body - **filePath** (string) - Required - The path to the source file. - **line** (integer) - Required - The zero-based line number. - **column** (integer) - Required - The zero-based column number. ### Request Example ```json { "name": "roslyn:go_to_definition", "arguments": { "filePath": "/path/to/src/Controller.cs", "line": 25, "column": 12 } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains the symbol and definition information. - **symbol** (object) - Information about the symbol. - **name** (string) - The name of the symbol. - **kind** (string) - The type of the symbol. - **fullyQualifiedName** (string) - The fully qualified name of the symbol. - **definition** (object) - Information about the symbol's definition. - **filePath** (string) - The file path of the definition. - **line** (integer) - The line number of the definition. - **column** (integer) - The column number of the definition. #### Response Example ```json { "success": true, "data": { "symbol": { "name": "UserService", "kind": "NamedType", "fullyQualifiedName": "MyApp.Services.UserService" }, "definition": { "filePath": "src/Services/UserService.cs", "line": 8, "column": 17 } } } ``` ``` -------------------------------- ### roslyn:organize_usings Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Sorts and removes unused using directives in a file or across a project. ```APIDOC ## POST roslyn:organize_usings ### Description Sort and remove unused using directives in a single file. ### Request Body - **filePath** (string) - Required - Path to the file. ## POST roslyn:organize_usings_batch ### Description Organize using directives for multiple files in a project. ### Request Body - **projectName** (string) - Required - Name of the project. - **filePattern** (string) - Optional - Pattern to match files. - **preview** (boolean) - Optional - Whether to preview changes. ``` -------------------------------- ### roslyn:apply_code_action_by_title Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Apply a code action by its title. ```APIDOC ## POST roslyn:apply_code_action_by_title ### Description Apply a code action by its title. ### Request Body - **filePath** (string) - Required - Path to the source file. - **line** (integer) - Required - Line number. - **column** (integer) - Required - Column number. - **title** (string) - Required - Title of the code action. - **preview** (boolean) - Optional - Whether to preview changes. ### Request Example { "name": "roslyn:apply_code_action_by_title", "arguments": { "filePath": "/path/to/src/MyClass.cs", "line": 15, "column": 10, "title": "Convert to expression body", "preview": true } } ``` -------------------------------- ### Search Symbols Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Searches for types, methods, or properties by name across the solution. Supports glob patterns for queries and namespace filtering. ```json // Find all handlers { "name": "roslyn:search_symbols", "arguments": { "query": "*Handler", "kind": "Class", "maxResults": 50 } } // Find methods starting with "Get" { "name": "roslyn:search_symbols", "arguments": { "query": "Get*", "kind": "Method", "namespaceFilter": "MyApp.Services.*" } } // Response { "success": true, "data": { "query": "*Handler", "hasMore": false, "results": [ { "name": "CreateUserHandler", "fullyQualifiedName": "MyApp.Handlers.CreateUserHandler", "kind": "NamedType", "location": { "filePath": "src/Handlers/CreateUserHandler.cs", "line": 10, "column": 17 } } ] } } ``` -------------------------------- ### roslyn:get_complexity_metrics Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Calculates complexity metrics for a method or an entire file. ```APIDOC ## roslyn:get_complexity_metrics ### Description Get complexity metrics for a method or entire file. ### Request Body - **filePath** (string) - Required - Path to the file. - **line** (integer) - Optional - Line number for method-specific analysis. - **column** (integer) - Optional - Column number for method-specific analysis. - **metrics** (array) - Optional - List of metrics to calculate (e.g., ["cyclomatic", "nesting", "cognitive"]). ``` -------------------------------- ### Discovery Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools for discovering specific code patterns and usages. ```APIDOC ## Discovery Tools ### Description Tools for discovering specific code patterns and usages. ### Tools - **get_di_registrations**: Scan DI service registrations. - **find_reflection_usage**: Detect reflection/dynamic usage. ``` -------------------------------- ### Find Circular Dependencies Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Detects cycles in project or namespace dependency graphs. Can specify the analysis level. ```json { "name": "roslyn:find_circular_dependencies", "arguments": {} } ``` ```json { "name": "roslyn:find_circular_dependencies", "arguments": { "level": "namespace" } } ``` -------------------------------- ### Uninstall SharpLens MCP Globally Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/npm/README.md Use this npm command to uninstall the sharplens-mcp package globally. This action also automatically removes the associated .NET tool. ```bash npm uninstall -g sharplens-mcp ``` -------------------------------- ### Retrieve code actions with roslyn:get_code_actions_at_position Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Fetches available code fixes and refactorings at a specific location or within a selected range. ```json // Request { "name": "roslyn:get_code_actions_at_position", "arguments": { "filePath": "/path/to/src/MyClass.cs", "line": 15, "column": 10, "includeCodeFixes": true, "includeRefactorings": true } } ``` ```json // With selection for extract operations { "name": "roslyn:get_code_actions_at_position", "arguments": { "filePath": "/path/to/src/MyClass.cs", "line": 15, "column": 10, "endLine": 20, "endColumn": 5 } } ``` -------------------------------- ### roslyn:get_method_source Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves the source code for a specific method. ```APIDOC ## POST roslyn:get_method_source ### Description Get the actual source code of a method by type and method name. ### Request Body - **typeName** (string) - Required - The name of the type. - **methodName** (string) - Required - The name of the method. ### Request Example { "name": "roslyn:get_method_source", "arguments": { "typeName": "UserService", "methodName": "ValidateUser" } } ``` -------------------------------- ### Analysis Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools for analyzing code quality, dependencies, and potential issues. ```APIDOC ## Analysis Tools ### Description Tools for analyzing code quality, dependencies, and potential issues. ### Tools - **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. ``` -------------------------------- ### roslyn:get_diagnostics Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves compiler errors, warnings, and info messages for a specific file or an entire project. ```APIDOC ## roslyn:get_diagnostics ### Description Get compiler errors, warnings, and info messages for a file or entire project. ### Request Body - **filePath** (string) - Optional - Path to the specific file to analyze. - **severity** (string) - Optional - Filter by severity (e.g., "Error"). - **projectPath** (string) - Optional - Path to the project file to analyze. ``` -------------------------------- ### Find Attribute Usages Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Locates all types and members decorated with a specified attribute. Can be filtered by project. ```json { "name": "roslyn:find_attribute_usages", "arguments": { "attributeName": "HttpGet", "projectName": "MyApp.Api" } } ``` ```json { "name": "roslyn:find_attribute_usages", "arguments": { "attributeName": "Authorize" } } ``` -------------------------------- ### roslyn:get_method_signature Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves detailed method signature information. ```APIDOC ## POST roslyn:get_method_signature ### Description Get detailed method signature by name including parameters, return type, and modifiers. ### Request Body - **typeName** (string) - Required - The name of the type. - **methodName** (string) - Required - The name of the method. - **overloadIndex** (integer) - Optional - Index of the overload. ### Request Example { "name": "roslyn:get_method_signature", "arguments": { "typeName": "UserService", "methodName": "GetUserByIdAsync", "overloadIndex": 0 } } ``` -------------------------------- ### Compound Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools that combine multiple operations for comprehensive analysis. ```APIDOC ## Compound Tools ### Description Tools that combine multiple operations for comprehensive analysis. ### Tools - **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. ``` -------------------------------- ### Find Reflection Usage Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Detects dynamic type and method usage based on reflection. Can limit the number of results returned. ```json { "name": "roslyn:find_reflection_usage", "arguments": { "maxResults": 50 } } ``` -------------------------------- ### roslyn:generate_constructor Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Generates a constructor for a specified type based on its fields and properties. ```APIDOC ## POST roslyn:generate_constructor ### Description Generates a constructor from fields and/or properties of a type at a specific location. ### Request Body - **filePath** (string) - Required - Path to the source file. - **line** (number) - Required - Line number for the type. - **column** (number) - Required - Column number for the type. - **includeProperties** (boolean) - Optional - Whether to include properties in the constructor. ### Request Example { "name": "roslyn:generate_constructor", "arguments": { "filePath": "/path/to/src/UserDto.cs", "line": 5, "column": 17, "includeProperties": true } } ### Response #### Success Response (200) - **typeName** (string) - Name of the type. - **constructorCode** (string) - The generated constructor code. - **parameterCount** (number) - Number of parameters. - **parameters** (array) - List of parameters with name and type. ``` -------------------------------- ### Analyze Method Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Performs a detailed analysis of a method, including its signature, callers, and outgoing calls. Can limit the number of callers analyzed. ```json { "name": "roslyn:analyze_method", "arguments": { "typeName": "UserService", "methodName": "ProcessData", "includeCallers": true, "includeOutgoingCalls": true, "maxCallers": 20 } } ``` -------------------------------- ### Refactoring Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools for performing safe code refactoring with preview capabilities. ```APIDOC ## Refactoring Tools ### Description Tools for performing safe code refactoring with preview capabilities. ### Tools - **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 Tools Source: https://github.com/pzalutski-pixel/sharplens-mcp/blob/main/README.md Tools for automatically generating code snippets. ```APIDOC ## Code Generation Tools ### Description Tools for automatically generating code snippets. ### Tools - **add_null_checks**: Generate ArgumentNullException guards. - **generate_equality_members**: Equals/GetHashCode/operators. ``` -------------------------------- ### roslyn:get_symbol_info Source: https://context7.com/pzalutski-pixel/sharplens-mcp/llms.txt Retrieves detailed semantic information about a code symbol at a specified file path and line/column coordinates. ```APIDOC ## roslyn:get_symbol_info ### Description Get detailed semantic information about a symbol at a specific position. Uses zero-based coordinates. ### Method POST ### Endpoint /roslyn/get_symbol_info ### Request Body - **filePath** (string) - Required - The path to the source file. - **line** (integer) - Required - The zero-based line number. - **column** (integer) - Required - The zero-based column number. ### Request Example ```json { "name": "roslyn:get_symbol_info", "arguments": { "filePath": "/path/to/src/MyService.cs", "line": 13, "column": 15 } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (object) - Contains the symbol information. - **name** (string) - The name of the symbol. - **kind** (string) - The type of the symbol (e.g., Method, Class). - **fullyQualifiedName** (string) - The fully qualified name of the symbol. - **containingType** (string) - The type containing this symbol. - **containingNamespace** (string) - The namespace containing this symbol. - **returnType** (string) - The return type of the symbol (if applicable). - **isAsync** (boolean) - Whether the symbol represents an asynchronous operation. - **parameters** (array) - An array of parameter objects (if applicable). - **name** (string) - The name of the parameter. - **type** (string) - The type of the parameter. - **location** (object) - The location of the symbol in the file. - **filePath** (string) - The file path. - **line** (integer) - The line number. - **column** (integer) - The column number. #### Response Example ```json { "success": true, "data": { "name": "ProcessData", "kind": "Method", "fullyQualifiedName": "MyNamespace.MyService.ProcessData(string)", "containingType": "MyNamespace.MyService", "containingNamespace": "MyNamespace", "returnType": "Task", "isAsync": true, "parameters": [ { "name": "input", "type": "string" } ], "location": { "filePath": "src/MyService.cs", "line": 13, "column": 15 } } } ``` ```