This is a dnSpy MCPServer Extension for the use of automated AI .NET reverse engineering The Example1.Extension has been updated to include the MCPServer logic with a few starting function to feed the decompiled code back to the LLM. This is an ongoing project and I plan to continue to add commands as time persist.
To execute the server, run as Administrator so the the Http server may Listen on +:3001 (release is currently set to 3003).
The following command will suffice:
cd {dnspy directory}
dnspy.exe --extension-directory {Path to extension}
Ex. dnspy.exe --extension-directory "C:\repos\dnSpy\Extensions\Examples\Example1.Extension\bin\Debug\net48"
Example 2 in CMD: C:\Users\user>"C:\Users\user\source\repos\DnSpy-MCPserver-Extension\dnSpy\dnSpy\bin\Debug\net48\dnspy.exe" --extension-directory "C:\Users\user\source\repos\DnSpy-MCPserver-Extension\dnSpy\dnSpy\bin\Debug\net48\Extensions"
In alternative you may copy the release into the Extension folder within the dnSpy\Extensions\AgentSmithersMCPServer path.
Ensure to compile the primary DnSpy Soultion (Clean and rebuild) so that the dependancies for "AgentSmithers DnSpyEx MCPServer" can use them for its own build. (Note: When compiling DnSpyEx you may have approx. ~20 errors, this will not prevent the 45 Projects from compiling)

Once dnSpy is fully cleaned and compiled, navigate to the Example1 Extension Project. In there is the modified code. Make your adjustments, compile then use the --extension-directory argument when executing DnSpy.exe to point to your projects extension path.
In alternative you may pull down the latest dnSpyEx then rename the Extension sample folder to another name and bring the modified extension folder over to recompile.
Currently readonly commands are supported to enumerate active namespaces, classes and functions by the AI. Plans are in the works to allow the AI to make interactive adjustments to the decompiled assemblies.
Get_Selected_Node - Gets the currently selected node within dnSpyEx
Get_Loaded_Assemblies - Gets all Assemblys currently loaded within dnSpyEx
Namespaces_From_Assembly - Dumps all unique namespaces under a given Assembly
Classes_From_Namespace - List all Classes under a given Namespace
Get_Class_Sourcecode - Dumps a target Class sourcecode
Get_Method_Prototypes - List all Method prototypes from a given Class within a given Namespace
Get_Method_SourceCode - Dumps a target Method's sourcecode
Update_Method_SourceCode - Update a target Method's sourcecode
Get_Function_Opcodes - Returns the IL opcodes of the specified method (with source line numbers)
Set_Function_Opcodes - Modifies the IL of the specified method at a given IL line index
Update_Tabs_View - Update all active tabs to reflect any changes or adjustments
Rename_Namespace - Renames exactly one distinct namespace across all types
Rename_Class - Renames a specific class within a given Namespace
Rename_Method - Renames a specific Methods by Class within a given Namespace
These commands allow you to inspect and modify .NET assemblies loaded in dnSpyEx, including viewing and editing source code, IL code, and performing various renaming operations.
A messagebox will appear allowing you a chance to attach your debugger if nessessary

Click "OK" and the MCPServer will load on :3001
Connect via SSE or if your application only supports STDIO (Claude Desktop / Windsurf) grab a copy of the STDIO<->SSE bridge https://github.com/AgentSmithers/MCPProxy-STDIO-to-SSE
Attach the Bridge AFTER hitting "OK" and your good to go.

