### Usage example Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/McpServerConfig.md Shows how to load, modify, save, validate, and start the server. Includes error-tolerant load with defensive fallback. ```csharp // Read current configuration (from mcp_config.json) var config = McpServerConfig.Load(); // Modify config.IpAddress = "127.0.0.1"; // local-only, no admin required config.Port = 50300; config.Save(); // Validation helpers before saving from UI input if (!McpServerConfig.IsValidIpAddress(config.IpAddress)) config.IpAddress = "+"; var server = new SimpleMcpServer(typeof(Plugin), config); server.Start(); Console.WriteLine(config.GetDisplayUrl()); // http://127.0.0.1:50300/sse ``` ```csharp McpServerConfig cfg; try { cfg = McpServerConfig.Load(); // never throws; logs internally } catch { cfg = new McpServerConfig(); // defensive fallback } ``` -------------------------------- ### Start() method Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Starts the HttpListener and begins accepting requests asynchronously (BeginGetContext -> thread-pool task per request). Idempotent — logs "already running" and returns if already started. Failures (e.g. access denied on the URL prefix) are logged via Console.WriteLine("Failed to start MCP server: " + ex.Message) and swallowed. Source: MCPServer.cs:452-473. ```csharp public void Start() ``` -------------------------------- ### Start() Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Starts the HTTP listener and begins accepting requests asynchronously. Idempotent; logs and swallows failures. ```APIDOC ## Start() ### Description Starts the `HttpListener` and begins accepting requests asynchronously. Idempotent — logs "already running" and returns if already started. Failures are logged and swallowed. ### Method Start ### Signature ```csharp public void Start() ``` ### Parameters None ### Return Value void ### Exceptions None (failures are logged, not thrown) ``` -------------------------------- ### PluginBase.Setup(ref Plugins.PLUG_SETUPSTRUCT) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/PluginBase.md Called from plugsetup after menu setup. Override to customize setup behavior. ```APIDOC ## [METHOD] Setup(ref Plugins.PLUG_SETUPSTRUCT) ### Description Called from plugsetup after menu setup. Override to customize setup behavior. ### Method Setup ### Parameters - **setupStruct** (Plugins.PLUG_SETUPSTRUCT) - Required - The setup structure passed by x64dbg. ### Returns void ### Example ```csharp public override void Setup(ref Plugins.PLUG_SETUPSTRUCT setupStruct) { // custom setup } ``` ``` -------------------------------- ### Usage example for Script API wrappers Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/ScriptApi.md Shows how to use the Script API wrappers to resolve module info, search for a byte pattern, and get GUI selection. ```csharp using DotNetPlugin.NativeBindings.Script; // Resolve the module hosting the current instruction pointer var info = new Module.ModuleInfo(); if (Module.InfoFromAddr(cip, ref info)) Console.WriteLine($"{info.name} @ 0x{info.@base:X} size 0x{info.size:X}"); // Search for a byte pattern nuint hit = Pattern.FindMem(0x140000000, 0x10000, "48 8B 05 ?? ?? ?? ??"); // Selection from the GUI nuint selStart = Gui.Disassembly.SelectionGetStart(); nuint selEnd = Gui.Disassembly.SelectionGetEnd(); ``` -------------------------------- ### Construction and lifecycle usage Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Shows how the plugin constructs and manages the server: load config, create instance, start, serve, stop. Listens on http://+:50300/ by default. ```csharp var config = McpServerConfig.Load(); // IP/port from mcp_config.json var server = new SimpleMcpServer(typeof(DotNetPlugin.Plugin), config); server.Start(); // listens on http://+:50300/ // ... serve requests ... server.Stop(); ``` -------------------------------- ### ExpressionFunction usage example Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Attributes.md Example from Plugin.ExpressionFunctions.cs showing how to apply ExpressionFunctionAttribute to a method that returns nuint and takes nuint parameters. ```csharp [ExpressionFunction] public static nuint DotNetAdd(nuint a, nuint b) => a + b; ``` -------------------------------- ### BridgeStart Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Starts the bridge engine. Returns a pointer to a wide-character error string, or null on success. ```APIDOC ## BridgeStart ### Description Starts the bridge engine. Returns a pointer to a wide-character error string, or null on success. ### Method C# extern method ### Signature `public static extern IntPtr BridgeStart();` ### Parameters None ### Return Value - `IntPtr` - Pointer to a `const wchar_t*` error message, or `null` on success. ``` -------------------------------- ### Sample commands for X64Dbg MCP Client Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/README.md Example commands to issue once the MCP server is running via the plugin menu in x64dbg. These commands return JSON or text-formatted output suitable for AI models or integration scripts. ```text ExecuteDebuggerCommand command=init C:\InjectGetTickCount\InjectSpeed.exe ExecuteDebuggerCommand command="AddFavouriteCommand Log s, NameOfCmd" ReadDismAtAddress addressStr=0x000000014000153f, byteCount=5 ReadMemAtAddress addressStr=00007FFA1AC81000, byteCount=5 WriteMemToAddress addressStr=0x000000014000153f, byteString=90 90 90 90 90 90 CommentOrLabelAtAddress addressStr=0x000000014000153f, value=Test, mode=Comment CommentOrLabelAtAddress addressStr=0x000000014000153f, value= GetAllRegisters GetLabel addressStr=0x000000014000153f GetAllActiveThreads GetAllModulesFromMemMap GetCallStack ``` -------------------------------- ### EventCallback usage example Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Attributes.md Example from Plugin.EventCallbacks.cs showing how to apply EventCallbackAttribute to a static method. The method signature uses a ref-based info struct parameter. ```csharp [EventCallback(Plugins.CBTYPE.CB_INITDEBUG)] public static void OnInitDebug(ref Plugins.PLUG_CB_INITDEBUG info) { ... } ``` -------------------------------- ### TitanEngine usage example Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/TitanEngine.md Shows how to read the instruction pointer via GetContextData and statically load a PE file with StaticFileLoad. Requires the DotNetPlugin.NativeBindings.SDK namespace. StaticFileLoad uses named argument simulateLoad: true and returns a bool indicating success. ```csharp using DotNetPlugin.NativeBindings.SDK; // Read the current instruction pointer through TitanEngine UIntPtr eip = TitanEngine.GetContextData(TitanEngine.UE_CIP); // Static load of a PE file without executing it uint loadedSize = 0; bool ok = TitanEngine.StaticFileLoad(@"C:\targets\app.exe", 0, simulateLoad: true, IntPtr.Zero, ref loadedSize, IntPtr.Zero, IntPtr.Zero); ``` -------------------------------- ### Post-build xcopy and launch x64dbg Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/README.md Used in the DotNetPlugin.Impl project build post commands to copy the plugin DLL to the x64dbg plugins folder and launch x64dbg for debugging. Update the path to match your x64dbg installation. After rebuilding, X64Dbg autoloads the new plugin and you can reattach to the instance if needed. ```batch xcopy /Y /I "$(TargetDir)*.*" "C:\Users\User\Desktop\x96\release\x64\plugins\x64DbgMCPServer" C:\Users\User\Desktop\x96\release\x64\x64dbg.exe ``` -------------------------------- ### Grant URL permissions for MCP server (netsh http add urlacl) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/README.md Run these commands in an elevated PowerShell or Command Prompt to allow the MCP server to listen on HTTP URLs without running x64dbg as administrator. This resolves the 'Access is denied' error when starting the MCP server. ```cmd netsh http add urlacl url=http://+:50300/sse/ user=Everyone netsh http add urlacl url=http://+:50300/message/ user=Everyone ``` -------------------------------- ### NativeBindings usage example Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/NativeBindings.md Shows how to use the NativeBindings extension methods for marshaling strings and pointers, and the BlittableBoolean type for interop. Requires the DotNetPlugin.NativeBindings namespace and its Extensions class. ```csharp using DotNetPlugin.NativeBindings; using static DotNetPlugin.NativeBindings.Extensions; // extension methods IntPtr nativeBuffer = Marshal.AllocHGlobal(64); "MCP".MarshalToPtrUTF8(nativeBuffer, 64); string back = nativeBuffer.MarshalToStringUTF8(64); // "MCP" Marshal.FreeHGlobal(nativeBuffer); nuint val = 0x140001000; string hex = ((UIntPtr)val).ToPtrString(); // "0000000140001000" on x64 // Blittable bool across the interop boundary var flag = new BlittableBoolean { Value = true }; bool same = flag; // implicit bool ``` -------------------------------- ### DbgMemGetPageSize Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the page size for the given base address. Returns the page size. ```APIDOC ## DbgMemGetPageSize ### Description Gets the page size for the given base address. ### Method DbgMemGetPageSize ### Signature public static extern nuint DbgMemGetPageSize(nuint baseAddr); ### Parameters - **baseAddr** (nuint) - Required - The base address. ### Returns - **nuint** - The page size. ``` -------------------------------- ### GET / Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md Discovery ping or SSE session. Behavior depends on the Accept header. If Accept does not contain text/event-stream, returns server info. If it does, establishes a long-lived SSE stream. ```APIDOC ## [GET] / ### Description Discovery ping or SSE session. Behavior depends on the Accept header. If Accept does not contain text/event-stream, returns server info. If it does, establishes a long-lived SSE stream. ### Method GET ### Endpoint / ### Parameters #### Headers - **Accept** (string) - Required - Determines behavior: if contains `text/event-stream`, SSE stream; otherwise discovery ping. ### Response #### Success Response (200) - Discovery ping - **jsonrpc** (string) - JSON-RPC version. - **result** (object) - Server info. - **name** (string) - Server name. - **version** (string) - Server version. - **protocolVersion** (string) - Protocol version. - **transports** (array of strings) - Supported transports. #### Response Example (Discovery ping) ```json { "jsonrpc": "2.0", "result": { "name": "AgentSmithes x96Dbg", "version": "1.6", "protocolVersion": "2025-11-25", "transports": ["streamable-http", "sse"] } } ``` #### Success Response (200) - SSE stream - **Content-Type** (string) - `text/event-stream` - **SendChunked** (boolean) - true - **Cache-Control** (string) - `no-cache, no-store` - **X-Accel-Buffering** (string) - `no` - **Connection** (string) - `keep-alive` - **Mcp-Session-Id** (string) - Session ID (generated if not supplied) - First frame: `event: endpoint\ndata: /?sessionId=\n\n` - Then open-ended stream of `event: message\ndata: \n\n` frames, plus `: ping` heartbeats. ``` -------------------------------- ### PluginBase.SetupMenu(Menus menus) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/PluginBase.md Override to build menus. MenuException is caught and the menu cleared. ```APIDOC ## [METHOD] SetupMenu(Menus menus) ### Description Override to build menus. MenuException is caught and the menu cleared. ### Method SetupMenu ### Parameters - **menus** (Menus) - Required - The menu object model to populate. ### Returns void ### Example ```csharp protected override void SetupMenu(Menus menus) { // add menu items } ``` ``` -------------------------------- ### SimpleMcpServer(Type, string) constructor Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Uses default config plus a Bearer token. Source: MCPServer.cs:213-217. ```csharp public SimpleMcpServer(Type commandSourceType, string bearerToken) : this(commandSourceType, McpServerConfig.Load(), bearerToken) { } ``` -------------------------------- ### DbgMemMap Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the memory map. Returns true on success. ```APIDOC ## DbgMemMap ### Description Gets the memory map. ### Method DbgMemMap ### Signature public static extern bool DbgMemMap(ref MEMMAP_NATIVE memmap); ### Parameters - **memmap** (ref MEMMAP_NATIVE) - Required - Receives the memory map. ### Returns - **bool** - True on success. ``` -------------------------------- ### DbgDelEncodeTypeSegment Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Deletes encoding types for a segment starting at the given address. ```APIDOC ## DbgDelEncodeTypeSegment ### Description Deletes encoding types for a segment starting at the given address. ### Method C# P/Invoke ### Signature `public static extern void DbgDelEncodeTypeSegment(nuint start);` ### Parameters - **start** (nuint) - Required - Start address of the segment. ### Returns - **void** - No return value. ``` -------------------------------- ### DbgGetLabelAt Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the label at the given address. Returns true on success. ```APIDOC ## DbgGetLabelAt ### Description Gets the label at the given address. ### Method DbgGetLabelAt ### Signature public static unsafe bool DbgGetLabelAt(nuint addr, SEGMENTREG segment, out string text); ### Parameters - **addr** (nuint) - Required - The address. - **segment** (SEGMENTREG) - Required - The segment register. - **text** (out string) - Required - Receives the label text. ### Returns - **bool** - True on success. ``` -------------------------------- ### SimpleMcpServer(Type, McpServerConfig, string) constructor Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Full constructor. When bearerToken is null/whitespace the server runs without authentication; otherwise every non-OPTIONS request must present Authorization: Bearer , compared in constant time (ConstantTimeEquals). The listener registers the single prefix http://:/ — every path under host:port is routed inside HandleRequestAsync. Source: MCPServer.cs:222-257. ```csharp public SimpleMcpServer(Type commandSourceType, McpServerConfig config, string bearerToken) ``` -------------------------------- ### DbgGetCommentAt Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the comment at the given address. Returns true on success. ```APIDOC ## DbgGetCommentAt ### Description Gets the comment at the given address. ### Method DbgGetCommentAt ### Signature public static unsafe bool DbgGetCommentAt(nuint addr, out string text); ### Parameters - **addr** (nuint) - Required - The address. - **text** (out string) - Required - Receives the comment text. ### Returns - **bool** - True on success. ``` -------------------------------- ### DbgLoopGet Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Retrieves the start and end addresses of the loop at the given depth and address. ```APIDOC ## DbgLoopGet ### Description Retrieves the start and end addresses of the loop at the given depth and address. ### Method C# P/Invoke ### Signature `public static extern bool DbgLoopGet(int depth, nuint addr, out nuint start, out nuint end);` ### Parameters - **depth** (int) - Required - Loop depth. - **addr** (nuint) - Required - Address to look up. - **start** (out nuint) - Required - Receives the start address. - **end** (out nuint) - Required - Receives the end address. ### Returns - **bool** - True if a loop was found, false otherwise. ``` -------------------------------- ### SimpleMcpServer(Type commandSourceType) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Creates a SimpleMcpServer instance with authentication disabled, using IP/port from McpServerConfig.Load(). This constructor is used to initialize the server with default configuration. ```APIDOC ## SimpleMcpServer(Type commandSourceType) ### Description Creates the server with auth disabled, using IP/port from `McpServerConfig.Load()`. ### Constructor `public SimpleMcpServer(Type commandSourceType)` ### Parameters - **commandSourceType** (Type) - Required - Type whose static `[Command]`-annotated methods become MCP tools; the plugin passes `typeof(DotNetPlugin.Plugin)`. Throws `ArgumentNullException` if null. ### Example ```csharp var server = new SimpleMcpServer(typeof(DotNetPlugin.Plugin)); ``` ``` -------------------------------- ### DbgFunctionGet Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Retrieves the start and end addresses of the function containing the given address. ```APIDOC ## DbgFunctionGet ### Description Retrieves the start and end addresses of the function containing the given address. ### Method C# P/Invoke ### Signature `public static extern bool DbgFunctionGet(nuint addr, out nuint start, out nuint end);` ### Parameters - **addr** (nuint) - Required - The address to look up. - **start** (out nuint) - Required - Receives the start address. - **end** (out nuint) - Required - Receives the end address. ### Returns - **bool** - True if a function was found, false otherwise. ``` -------------------------------- ### DbgGetModuleAt Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the module name at the given address. Returns true on success. ```APIDOC ## DbgGetModuleAt ### Description Gets the module name at the given address. ### Method DbgGetModuleAt ### Signature public static unsafe bool DbgGetModuleAt(nuint addr, out string text); ### Parameters - **addr** (nuint) - Required - The address. - **text** (out string) - Required - Receives the module name. ### Returns - **bool** - True on success. ``` -------------------------------- ### DbgGetBranchDestination Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the destination address of a branch instruction. Returns the destination address. ```APIDOC ## DbgGetBranchDestination ### Description Gets the destination address of a branch instruction. ### Method DbgGetBranchDestination ### Signature public static extern nuint DbgGetBranchDestination(nuint addr); ### Parameters - **addr** (nuint) - Required - The address of the branch instruction. ### Returns - **nuint** - The destination address. ``` -------------------------------- ### GetAllModulesFromMemMap Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/MCP-Tools-Inspect.md Lists every image module currently mapped into the target process, with name, path, base address, end address, and size. Takes no arguments. ```APIDOC ## GetAllModulesFromMemMap ### Description Lists every image module currently mapped into the target process, with name, path, base address, end address, and size. Takes no arguments. ### Method Command ### Endpoint GetAllModulesFromMemMap ### Parameters None ### Request Example ``` GetAllModulesFromMemMap ``` ### Response #### Success Response - Returns a header and rows with `Name Path Base End Size` for each module. #### Response Example ``` Name Path Base End Size ... ``` ``` -------------------------------- ### Building main menu with fluent API Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Menus.md Builds the main plugin menu in Plugin.SetupMenu using AddAndConfigureItem and AddSeparator. Each AddAndConfigureItem returns a MenuItem, and .Parent returns to the Menu for chaining. ```csharp menus.Main .AddAndConfigureItem("&Start MCP Server", StartMCPServer).Parent .AddAndConfigureItem("&Stop MCP Server", StopMCPServer).Parent .AddSeparator() .AddAndConfigureItem("&Configure MCP Server...", ConfigureMCPServer).Parent .AddSeparator() .AddAndConfigureItem("&About...", OnAboutMenuItem); ``` -------------------------------- ### SimpleMcpServer(Type commandSourceType, McpServerConfig config, string bearerToken) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Full constructor that allows specifying both configuration and bearer token. When the token is null or whitespace, the server runs without authentication; otherwise every non-OPTIONS request must present the Authorization header with the token. ```APIDOC ## SimpleMcpServer(Type commandSourceType, McpServerConfig config, string bearerToken) ### Description Full constructor. When `bearerToken` is null/whitespace the server runs without authentication; otherwise every non-OPTIONS request must present `Authorization: Bearer `, compared in constant time (`ConstantTimeEquals`). The listener registers the single prefix `http://:/` — every path under host:port is routed inside `HandleRequestAsync`. ### Constructor `public SimpleMcpServer(Type commandSourceType, McpServerConfig config, string bearerToken)` ### Parameters - **commandSourceType** (Type) - Required - Type whose static `[Command]`-annotated methods become MCP tools; the plugin passes `typeof(DotNetPlugin.Plugin)`. Throws `ArgumentNullException` if null. - **config** (McpServerConfig) - Required - IP/port/bind settings. - **bearerToken** (string) - Required - Bearer token; null/whitespace disables auth. ### Example ```csharp var config = McpServerConfig.Load(); var server = new SimpleMcpServer(typeof(DotNetPlugin.Plugin), config, "my-token"); ``` ``` -------------------------------- ### SimpleMcpServer(Type commandSourceType, string bearerToken) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Creates a SimpleMcpServer using default configuration plus a Bearer token for authentication. If the token is null or whitespace, authentication is disabled. ```APIDOC ## SimpleMcpServer(Type commandSourceType, string bearerToken) ### Description Uses default config plus a Bearer token. ### Constructor `public SimpleMcpServer(Type commandSourceType, string bearerToken)` ### Parameters - **commandSourceType** (Type) - Required - Type whose static `[Command]`-annotated methods become MCP tools; the plugin passes `typeof(DotNetPlugin.Plugin)`. Throws `ArgumentNullException` if null. - **bearerToken** (string) - Required - Bearer token; null/whitespace disables auth. ### Example ```csharp var server = new SimpleMcpServer(typeof(DotNetPlugin.Plugin), "my-token"); ``` ``` -------------------------------- ### DbgArgumentGet Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Retrieves the start and end addresses of the argument (function argument) containing the given address. ```APIDOC ## DbgArgumentGet ### Description Retrieves the start and end addresses of the argument (function argument) containing the given address. ### Method C# P/Invoke ### Signature `public static extern bool DbgArgumentGet(nuint addr, out nuint start, out nuint end);` ### Parameters - **addr** (nuint) - Required - The address to look up. - **start** (out nuint) - Required - Receives the start address. - **end** (out nuint) - Required - Receives the end address. ### Returns - **bool** - True if an argument was found, false otherwise. ``` -------------------------------- ### DbgAddrInfoGet Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets address information for the given address. The flags field is a bitmask of ADDRINFOFLAGS values. ```APIDOC ## DbgAddrInfoGet ### Description Gets address information for the given address. ### Method DbgAddrInfoGet ### Signature public static bool DbgAddrInfoGet(nuint addr, int segment, ref BRIDGE_ADDRINFO_NATIVE addrinfo) ### Parameters - **addr** (nuint) - Required - The address. - **segment** (int) - Required - The segment. - **addrinfo** (ref BRIDGE_ADDRINFO_NATIVE) - Required - Receives the address information. ### Returns - **bool** - True on success. ### Notes - The `flags` field is a bitmask of `ADDRINFOFLAGS` values: `flagmodule` (0x1), `flaglabel` (0x2), `flagcomment` (0x4), `flagbookmark` (0x8), `flagfunction` (0x10), `flagloop` (0x20), `flagargs` (0x40), `flagNoFuncOffset` (0x80). ``` -------------------------------- ### BridgeInit Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Initializes the bridge engine. Returns a pointer to a wide-character error string, or null on success. ```APIDOC ## BridgeInit ### Description Initializes the bridge engine. Returns a pointer to a wide-character error string, or null on success. ### Method C# extern method ### Signature `public static extern IntPtr BridgeInit();` ### Parameters None ### Return Value - `IntPtr` - Pointer to a `const wchar_t*` error message, or `null` on success. ``` -------------------------------- ### DbgGetLabelAt Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Retrieves the label at a given address. This is used to get the symbolic name associated with a memory address. ```APIDOC ## DbgGetLabelAt ### Description Retrieves the label at a given address. This is used to get the symbolic name associated with a memory address. ### Method N/A (C# static method) ### Endpoint `Bridge.DbgGetLabelAt(ulong address, SEGMENTREG segment, out string label)` ### Parameters - **address** (ulong) - Required - The memory address to query. - **segment** (SEGMENTREG) - Required - The segment register to use (e.g., `SEG_DEFAULT`). - **label** (out string) - Required - The output label string. ### Request Example ```csharp if (Bridge.DbgGetLabelAt(addr, SEGMENTREG.SEG_DEFAULT, out string label)) Console.WriteLine(label); ``` ### Response - **bool** - Returns `true` if a label was found, otherwise `false`. - **label** (out string) - The label at the address. ``` -------------------------------- ### DbgModBaseFromName Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Gets the module base address from its name. Returns the base address as a native unsigned integer. ```APIDOC ## DbgModBaseFromName ### Description Gets the module base address from its name. ### Method DbgModBaseFromName ### Signature public static extern nuint DbgModBaseFromName(string name); ### Parameters - **name** (string) - Required - The module name. ### Returns - **nuint** - The base address. ``` -------------------------------- ### DbgInit Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Initializes the debugger engine. Returns a pointer to a character error string, or null on success. ```APIDOC ## DbgInit ### Description Initializes the debugger engine. Returns a pointer to a character error string, or null on success. ### Method C# extern method ### Signature `public static extern IntPtr DbgInit();` ### Parameters None ### Return Value - `IntPtr` - Pointer to a `const char*` error message, or `null` on success. ``` -------------------------------- ### PLUG_INITSTRUCT / PLUG_SETUPSTRUCT definitions Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Plugins.md Defines the structures consumed by the exported entry points in PluginMain. PLUG_SETUPSTRUCT drives PluginBase.SetupInternal with host window handle and all menu handles. ```csharp public static class Plugins { public struct PLUG_INITSTRUCT { /* sdkVersion, pluginVersion, pluginName, pluginHandle */ } public struct PLUG_SETUPSTRUCT { /* hwndDlg, hMenu, hMenuDisasm, ..., hMenuSymmod */ } } ``` -------------------------------- ### GET / (discovery ping) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md A simple ping endpoint to check server availability. Returns 200 on success. ```APIDOC ## [GET] / (discovery ping) ### Description A simple ping endpoint to check server availability. Returns 200 on success. ### Method GET ### Endpoint / ### Response #### Success Response (200) - No body content specified ``` -------------------------------- ### ListCommandsByCategory Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/MCP-Tools-Inspect.md Lists the available MCP tools, optionally filtered to a single category. Call with no category to list the available categories first. ```APIDOC ## ListCommandsByCategory ### Description Lists the available MCP tools, optionally filtered to a single category. Call with no category to list the available categories first. ### Method Command ### Endpoint ListCommandsByCategory ### Parameters #### Query Parameters - `category` (string) - Optional - Filter by `CommandCategory` name (case-insensitive). ### Request Example ``` ListCommandsByCategory category=Searching ``` ### Response #### Success Response - Returns a list of commands in the specified category, or the list of available categories if no category is provided. #### Response Example ``` Available categories: Searching, DebugControl, DebugFunctions ``` ``` -------------------------------- ### PluginBase.Init() Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/PluginBase.md Called after command/expression/callback registration. Override to perform initialization logic; default returns true. ```APIDOC ## [METHOD] Init() ### Description Called after command/expression/callback registration. Override to perform initialization logic; default returns true. ### Method Init ### Parameters None ### Returns - **bool** - true if initialization succeeded, false otherwise. ### Example ```csharp public override bool Init() { // custom initialization return true; } ``` ``` -------------------------------- ### DumpModuleToFile Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/MCP-Tools-Inspect.md Dumps the current module's register state and full disassembly (with labels and dereferenced strings) to a text file on disk. Example: DumpModuleToFile pfilepath=C:\Output.txt ```APIDOC ## DumpModuleToFile ### Description Dumps the current module's register state and full disassembly (with labels and dereferenced strings) to a text file on disk. Example: DumpModuleToFile pfilepath=C:\Output.txt ### Method Command ### Endpoint DumpModuleToFile ### Parameters #### Query Parameters - `pfilepath` (string) - Required - Absolute path of the output text file to write the dump to. ### Request Example ``` DumpModuleToFile pfilepath=C:\Output.txt ``` ### Response #### Success Response - Returns `"Command executed successfully"` on success. #### Response Example ``` Command executed successfully ``` ``` -------------------------------- ### Error handling for null commandSourceType Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md The constructor throws ArgumentNullException for commandSourceType; Start()/Stop() never throw publicly, they log. The exception's ParamName is "commandSourceType". ```csharp try { var server = new SimpleMcpServer(null); // ArgumentNullException } catch (ArgumentNullException ex) { Console.WriteLine(ex.ParamName); // "commandSourceType" } ``` -------------------------------- ### SimpleMcpServer(Type commandSourceType, McpServerConfig config) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Backward-compatible constructor that creates a SimpleMcpServer with authentication disabled, using the provided configuration for IP/port/bind settings. ```APIDOC ## SimpleMcpServer(Type commandSourceType, McpServerConfig config) ### Description Backward-compatible constructor; auth disabled. ### Constructor `public SimpleMcpServer(Type commandSourceType, McpServerConfig config)` ### Parameters - **commandSourceType** (Type) - Required - Type whose static `[Command]`-annotated methods become MCP tools; the plugin passes `typeof(DotNetPlugin.Plugin)`. Throws `ArgumentNullException` if null. - **config** (McpServerConfig) - Required - IP/port/bind settings. ### Example ```csharp var config = McpServerConfig.Load(); var server = new SimpleMcpServer(typeof(DotNetPlugin.Plugin), config); ``` ``` -------------------------------- ### SimpleMcpServer(Type) constructor Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Creates the server with auth disabled, using IP/port from McpServerConfig.Load(). Source: MCPServer.cs:197-201. ```csharp public SimpleMcpServer(Type commandSourceType) : this(commandSourceType, McpServerConfig.Load(), bearerToken: null) { } ``` -------------------------------- ### GET / (SSE stream) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md Establishes a Server-Sent Events (SSE) stream for receiving server events. Returns 200 on success. ```APIDOC ## [GET] / (SSE stream) ### Description Establishes a Server-Sent Events (SSE) stream for receiving server events. Returns 200 on success. ### Method GET ### Endpoint / ### Response #### Success Response (200) - No body content specified ``` -------------------------------- ### ReadDismAtAddress Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/MCP-Tools.md Disassembles instructions starting at an address and returns the listing (with bytes, labels, and any dereferenced strings) until the byte budget is reached. This command is debug-only and MCP-only. ```APIDOC ## ReadDismAtAddress ### Description Disassembles instructions starting at an address and returns the listing (with bytes, labels, and any dereferenced strings) until the byte budget is reached. This command is debug-only and MCP-only. ### Method Command ### Endpoint ReadDismAtAddress ### Parameters #### Parameters - **address** (string) - Required - Hex start address. - **byteCount** (int) - Required - Byte budget; hard cap 5000 instructions. ### Response Emits `address bytes instruction ; "dereferenced-string"` lines via `DbgDisasmFastAt`. ### Source `Plugin.Commands.cs:3194-3195` ``` -------------------------------- ### IPlugin interface definition (C#) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/PluginBase.md Defines the core plugin contract with PluginHandle, Init, Setup, Stop, and OnMenuEntry methods. Used as the base interface for plugin implementations. ```csharp internal interface IPlugin { int PluginHandle { get; } bool Init(); void Setup(ref Plugins.PLUG_SETUPSTRUCT setupStruct); bool Stop(); void OnMenuEntry(ref Plugins.PLUG_CB_MENUENTRY info); } ``` -------------------------------- ### StepInto Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/MCP-Tools.md Executes a single instruction, stepping INTO any call encountered (F7). Takes no arguments. ```APIDOC ## StepInto ### Description Executes a single instruction, stepping INTO any call encountered (F7). Takes no arguments. ### Method Command ### Endpoint StepInto ### Parameters None ### Request Example (No arguments) ### Response #### Success Response - **result** (string) - The result of the command execution. #### Response Example (Not provided) ``` -------------------------------- ### BridgeSettingRead Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Reads the bridge configuration settings from disk. ```APIDOC ## BridgeSettingRead ### Description Reads the bridge configuration settings from disk. ### Method C# extern method ### Signature `public static extern bool BridgeSettingRead(ref int errorLine);` ### Parameters - `errorLine` (ref int) - Required - Reference to an integer that receives the line number of a parse error, if any. ### Return Value - `bool` - `true` if the settings were read successfully, otherwise `false`. ``` -------------------------------- ### JSON-RPC response for tools/call Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md Example JSON-RPC 2.0 response to the tools/call request, containing a text result with register values and isError set to false. ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [{ "type": "text", "text": "RAX: 0x...\r\nRBX: 0x..." }], "isError": false } } ``` -------------------------------- ### GetBaseUrl() method Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/McpServerConfig.md Returns the HttpListener prefix, e.g. "http://+:50300/" (literally interpolates IpAddress/Port). ```csharp public string GetBaseUrl() ``` -------------------------------- ### Windsurf MCP Configuration (JSON) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/README.md Configuration for Windsurf using the MCPProxy STDIO-to-SSE bridge. Specifies the command path and arguments to connect to localhost:50300. ```json { "mcpServers": { "AgentSmithers x64Dbg STDIO<->SSE": { "command": "C:\\MCPProxy-STDIO-to-SSE.exe", "args": ["http://localhost:50300"] } } } ``` -------------------------------- ### DbgAssembleAt Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Assembles an instruction at the given address. Returns true on success. ```APIDOC ## DbgAssembleAt ### Description Assembles an instruction at the given address. ### Method DbgAssembleAt ### Signature public static extern bool DbgAssembleAt(nuint addr, string instruction); ### Parameters - **addr** (nuint) - Required - The address where to assemble. - **instruction** (string) - Required - The instruction to assemble. ### Returns - **bool** - True on success. ``` -------------------------------- ### PLogTextWriter definition Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/NativeBindings.md A TextWriter that forwards every write to Plugins._plugin_logprint, which is what x64dbg's log shows when the plugin calls Console.WriteLine. Installed by Plugin.Init(). NewLine is "\n". Source: DotNetPlugin.Stub/NativeBindings/SDK/PLog.cs. ```csharp public sealed class PLogTextWriter : TextWriter { public static readonly PLogTextWriter Default = new PLogTextWriter(); // overrides: Encoding (UTF-8), Write(char/char[]/string/format...), WriteLine(...) } ``` -------------------------------- ### SimpleMcpServer(Type, McpServerConfig) constructor Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/SimpleMcpServer.md Backward-compatible constructor; auth disabled. Source: MCPServer.cs:205-209. ```csharp public SimpleMcpServer(Type commandSourceType, McpServerConfig config) : this(commandSourceType, config, bearerToken: null) { } ``` -------------------------------- ### Raw HTTP request to tools/call Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md Example raw HTTP POST request to the MCP server endpoint. Uses the mcp-protocol-version header and calls the GetAllRegisters tool with empty arguments. ```http POST / HTTP/1.1 Host: 127.0.0.1:50300 Content-Type: application/json Accept: application/json mcp-protocol-version: 2025-11-25 {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"GetAllRegisters","arguments":{}}} ``` -------------------------------- ### DbgScriptStep Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Steps the script execution by one line. ```APIDOC ## DbgScriptStep ### Description Steps the script execution by one line. ### Method C# P/Invoke ### Signature `public static extern void DbgScriptStep();` ### Parameters None. ### Returns - **void** - No return value. ``` -------------------------------- ### POST / Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md JSON-RPC request. Accepts a JSON-RPC 2.0 request object (single object, no batch). Responses are framed by the Accept header. Notifications (no id and method starts with notifications/) return 202 Accepted. ```APIDOC ## [POST] / ### Description JSON-RPC request. Accepts a JSON-RPC 2.0 request object (single object, no batch). Responses are framed by the Accept header. Notifications (no id and method starts with notifications/) return 202 Accepted. ### Method POST ### Endpoint / ### Parameters #### Headers - **Accept** (string) - Required - Determines response framing: if contains `text/event-stream`, single-shot SSE; otherwise JSON. - **Mcp-Session-Id** (string) - Optional - Session ID for the request. #### Request Body - JSON-RPC 2.0 request object (single object; no batch support). ### Request Example ```json { "jsonrpc": "2.0", "method": "initialize", "id": 1 } ``` ### Response #### Success Response (200) - JSON response - JSON-RPC response object. #### Success Response (200) - SSE response (Accept: text/event-stream) - Content-Type: `text/event-stream` - KeepAlive: false - Closes after the frame. - Frame: `event: message\ndata: ` #### Success Response (202) - Notification - Body: `Accepted` (plain text) - No JSON-RPC response. #### Error Response - Parse error - JSON-RPC error `-32700` (`"Parse error: ..."` / `"Parse error reading body: ..."`) #### Error Response - Missing method - JSON-RPC error `-32600` `"Invalid Request: missing 'method'."` ``` -------------------------------- ### GuiGetLineWindow Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Retrieves the text from a line window in the GUI. ```APIDOC ## GuiGetLineWindow ### Description Retrieves the text from a line window in the GUI. ### Method C# managed wrapper ### Signature `public static void GuiGetLineWindow(string title, out string text)` ### Parameters - `title` (string) - Required - The title of the line window. - `text` (out string) - Required - The text from the window. ### Return Value None ``` -------------------------------- ### initialize Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/endpoints.md Initializes the MCP server connection and returns protocol version, capabilities, and server information. ```APIDOC ## initialize ### Description Initializes the MCP server connection and returns protocol version, capabilities, and server information. ### Method JSON-RPC ### Endpoint JSON-RPC method: initialize ### Parameters #### Request Body - **params** (object) - Required - Empty object. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { } } ``` ### Response #### Success Response - **protocolVersion** (string) - Protocol version. - **capabilities** (object) - Server capabilities. - **serverInfo** (object) - Server name and version. - **instructions** (string) - Instructions. - **meta** (object) - Metadata including eventSourceUrl and sessionId. #### Response Example ```json { "protocolVersion": "2025-11-25", "capabilities": { "tools": { "listChanged": true }, "prompts": { "listChanged": true }, "resources": { "listChanged": true, "subscribe": false } }, "serverInfo": { "name": "AgentSmithes x96Dbg", "version": "1.6" }, "instructions": "", "meta": { "eventSourceUrl": "/?sessionId=", "sessionId": "" } } ``` ``` -------------------------------- ### Save() method Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/McpServerConfig.md Serializes the instance and writes mcp_config.json, creating the directory if needed. Errors are logged as '[McpServerConfig] Error saving config: …' and swallowed. ```csharp public void Save() ``` -------------------------------- ### DbgScriptRun Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Runs the script from the given destination line. ```APIDOC ## DbgScriptRun ### Description Runs the script from the given destination line. ### Method C# P/Invoke ### Signature `public static extern void DbgScriptRun(int destline);` ### Parameters - **destline** (int) - Required - Destination line number. ### Returns - **void** - No return value. ``` -------------------------------- ### McpConfigDialog constructor signature Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/McpConfigDialog.md Constructor that seeds the form from the provided McpServerConfig, pre-filling the IP text box and port numeric up-down. Renders a live URL preview. Must be shown on an STA thread. ```csharp public McpConfigDialog(McpServerConfig currentConfig) ``` -------------------------------- ### GetDisplayUrl() method Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/McpServerConfig.md Returns a human-readable SSE URL, substituting display IP 127.0.0.1 when IpAddress == "+", e.g. "http://127.0.0.1:50300/sse". ```csharp public string GetDisplayUrl() ``` -------------------------------- ### Cursor MCP Server Configuration (JSON) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/README.md Configuration for connecting Cursor to the X64Dbg MCP server via SSE. Uses the URL http://127.0.0.1:50300/sse. ```json { "mcpServers": { "AgentSmithers X64Dbg MCP Server": { "url": "http://127.0.0.1:50300/sse" } } } ``` -------------------------------- ### DbgSetAutoBookmarkAt Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Sets an auto bookmark at the given address. Returns true on success. ```APIDOC ## DbgSetAutoBookmarkAt ### Description Sets an auto bookmark at the given address. ### Method DbgSetAutoBookmarkAt ### Signature public static extern bool DbgSetAutoBookmarkAt(nuint addr); ### Parameters - **addr** (nuint) - Required - The address. ### Returns - **bool** - True on success. ``` -------------------------------- ### Claude Desktop MCP Configuration (JSON) Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/README.md Configuration for Claude Desktop using the MCPProxy STDIO-to-SSE bridge. Specifies the command path and arguments to connect to localhost:50300. ```json { "mcpServers": { "x64Dbg": { "command": "C:\\MCPProxy-STDIO-to-SSE.exe", "args": ["http://localhost:50300"] } } } ``` -------------------------------- ### GuiGetWindowHandle Source: https://github.com/agentsmithers/x64dbgmcpserver/blob/master/_autodocs/api-reference/Bridge.md Retrieves the main window handle of the GUI. ```APIDOC ## GuiGetWindowHandle ### Description Retrieves the main window handle of the GUI. ### Method C# extern method ### Signature `public static extern IntPtr GuiGetWindowHandle();` ### Parameters None ### Return Value - `IntPtr` - The window handle. ```