### Run DotNet MCP via Command Line Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Examples for starting the server in stdio mode or HTTP mode with a custom port. ```bash # Stdio mode dotnet run --project src/DotNetMcp.Server -- --stdio # HTTP mode with custom port dotnet run --project src/DotNetMcp.Server -- --port 8080 ``` -------------------------------- ### Install .NET SDK on macOS Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Install the .NET SDK using Homebrew. ```bash brew install dotnet ``` -------------------------------- ### Install .NET SDK on Linux Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Commands to install the .NET 10.0 SDK on Ubuntu/Debian systems. ```bash wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt update sudo apt install dotnet-sdk-10.0 ``` -------------------------------- ### Verify .NET SDK installation Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Check the installed version of the .NET SDK on Windows. ```powershell dotnet --version ``` -------------------------------- ### Example AI Interaction Workflow Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md A sample conversation demonstrating how to load an assembly and perform analysis tasks. ```text User: Load /Users/me/Projects/MyApp/bin/Debug/MyApp.dll AI: Loaded assembly MyApp.dll, containing 25 types. User: What Service classes are there? AI: Found the following Service classes: - MyApp.Services.UserService (8 methods) - MyApp.Services.OrderService (12 methods) - MyApp.Services.PaymentService (6 methods) User: Decompile UserService AI: [Shows complete C# source code for UserService] User: What other methods does GetUser call? AI: [Shows call graph for GetUser] ``` -------------------------------- ### Run DotNetMCP in HTTP mode Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Start the container and mount the directory containing the assemblies to be analyzed. ```bash docker run -p 5000:5000 \ -v /path/to/your/assemblies:/data \ dotnet-mcp ``` -------------------------------- ### Backend Management Workflow Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Example interactions for registering, listing, and setting default backends via AI commands. ```text # Register backend with API Key authentication User: Register remote backend http://server:5000 with API key "secret123" AI: [Call register_remote_backend id="analysis-1" name="Analysis Server" endpoint="http://server:5000" apiKey="secret123"] Successfully registered remote backend "Analysis Server" # List all backends User: List all backends AI: [Call list_backends] Available backends: - local (default) - Local, Healthy - analysis-1 - Remote, Healthy # Set default backend User: Use analysis-1 as default AI: [Call set_default_backend id="analysis-1"] Default backend set to "analysis-1" ``` -------------------------------- ### List Assemblies Response Example Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md The JSON response structure containing a list of currently loaded assemblies. ```json { "success": true, "assemblies": [ { "mvid": "12345678-...", "name": "MyAssembly", "path": "/path/to/assembly.dll", "isDefault": true } ] } ``` -------------------------------- ### get_control_flow_graph Response Example Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Example JSON response structure for the get_control_flow_graph tool, including a Mermaid diagram string. ```json { "success": true, "methodName": "ComplexMethod", "blockCount": 5, "edgeCount": 6, "mermaid": "graph TD\n BB0 --> BB1\n ..." } ``` -------------------------------- ### Get Call Graph Response Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Example JSON response for the get_call_graph tool. ```json { "success": true, "startMethod": "MyClass.EntryPoint", "levels": [ { "depth": 1, "methods": ["Method1", "Method2"] }, { "depth": 2, "methods": ["Method3"] } ], "maxDepthReached": false } ``` -------------------------------- ### Load Assembly Response Example Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md The JSON response returned after successfully loading a .NET assembly. ```json { "success": true, "mvid": "12345678-1234-1234-1234-123456789abc", "name": "MyAssembly", "backend": "local" } ``` -------------------------------- ### Run DotNetMCP with API Key authentication Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Start the container with an API key environment variable for secure access. ```bash docker run -p 5000:5000 \ -v /path/to/your/assemblies:/data \ -e API_KEYS="your-secret-key" \ dotnet-mcp ``` -------------------------------- ### Decompile Method Response Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Example JSON response for the decompile_method tool. ```json { "success": true, "methodName": "GetUser", "code": "public User GetUser(int id) { ... }" } ``` -------------------------------- ### Analyze Call Graph Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Visualizes the hierarchy of method calls starting from a specific method. ```text ProcessOrder ├── ValidateOrder │ └── CheckInventory ├── CalculateTotal │ └── ApplyDiscount └── SaveOrder └── Database.Insert ``` -------------------------------- ### Find Method Calls Response Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Example JSON response for the find_method_calls tool. ```json { "success": true, "calls": [ { "callerType": "OrderService", "callerMethod": "ProcessOrder", "offset": 24 } ], "totalCount": 1 } ``` -------------------------------- ### Run DotNetMcp in HTTP Mode Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Start the server in HTTP mode to expose MCP endpoints at localhost:5000. ```bash dotnet run --project src/DotNetMcp.Server ``` -------------------------------- ### Decompile Type Response Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Example JSON response for the decompile_type tool. ```json { "success": true, "typeName": "MyNamespace.MyClass", "code": "public class MyClass { ... }" } ``` -------------------------------- ### Find Type References Response Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Example JSON response for the find_type_references tool. ```json { "success": true, "references": [ { "sourceTypeName": "OtherClass", "sourceMemberName": "Method1", "targetName": "MyClass", "kind": "TypeReference" } ], "totalCount": 1 } ``` -------------------------------- ### detect_obfuscation Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Detect if an assembly is obfuscated, identify the obfuscator, and get a score. ```APIDOC ## detect_obfuscation ### Description Detect if an assembly is obfuscated, identify the obfuscator, and get a score from 0 to 100. Useful for determining if de-obfuscation is required. ### Parameters #### Parameters - **mvid** (string) - Optional - Specific assembly MVID - **backendId** (string) - Optional - Target backend ID ### Response - **isObfuscated** (boolean) - whether the assembly is obfuscated - **obfuscationScore** (int) - score 0-100 - **confidence** (string) - confidence level (Low/Medium/High) - **detectedObfuscators[]** (array) - names of identified obfuscators - **topIndicators[]** (array) - top 10 indicators with category, severity, description, location - **stats** (object) - statistics including type/method/field counts, invalid names, short names, control flow flattening, proxy methods ``` -------------------------------- ### load_assembly Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Loads a .NET assembly for analysis. This tool is used to start analyzing a new DLL or EXE file. ```APIDOC ## load_assembly ### Description Load a .NET assembly for analysis. ### Parameters - **path** (string) - Required - Assembly file path (.dll or .exe) - **searchPaths** (string[]) - Optional - Dependency search directories for resolving references - **backendId** (string) - Optional - Target backend ID ### Response Example { "success": true, "mvid": "12345678-1234-1234-1234-123456789abc", "name": "MyAssembly", "backend": "local" } ``` -------------------------------- ### Configure Claude Desktop with Pre-built Binary Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Add the DotNetMcp server to the Claude Desktop configuration file using the path to the executable. ```json { "mcpServers": { "dotnet-mcp": { "command": "/path/to/DotNetMcp.Server", "args": ["--stdio"] } } } ``` -------------------------------- ### Configure appsettings.json Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Standard .NET configuration file structure for logging and server metadata. ```json { "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "McpServer": { "Name": "DotNet MCP", "Version": "0.0.3" } } ``` -------------------------------- ### Analyze Third-Party Library Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Use these commands to load a DLL and inspect its public APIs and class implementations. ```text User: Load ThirdParty.dll User: What public APIs are available? User: How do I use the AuthClient class? Decompile it User: What parameters does the Authenticate method need? ``` -------------------------------- ### Inject Code into Method Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Illustrates the syntax for injecting instructions into a specific method entry point. ```text User: Add logging at GetUser method entry AI: [Call inject_at_entry methodFullName="MyApp.Services.UserService.GetUser" instructions=[ {"opCode": "ldstr", "stringValue": "GetUser called"}, {"opCode": "call", "stringValue": "System.Console::WriteLine" ]] Logging code injected at GetUser method entry. ``` -------------------------------- ### Build the DotNetMCP Docker image Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Clone the repository and build the image from the source code. ```bash git clone https://github.com/xjoker/DotNetMCP.git cd DotNetMCP docker build -t dotnet-mcp . ``` -------------------------------- ### Make binary executable on macOS/Linux Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Required step after extracting the pre-built binary on Unix-based systems. ```bash chmod +x /path/to/DotNetMcp.Server ``` -------------------------------- ### Clone and build DotNetMCP Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Standard commands to download the source code and compile the project. ```bash git clone https://github.com/xjoker/DotNetMCP.git cd DotNetMCP dotnet build ``` -------------------------------- ### Load and Analyze Assembly Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Demonstrates the interaction flow for loading an assembly and listing its contained types. ```text User: Load /path/to/MyApp.dll and tell me what types it contains AI: [Call load_assembly] [Call search_types keyword=""] Loaded assembly MyApp.dll, containing the following types: - MyApp.Program (class, 5 methods) - MyApp.Services.UserService (class, 10 methods) ... ``` -------------------------------- ### Configure Single Local Backend Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Minimal configuration to enable only the local backend. ```json { "McpServer": { "EnableLocalBackend": true } } ``` -------------------------------- ### Define IL Instructions for Method Injection Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Format for providing IL instructions when using the inject_at_entry tool. ```json [ {"opCode": "ldstr", "stringValue": "Method called"}, {"opCode": "call", "stringValue": "System.Console::WriteLine"} ] ``` -------------------------------- ### Run Project Tests Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Commands for executing the test suite using the .NET CLI. ```bash # Run all tests dotnet test # Run Server tests only dotnet test tests/DotNetMcp.Server.Tests # Run Backend tests only dotnet test tests/DotNetMcp.Backend.Tests ``` -------------------------------- ### Configure API Keys via Environment Variable Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Set multiple API keys using a comma-separated string in the environment. ```bash # Set API keys (comma-separated for multiple keys) export API_KEYS="your-secret-key-1,your-secret-key-2" ``` -------------------------------- ### Configure Claude Desktop on Windows Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md JSON configuration for the Claude Desktop app on Windows. ```json { "mcpServers": { "dotnet-mcp": { "command": "dotnet", "args": [ "run", "--project", "C:\\path\\to\\DotNetMCP\\src\\DotNetMcp.Server", "--", "--stdio" ] } } } ``` -------------------------------- ### Analyze Inheritance Relationships Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Commands to explore type hierarchies, interface implementations, and base class chains. ```text User: What types implement IRepository? AI: [Call get_implementations interfaceTypeName="MyApp.IRepository"] Found 3 direct implementations: - MyApp.Data.SqlRepository - MyApp.Data.MongoRepository - MyApp.Data.InMemoryRepository User: What is the base class chain of SqlRepository? AI: [Call find_base_types typeName="MyApp.Data.SqlRepository"] Base classes: BaseRepository (internal) → System.Object (external) Interfaces implemented: IRepository, IDisposable User: Are there any other types derived from BaseRepository? AI: [Call find_derived_types typeName="MyApp.Data.BaseRepository"] Found 4 derived types: SqlRepository, MongoRepository, InMemoryRepository, CachedRepository ``` -------------------------------- ### Pre-warming indexes for large assemblies Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Use this sequence to load an assembly and build indexes for faster subsequent searches. This is recommended for assemblies larger than 5 MB. ```text User: Load the game assembly, then pre-warm indexes before I start analysis AI: [Call load_assembly path="/path/to/Assembly-CSharp.dll"] [Call warm_index typeIndex=true memberIndex=true maxSeconds=30] Loaded Assembly-CSharp.dll (8.4 MB, 2,847 types). Index warm-up complete: 2,847 types, 41,320 members indexed in 18.4 s. User: Now find all methods named Update AI: [Call search_types keyword="Update"] ← instant, uses cached index ... ``` -------------------------------- ### Configure Claude Desktop Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md JSON configurations for integrating the DotNet MCP server into Claude Desktop using different execution methods and environment settings. ```json { "mcpServers": { "dotnet-mcp": { "command": "dotnet", "args": [ "run", "--project", "/path/to/DotNetMCP/src/DotNetMcp.Server", "--", "--stdio" ] } } } ``` ```json { "mcpServers": { "dotnet-mcp": { "command": "/path/to/DotNetMcp.Server", "args": ["--stdio"] } } } ``` ```json { "mcpServers": { "dotnet-mcp": { "command": "dotnet", "args": ["run", "--project", "/path/to/src/DotNetMcp.Server", "--", "--stdio"], "env": { "DOTNET_ENVIRONMENT": "Production" } } } } ``` -------------------------------- ### Configure Local and Remote Backends Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Configuration enabling both local and remote backend support. ```json { "McpServer": { "EnableLocalBackend": true, "RemoteBackends": [ { "Id": "remote-analysis", "Name": "Remote Analysis Server", "Endpoint": "http://analysis-server:5000", "ApiKey": "secret-key" } ] } } ``` -------------------------------- ### Configure Remote Backends in appsettings.json Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Define multiple remote backends with specific endpoints, API keys, and timeouts. ```json { "McpServer": { "EnableLocalBackend": true, "ServerName": "dotnet-mcp", "ServerVersion": "0.0.3", "HealthCheckIntervalSeconds": 30, "RemoteBackends": [ { "Id": "remote-1", "Name": "Analysis Server", "Endpoint": "http://server:5000", "ApiKey": "your-api-key", "TimeoutSeconds": 30 }, { "Id": "remote-2", "Name": "Build Server", "Endpoint": "http://build-server:5000", "ApiKey": "another-api-key", "TimeoutSeconds": 60 } ] } } ``` -------------------------------- ### Register DotNetMCP with Claude Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Use the Claude CLI to add the running Docker container as an MCP server. ```bash claude mcp add dotnet-mcp --transport http --url http://localhost:5000/mcp ``` -------------------------------- ### Run DotNetMcp in Stdio Mode Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Execute the server in stdio mode for direct communication with Claude Desktop. ```bash dotnet run --project src/DotNetMcp.Server -- --stdio ``` -------------------------------- ### Dependency Graph Visualization Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Commands to generate dependency graphs in Mermaid format for assemblies or specific types. ```text User: Show the dependency graph for this assembly AI: [Call get_dependency_graph level="assembly"] Assembly dependency graph (8 nodes, 12 edges): ```mermaid graph LR MyApp --> Newtonsoft.Json MyApp --> Microsoft.EntityFrameworkCore ... ``` User: Show type dependencies for UserService at depth 2 AI: [Call get_dependency_graph level="type" rootType="MyApp.Services.UserService" maxDepth=2] Type dependency graph (Mermaid): ... ``` -------------------------------- ### Configure Claude Desktop on macOS Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md JSON configuration for the Claude Desktop app on macOS. ```json { "mcpServers": { "dotnet-mcp": { "command": "dotnet", "args": [ "run", "--project", "/path/to/DotNetMCP/src/DotNetMcp.Server", "--", "--stdio" ] } } } ``` -------------------------------- ### list_assemblies Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Lists all assemblies currently loaded in the session. ```APIDOC ## list_assemblies ### Description List loaded assemblies. ### Parameters - **backendId** (string) - Optional - Target backend ID ### Response Example { "success": true, "assemblies": [ { "mvid": "12345678-...", "name": "MyAssembly", "path": "/path/to/assembly.dll", "isDefault": true } ] } ``` -------------------------------- ### Define IL Instructions for Method Body Replacement Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Format for providing IL instructions to replace a method body, such as forcing a return value of true. ```json [ {"opCode": "ldc.i4.1"}, {"opCode": "ret"} ] ``` -------------------------------- ### Register and use assembly aliases Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Use aliases to reference assemblies by short names instead of full MVIDs. Aliases can be restored across sessions. ```text User: Load /path/to/GameLib.dll, then register it as alias 'game' AI: [Call load_assembly path="/path/to/GameLib.dll"] [Call register_assembly_alias alias="game"] Loaded assembly GameLib.dll. Registered as alias 'game'. You can now use 'game' wherever a mvid is required. User: Find all types named Controller using alias 'game' AI: [Call search_types keyword="Controller" mvid="game"] Found 5 types matching 'Controller': - GameLib.PlayerController - GameLib.EnemyController ... # Restore on next session User: Restore my previous assemblies AI: [Call instance_restore_persisted] Restored 1 assembly. Alias 'game' → GameLib.dll is available again. ``` -------------------------------- ### Configure API Key Authentication Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Set the API key environment variable to enable authentication for HTTP endpoints. ```bash export API_KEYS="your-secret-key" ``` -------------------------------- ### Add MCP Server via Claude CLI Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/getting-started.md Register the DotNetMcp server using the Claude CLI for either stdio or HTTP transport modes. ```bash # Stdio mode — pre-built binary claude mcp add dotnet-mcp -- /path/to/DotNetMcp.Server --stdio # HTTP mode — start server first dotnet run --project src/DotNetMcp.Server & claude mcp add dotnet-mcp --transport http --url http://localhost:5000/mcp ``` -------------------------------- ### Project Directory Structure Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Visual representation of the project file organization. ```text DotNetMCP/ ├── src/ │ ├── DotNetMcp.Server/ # MCP Server │ │ ├── Tools/ # MCP Tool implementations │ │ ├── Backend/ # Backend registration & management │ │ └── Configuration/ # Configuration │ └── DotNetMcp.Backend/ # Core Backend │ ├── Core/ │ │ ├── Analysis/ # Analysis services │ │ ├── Modification/ # Modification services │ │ ├── Context/ # Assembly context │ │ └── Identity/ # ID system │ ├── Services/ # Business services │ └── Controllers/ # HTTP API ├── tests/ │ ├── DotNetMcp.Server.Tests/ # Server unit tests │ └── DotNetMcp.Backend.Tests/ # Backend unit tests └── docs/ ├── zh/ # Chinese docs └── en/ # English docs ``` -------------------------------- ### compare_assemblies Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Compares two loaded assemblies to identify structural differences. ```APIDOC ## compare_assemblies ### Description Compares two loaded assemblies to find structural changes, useful for tracking modifications between builds. ### Parameters - **leftMvid** (string) - Required - MVID of original assembly - **rightMvid** (string) - Required - MVID of modified assembly - **namespaceFilter** (string) - Optional - Filter by namespace prefix - **includeUnchanged** (bool) - Optional - Include unchanged types (default false) ``` -------------------------------- ### list_backends Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Lists all available analysis backends and their current status. ```APIDOC ## list_backends ### Description List all available analysis backends to view their status. ### Parameters None ``` -------------------------------- ### get_dependency_graph Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Builds a dependency graph for a loaded assembly at various granularities. ```APIDOC ## get_dependency_graph ### Description Generates a dependency graph for an assembly, namespace, or type, returning statistics and a Mermaid diagram. ### Parameters - **level** (string) - Optional - Granularity: assembly (default), namespace, or type - **rootType** (string) - Optional - Required when level=type; full type name - **maxDepth** (int) - Optional - Max traversal depth for level=type (default 3, max 10) - **mvid** (string) - Optional - Specific assembly MVID - **backendId** (string) - Optional - Target backend ID ### Response - **level** (string) - Granularity used - **rootId** (string) - Root node ID - **totalNodes** (int) - Total nodes in graph - **externalNodes** (int) - External nodes count - **totalEdges** (int) - Total edges count - **mermaid** (string) - Mermaid diagram string ``` -------------------------------- ### Register Remote Backend in Claude Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Command syntax for registering a remote backend within the Claude interface. ```text # Use in Claude Register remote backend http://remote-server:5000 named "remote-1" ``` -------------------------------- ### Decompile and Analyze Type Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Shows how to request the decompilation of a specific class within an assembly. ```text User: Decompile the UserService class AI: [Call decompile_type typeName="MyApp.Services.UserService"] public class UserService { private readonly IDatabase _db; public User GetUser(int id) { return _db.Query().FirstOrDefault(u => u.Id == id); } ... } ``` -------------------------------- ### register_remote_backend Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Registers a new remote backend with the system, optionally providing an API key for authentication. ```APIDOC ## register_remote_backend ### Description Registers a new remote backend to the DotNetMcp registry. ### Parameters - **id** (string) - Required - Unique backend ID - **name** (string) - Required - Display name - **endpoint** (string) - Required - HTTP URL - **apiKey** (string) - Optional - API Key for authentication - **timeoutSeconds** (integer) - Optional - Timeout (default: 30) ``` -------------------------------- ### MCP Tools Overview Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md The dotnetmcp project provides a comprehensive set of tools accessible via the Model Context Protocol. These tools are organized into functional groups including assembly management, code search, deep analysis, assembly modification, and instance/backend management. ```APIDOC ## MCP Tools Reference ### Assembly Management - `load_assembly`: Load a .NET assembly - `list_assemblies`: List loaded assemblies - `unload_assembly`: Unload an assembly - `detect_unity_assembly`: Auto-detect Assembly-CSharp.dll in a Unity game directory ### Search Tools - `search_types`: Search types by keyword - `search_strings`: Search string literals ### Analysis Tools - `decompile_type`: Decompile type to C#/IL - `decompile_method`: Decompile a single method precisely - `find_type_references`: Find type references - `find_method_calls`: Find method calls - `get_call_graph`: Build call graph - `get_control_flow_graph`: Build control flow graph (Mermaid) - `get_type_outline`: Get metadata-based type outline - `plan_chunking`: Plan LLM-friendly source code chunks - `compare_assemblies`: Compare two assemblies for structural differences - `batch_decompile`: Decompile multiple members in one call - `get_dependency_graph`: Build dependency graph (Mermaid) - `detect_design_patterns`: Detect design patterns - `find_base_types`: Find base class chain and interfaces - `find_derived_types`: Find all types that inherit from a given type - `get_implementations`: Find all implementations of an interface - `get_overrides`: Find all overrides of a virtual/abstract method - `get_overloads`: Find all overloads of a method - `enhanced_search`: Unified search with advanced syntax - `detect_obfuscation`: Detect obfuscation and identify obfuscator - `warm_index`: Pre-build type and member indexes ### Modification Tools - `inject_at_entry`: Inject code at method entry - `replace_method_body`: Replace method body with raw IL - `replace_method_body_with_csharp`: Replace method body using C# source - `add_type`: Add new type - `save_assembly`: Save modified assembly - `generate_patch_skeleton`: Generate Harmony patch skeleton ### Instance Management - `list_backends`: List all backends - `register_remote_backend`: Register remote backend - `unregister_backend`: Unregister backend - `set_default_backend`: Set default backend - `check_backend_health`: Check backend health - `register_assembly_alias`: Register a short alias for an assembly MVID - `unregister_assembly_alias`: Remove a registered alias - `list_assembly_aliases`: List all registered aliases - `instance_restore_persisted`: Reload assemblies from persisted aliases ``` -------------------------------- ### Detect Obfuscation Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Use the detect_obfuscation tool to assess if an assembly requires de-obfuscation. ```text User: Load SuspiciousApp.dll User: Is this assembly obfuscated? AI: [Call detect_obfuscation] Result: Obfuscation score 87/100, confidence High. Detected obfuscator: ConfuserEx. Top indicators: many single-character type names (a, b, c), 42 control-flow-flattened methods, 18 proxy methods. Recommend using a matching de-obfuscator before further analysis. ``` -------------------------------- ### list_assembly_aliases Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md List all registered assembly aliases for the current backend. ```APIDOC ## list_assembly_aliases ### Description List all registered assembly aliases for the current backend to verify alias to MVID mappings. ### Parameters - **backendId** (string) - Optional - Target backend ID ### Response - **aliases[]** (array) - Array of { alias, mvid } entries ``` -------------------------------- ### Unity Game Reverse Engineering Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Commands to auto-locate Unity assemblies and search for specific types within the game structure. ```text User: Help me analyze the Unity game at /Users/me/Games/MyGame AI: [Call detect_unity_assembly gameRootPath="/Users/me/Games/MyGame"] Found Unity assembly: - Assembly-CSharp.dll: /Users/me/Games/MyGame/MyGame.app/Contents/Resources/Data/Managed/Assembly-CSharp.dll - Game name: MyGame - Unity version: 2022.3.10f1 - 47 managed assemblies found User: Load Assembly-CSharp.dll AI: [Call load_assembly path="..."] User: Find all Player-related types AI: [Call search_types keyword="Player"] ``` -------------------------------- ### replace_method_body Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Replaces the entire body of a method with new IL instructions. ```APIDOC ## replace_method_body ### Description Replace method body to modify implementation, bypass validation, or fix code. ### Parameters - **methodFullName** (string) - Required - Full method name - **instructions** (object[]) - Required - New IL instruction list - **mvid** (string) - Optional - Specific assembly MVID ``` -------------------------------- ### Debug Issues Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Commands for searching strings and decompiling classes to trace error handling logic. ```text User: Load the problematic MyApp.dll User: Search for strings containing "Exception" User: Decompile ErrorHandler class User: Who calls HandleError method? ``` -------------------------------- ### detect_unity_assembly Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Detects the Assembly-CSharp.dll in a Unity game directory, supporting various platforms. ```APIDOC ## detect_unity_assembly ### Description Detects Assembly-CSharp.dll in a Unity game directory. Supports Windows, macOS, and Linux Unity directory layouts. ### Parameters - **gameRootPath** (string) - Required - Path to the Unity game root directory or .app bundle ### Response - **assemblyCSharpPath** (string) - full path to Assembly-CSharp.dll - **managedDirectory** (string) - path to the Managed directory - **gameName** (string) - game name - **platform** (string) - detected platform (Windows/macOS/Linux) - **unityVersion** (string) - Unity version (if readable) - **managedAssemblies** (array) - list of all managed DLL paths ``` -------------------------------- ### inject_at_entry Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Injects code at the entry point of a specified method. ```APIDOC ## inject_at_entry ### Description Inject code at method entry for logging, debugging, or interception. ### Parameters - **methodFullName** (string) - Required - Full method name (Type.Method) - **instructions** (object[]) - Required - IL instruction list - **mvid** (string) - Optional - Specific assembly MVID ``` -------------------------------- ### get_overloads Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Find all overloads of a method within the same type. ```APIDOC ## get_overloads ### Description Find all overloads of a method within the same type. This helps in disambiguating overloaded methods and understanding all call signatures. ### Parameters #### Parameters - **typeName** (string) - Required - Full type name - **methodName** (string) - Required - Method name - **mvid** (string) - Optional - Specific assembly MVID - **backendId** (string) - Optional - Target backend ID ### Response - **methods[]** - each entry contains id, typeFullName, methodName, signature - **totalCount** ``` -------------------------------- ### warm_index Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Pre-build type and member indexes for faster subsequent queries. ```APIDOC ## warm_index ### Description Pre-build type and member indexes for faster subsequent queries. This reduces first-query latency in batch analysis workflows. ### Parameters #### Parameters - **mvid** (string) - Optional - MVID or alias of the assembly. Omit to use default. - **typeIndex** (bool) - Optional - Build type index (default true) - **memberIndex** (bool) - Optional - Build member index (default true) - **maxSeconds** (int) - Optional - Soft time budget in seconds. - **backendId** (string) - Optional - Target backend ID ### Response - **typeIndexBuilt** (boolean) - whether the type index was built - **memberIndexBuilt** (boolean) - whether the member index was built - **typeCount** (int) - number of types indexed - **memberCount** (int) - number of members indexed - **elapsedMs** (int) - elapsed time in milliseconds - **maxSecondsExceeded** (boolean) - whether the soft time budget was exceeded ``` -------------------------------- ### search_types Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Search types by keyword within an assembly. ```APIDOC ## search_types ### Description Search types by keyword to explore assembly structure or filter by namespace. ### Parameters - **keyword** (string) - Required - Search keyword (empty matches all) - **namespaceFilter** (string) - Optional - Namespace filter - **limit** (int) - Optional - Result limit (default 50) - **mvid** (string) - Optional - Specific assembly MVID ### Response #### Success Response - **success** (boolean) - Operation status - **types** (array) - List of found types - **totalCount** (int) - Total number of types found #### Response Example { "success": true, "types": [ { "fullName": "MyNamespace.MyClass", "namespace": "MyNamespace", "name": "MyClass", "kind": "class", "methodCount": 5, "fieldCount": 2 } ], "totalCount": 1 } ``` -------------------------------- ### add_type Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Adds a new type to the assembly. ```APIDOC ## add_type ### Description Add a new class, interface, or struct to the assembly. ### Parameters - **typeName** (string) - Required - New type full name - **kind** (string) - Optional - Type kind: class, interface, struct (default class) - **baseType** (string) - Optional - Base type name - **mvid** (string) - Optional - Specific assembly MVID ``` -------------------------------- ### register_assembly_alias Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Register a short alias for a loaded assembly MVID. ```APIDOC ## register_assembly_alias ### Description Register a short alias for a loaded assembly MVID. This allows using a human-readable name instead of a 32-character GUID. ### Parameters - **alias** (string) - Required - Short alias (1–32 chars, [A-Za-z0-9_-], not reserved) - **mvid** (string) - Optional - Assembly MVID to bind. Omit to use the current default assembly. - **overwrite** (bool) - Optional - If true, overwrite an existing alias with the same name (default false) - **backendId** (string) - Optional - Target backend ID ### Response - **alias** (string) - The registered alias name - **mvid** (string) - The MVID it was bound to ``` -------------------------------- ### plan_chunking Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Plans line-range chunks for a type or method's decompiled source to facilitate LLM-friendly processing. ```APIDOC ## plan_chunking ### Description Calculates line-range chunks for decompiled source code to assist in paged reading or processing of large classes. ### Parameters - **typeName** (string) - Required - Full type name - **methodName** (string) - Optional - Method name - **targetChunkSize** (int) - Optional - Target chars per chunk (default 6000) - **overlap** (int) - Optional - Overlapping lines between chunks (default 2) - **mvid** (string) - Optional - Specific assembly MVID ``` -------------------------------- ### instance_restore_persisted Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Reload assemblies from persisted alias entries saved to disk from a previous session. ```APIDOC ## instance_restore_persisted ### Description Reload assemblies from persisted alias entries saved to disk from a previous session. Failed entries are automatically removed from persistence. ### Parameters - **backendId** (string) - Optional - Target backend ID ### Response - **restoredCount** (number) - Number of successfully restored assemblies ``` -------------------------------- ### Code Modification Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Commands for decompiling a class, modifying a method, and saving the changes to a new assembly. ```text User: Load App.dll User: Decompile LicenseChecker class User: Change IsLicenseValid method to always return true User: Save to App_Modified.dll ``` -------------------------------- ### Patch methods using C# code Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/ai-usage-guide.md Replace method bodies using C# syntax and save the modified assembly. Compilation errors are returned if the provided C# code is invalid. ```text User: Make IsTrialExpired always return false, write it as C# AI: [Call replace_method_body_with_csharp methodFullName="MyApp.Licensing.LicenseManager::IsTrialExpired" csharpBody="return false;"] Method body replaced with 2 IL instructions. User: Save the changes AI: [Call save_assembly outputPath="/path/to/MyApp.Patched.dll"] Assembly saved to MyApp.Patched.dll. # If compilation fails, diagnostics are returned User: Replace GetConfig to return a specific string AI: [Call replace_method_body_with_csharp methodFullName="MyApp.Config::GetConfig" csharpBody="return Cofig.Default;"] ← typo Compilation failed: [Error] CS0103 (line 1): The name 'Cofig' does not exist in the current context ``` -------------------------------- ### get_implementations Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Finds all types that directly implement the specified interface. ```APIDOC ## get_implementations ### Description Find all types that directly implement the specified interface. ### Parameters #### Query Parameters - **interfaceTypeName** (string) - Required - Full interface name (e.g. MyNamespace.IService) - **mvid** (string) - Optional - Specific assembly MVID - **backendId** (string) - Optional - Target backend ID ### Response #### Success Response (200) - **types[]** (array) - each entry contains id, fullName, namespace, kind, isExternal - **totalCount** (int) - total count ``` -------------------------------- ### register_remote_backend Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Registers a new remote analysis backend. ```APIDOC ## register_remote_backend ### Description Connect to a remote analysis service for distributed analysis. ### Parameters - **id** (string) - Required - Unique backend identifier - **name** (string) - Required - Display name for the backend - **endpoint** (string) - Required - HTTP endpoint URL - **apiKey** (string) - Optional - API key for authentication - **timeoutSeconds** (int) - Optional - Request timeout in seconds (default 30) ``` -------------------------------- ### unregister_backend Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Removes an existing backend from the system. ```APIDOC ## unregister_backend ### Description Unregister a backend to remove it from the system or clean up a session. ### Parameters - **backendId** (string) - Required - Backend ID ``` -------------------------------- ### set_default_backend Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Sets the active default backend for the system using a specific backend ID. ```APIDOC ## set_default_backend ### Description Updates the default backend configuration. ### Parameters - **id** (string) - Required - The unique ID of the backend to set as default ``` -------------------------------- ### detect_design_patterns Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Detects design patterns such as Singleton, Factory, and Observer within a loaded assembly. ```APIDOC ## detect_design_patterns ### Description Detect design patterns in a loaded assembly. Supports Singleton, Factory, AbstractFactory, Observer, Builder, Strategy, and Decorator. ### Parameters #### Query Parameters - **typeName** (string) - Optional - Specific type to analyze; omit to scan entire assembly - **mvid** (string) - Optional - Specific assembly MVID - **backendId** (string) - Optional - Target backend ID ### Response #### Success Response (200) - **totalCount** (int) - total patterns detected - **summary** (string) - text summary - **patterns[]** (array) - each result contains patternType, typeName, confidence, evidence[], relatedTypes[] ``` -------------------------------- ### list_backends Source: https://github.com/xjoker/dotnetmcp/blob/main/README.md Retrieves a list of all currently registered backends and their health status. ```APIDOC ## list_backends ### Description Lists all available backends, including local and remote instances, along with their health status. ``` -------------------------------- ### search_strings Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Search for string literals within an assembly. ```APIDOC ## search_strings ### Description Search for string literals to find hardcoded values, URLs, or configuration strings. ### Parameters - **query** (string) - Required - Search query - **mode** (string) - Optional - Search mode: contains, exact, startswith (default contains) - **limit** (int) - Optional - Result limit (default 50) - **mvid** (string) - Optional - Specific assembly MVID ### Response #### Success Response - **success** (boolean) - Operation status - **strings** (array) - List of found strings - **totalCount** (int) - Total number of strings found #### Response Example { "success": true, "strings": [ { "value": "Invalid password", "location": "AuthService.Login", "offset": 42 } ], "totalCount": 1 } ``` -------------------------------- ### get_control_flow_graph Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Builds a control flow graph for a specified method to analyze execution paths and conditional branches. ```APIDOC ## get_control_flow_graph ### Description Builds a control flow graph for a specified method. Useful for analyzing execution paths, conditional branches, and loops. ### Parameters - **typeName** (string) - Required - Full type name - **methodName** (string) - Required - Method name - **includeIL** (bool) - Optional - Include IL instructions (default false) - **mvid** (string) - Optional - Specific assembly MVID ### Response - **success** (bool) - Status of the operation - **methodName** (string) - Name of the method processed - **blockCount** (int) - Number of blocks in the graph - **edgeCount** (int) - Number of edges in the graph - **mermaid** (string) - Mermaid diagram representation ``` -------------------------------- ### replace_method_body_with_csharp Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Replaces a method body using C# source code. ```APIDOC ## replace_method_body_with_csharp ### Description Replace a method body using C# source code instead of raw IL instructions. This is useful for patching logic, stubbing methods, or overriding implementations. ### Parameters - **methodFullName** (string) - Required - Full method name, e.g. "MyNamespace.MyClass::MyMethod" - **csharpBody** (string) - Required - C# method body (without the signature). - **mvid** (string) - Optional - Assembly MVID or alias. - **usings** (string[]) - Optional - Extra using namespaces. - **allowUnsafe** (bool) - Optional - Allow unsafe C# code in the snippet (default false). - **backendId** (string) - Optional - Target backend ID. ### Response #### Success Response - **success** (boolean) - true - **message** (string) - confirmation with instruction count - **instructionsReplaced** (number) - number of IL instructions in the replaced body #### Failure Response - **success** (boolean) - false - **error** (string) - error message - **diagnostics** (array) - Roslyn compilation diagnostics ``` -------------------------------- ### enhanced_search Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Performs a full-featured assembly search with support for advanced query syntax. ```APIDOC ## enhanced_search ### Description Full-featured assembly search with advanced query syntax support. ### Parameters #### Query Parameters - **query** (string) - Required - Query string with optional advanced syntax - **mvid** (string) - Optional - Specific assembly MVID - **mode** (string) - Optional - Search mode: auto (default), type, member, method, field, property, event, literal, token - **namespaceFilter** (string) - Optional - Filter by namespace prefix - **limit** (int) - Optional - Max results (default 100, max 1000) - **backendId** (string) - Optional - Target backend ID ### Response #### Success Response (200) - **items[]** (array) - results with id, name, fullName, kind, declaringType, namespace, value, relevance - **totalCount** (int) - total count - **hasMore** (bool) - pagination flag - **durationMs** (int) - execution time - **mode** (string) - search mode used ``` -------------------------------- ### Configure Gateway Mode Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/configuration.md Configuration for remote-only operation by disabling the local backend. ```json { "McpServer": { "EnableLocalBackend": false, "RemoteBackends": [ { "Id": "backend-1", "Name": "Backend 1", "Endpoint": "http://backend1:5000", "ApiKey": "key1" }, { "Id": "backend-2", "Name": "Backend 2", "Endpoint": "http://backend2:5000", "ApiKey": "key2" } ] } } ``` -------------------------------- ### get_overrides Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Find all override implementations of a virtual or abstract method across derived types. ```APIDOC ## get_overrides ### Description Find all override implementations of a virtual or abstract method across derived types. This is useful for analyzing polymorphic method implementations and finding entry points through virtual dispatch. ### Parameters #### Parameters - **typeName** (string) - Required - Full name of the declaring type - **methodName** (string) - Required - Name of the virtual or abstract method - **mvid** (string) - Optional - Specific assembly MVID - **backendId** (string) - Optional - Target backend ID ### Response - **methods[]** - each entry contains id, typeFullName, methodName, signature - **totalCount** ``` -------------------------------- ### save_assembly Source: https://github.com/xjoker/dotnetmcp/blob/main/docs/en/tools-reference.md Saves the modified assembly to a specified path. ```APIDOC ## save_assembly ### Description Save all modifications to an assembly file. ### Parameters - **outputPath** (string) - Required - Output file path - **mvid** (string) - Optional - Specific assembly MVID ```