Skip to main content
Glama
nevse
by nevse

DotnetDebugger.Mcp

An MCP server that lets an AI assistant debug .NET programs: launch or attach to a process, set breakpoints, step through code, inspect variables and evaluate expressions. It also carries a searchable reference on how .NET debuggers work internally.

Published on NuGet as DotnetDebugger.Mcp. Built on clrdbg, driven over the Debug Adapter Protocol. The debugger travels inside the package and runs as a child process, so a crash in native debugging code costs the debug session rather than the server.

Origin. A fork of decriptor/SharpDbg.MCP, now far enough from it to carry its own name: the debugger layer speaks the Debug Adapter Protocol instead of calling a debugger's internal API, the debugger underneath has since changed from SharpDbg to clrdbg, launching a program under the debugger is new, and the two have not shared a commit since. This repository was called SharpDbg.MCP until the first release; GitHub redirects the old name, and the project files and SHARPDBG_* settings still carry it.

What it can do

  • Attach to a running .NET process, or launch one and stop before its first line executes

  • Set breakpoints by file and line or by method name, with conditions and hit counts

  • Step over, into and out of code, and read the call stack for any thread

  • Inspect local variables, expand objects member by member, and evaluate C# expressions

  • Break on exceptions - all of them, only the unhandled ones, or only the types you name - and read what was thrown

  • Read the debuggee's stdout and stderr

  • Debug more than one process at once, each with its own breakpoints and stops

  • Debug a .NET MAUI app on an Android emulator or phone, an iOS simulator or device, or this Mac as a Mac Catalyst app - building it and stopping before its first line, same as a desktop program

  • Search embedded documentation on ICorDebug, the Debug Adapter Protocol and expression evaluation

Related MCP server: DebugMCP

What it cannot do

Some of these need changes in the underlying debugger rather than here.

  • Report the exit code of a process it attached to. exit_code is null there. The debugger reads the code off a process it started itself and has none for one it was pointed at, so for an attached process there is nothing to report — and the protocol cannot say "unknown", only 0, which would be a number this server made up. A program started with launch_program does report its real code.

  • Debug a self-contained single-file publish. The runtime is packed inside the executable, so the debugger shim cannot find it to load the matching components. The attempt fails immediately with CORDBG_E_DEBUG_COMPONENT_MISSING (0x80131C3C), reported as Attempting to register for runtime startup failed: -2146231236. Self-contained on its own works, and single-file on its own works; only the combination does not.

  • Watch expressions, hot reload and data breakpoints are not implemented.

Requirements

  • .NET 10 SDK or later

  • An MCP-compatible client, such as Claude Code or Claude Desktop

  • Windows, macOS or Linux

Install

One package carries the debugger and its native shims for every platform, so the same configuration works everywhere. There is nothing to clone or build.

Claude Code, for the current project:

claude mcp add dotnet-debugger -- dotnet tool exec DotnetDebugger.Mcp --yes

Add --scope user to make it available in every project, or --scope project to write a .mcp.json that is committed and shared with your team.

Claude Desktop, by editing ~/.config/Claude/claude_desktop_config.json on macOS and Linux, or %APPDATA%\Claude\claude_desktop_config.json on Windows:

{
  "mcpServers": {
    "dotnet-debugger": {
      "command": "dotnet",
      "args": ["tool", "exec", "DotnetDebugger.Mcp", "--yes"]
    }
  }
}

dnx DotnetDebugger.Mcp --yes is the shorter equivalent, and the form NuGet.org suggests. Prefer dotnet tool exec in a client launched from a desktop environment rather than from a shell: dnx lives in the SDK directory, which such a client often does not have on its PATH, while dotnet reliably is.

A client only connects its MCP servers when a session starts, so restart it after changing the configuration. To confirm the server is there, run claude mcp list or ask the client to list .NET processes.

Pinning a version

Installing the tool once avoids the resolution step on every start and keeps the version fixed until you change it:

dotnet tool install -g DotnetDebugger.Mcp

The command is then dotnet-debugger-mcp, with no arguments. This needs ~/.dotnet/tools on your PATH, which is why it is not the default suggestion: a client that cannot find the command fails the same way a wrong path does.

Upgrading

dotnet tool exec can keep running a version it has already downloaded, even after a newer one is published and indexed. Nothing looks wrong when it does: the server starts, the client reports it as connected, and the only sign is that the new release's tools are missing.

Measured while releasing 0.1.1. With only 0.1.0 in the local package folder, the unpinned command kept running 0.1.0, and clearing the NuGet HTTP cache did not change that. Naming the version once fetched the new package, after which the unpinned command used it too:

dotnet tool exec DotnetDebugger.Mcp --version 0.1.1 --yes

Installing the tool avoids the question entirely, because then upgrading is explicit:

dotnet tool update -g DotnetDebugger.Mcp

To see which version is actually running, ask the client to list this server's tools, or read the first line the server writes to stderr — it names the version at startup. A client's own health check reports only that the process started, not what it is.

A worked example

Catching a program before it has run a single line, which is the case attaching cannot reach:

User: "My app throws before it prints anything. Find out why."

Claude: [launch_program("/path/to/bin/Debug/net10.0/MyApp.dll")]
"Prepared, not running yet. Setting a breakpoint on the first line of Main."

Claude: [set_breakpoint("/path/to/Program.cs", 12)]
"Breakpoint set. It is unverified for now — nothing can bind before the program has
loaded its modules — and takes effect when the program starts."

Claude: [start_program()]
Claude: [wait_for_stop()]
"Stopped at Program.cs:12, before a single line has run."

Claude: [step_over(thread_id: 1)]
Claude: [get_variables(frame_id: 0)]
"configPath is null, and the next line passes it to File.ReadAllText."

Claude: [get_program_output()]
"The program printed nothing before the throw, which matches what you saw."

Tools

Debugging

Tool

What it does

list_dotnet_processes

List the .NET processes running on this machine

attach_to_process

Attach the debugger to a running .NET process

launch_program

Prepare a program to run under the debugger, stopped before it starts

start_program

Run the program prepared by launch_program

get_process_status

Report whether the session is running, stopped, and where

wait_for_stop

Block until the debuggee stops, instead of polling

get_program_output

Read what the debuggee wrote to stdout and stderr

detach_from_process

Detach, leaving the process running

list_sessions

List open sessions and what each is debugging

close_session

Close a session, detaching first if needed

.NET MAUI

Needs a one-off setup - see Debugging a .NET MAUI app.

Tool

What it does

list_mobile_devices

List Android emulators and phones, iOS simulators and devices, and this Mac

build_mobile_app

Build a MAUI project for one of them, against CoreCLR and with the debugging library inside

launch_mobile_app

Prepare the built app for debugging, stopped before it starts; start_program runs it

Breakpoints

Tool

What it does

set_breakpoint

Set or update a breakpoint at a file and line, with an optional condition or hit count

set_function_breakpoint

Set a breakpoint on a method by name, when the file and line are not known

remove_breakpoint

Remove a breakpoint of either kind

list_breakpoints

List this session's breakpoints and whether each is verified

set_exception_break_mode

Choose which exceptions stop the program: all, unhandled, or named types

Execution and inspection

Tool

What it does

continue_execution

Resume until the next breakpoint or exit

pause_execution

Break into the debugger where the program currently is

step_over, step_into, step_out

Step by line, into a call, or out of the current method

get_threads

List the threads in the debuggee

get_stack_trace

Read the call stack for a thread

get_variables

Read the locals of a stack frame

expand_variable

Expand an object into its members, which may expand further

evaluate_expression

Evaluate a C# expression in the context of a frame

get_exception_info

Read the type, message, stack trace and inner exception of what was thrown

Documentation

Tool

What it does

search_debugging_concepts

Search the embedded documentation

explain_icordebug_interface

Explain a specific ICorDebug interface

get_debugging_flow

Walk through a debugging operation step by step

list_debugging_concepts

Browse the concept catalogue by category

Things worth knowing

Breakpoints need portable PDBs

A breakpoint binds through the target's symbols, so the debuggee must be built with portable PDBs sitting next to its assembly. A missing or mismatched PDB is the most common reason set_breakpoint answers verified: false with No symbols have been loaded for this document.

Debug builds already do this. For a Release build, or any project that changes the defaults:

<PropertyGroup>
  <DebugType>portable</DebugType>
  <DebugSymbols>true</DebugSymbols>
</PropertyGroup>

Optimized code also moves locals out of reach, so get_variables is only fully useful with <Optimize>false</Optimize>.

macOS: headless environments may need an entitlement

macOS will not let a debugger take another process's task port unless the target carries com.apple.security.get-task-allow. A program run through the dotnet muxer is fine, because the muxer ships with that entitlement; an apphost produced by dotnet publish is ad-hoc signed with no entitlements at all.

The debugger's own side of this needs nothing from you: the debug adapter is started through the dotnet muxer as well, so it inherits the entitlements that let it debug at all.

On a desktop session this does not affect you. Debugging a self-contained publish carrying no entitlements is verified to work there.

It matters in a headless environment, such as a CI runner, and it fails badly when it does: macOS refuses by blocking rather than returning an error, so the debugger stops responding and the call never comes back. If a launch or attach hangs on macOS with no error at all, sign the target and try again:

codesign -s - -f --entitlements get-task-allow.entitlements ./MyApp

with get-task-allow.entitlements containing:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>com.apple.security.get-task-allow</key>
  <true/>
</dict>
</plist>

What Just My Code changes about stepping

SHARPDBG_JUST_MY_CODE=false does not make a step stop in code you have no symbols for. Neither setting does: a step that lands in a module without symbols steps straight back out, because there is no source to report a location against. A step through an interpolated string goes through System.Private.CoreLib and comes back to the next statement of your own method either way.

What the setting changes is which modules get their symbols looked for at all. With Just My Code on, only assemblies built by you are searched; with it off, every module is, so a step does surface inside a dependency you happen to have symbols for. That is what to turn it off for.

Attaching to other users' processes

A debugger can read and change everything in the process it attaches to, so by default this server attaches only to processes belonging to the user it runs as. attach_to_process refuses anything else before it looks at the process at all, and list_dotnet_processes marks each entry with an owner of current_user, other_user or unknown.

unknown is refused as well. On Windows that is what a system or elevated process looks like, since its token cannot be opened, and treating it as your own would make the check decorative wherever the lookup does not work.

SHARPDBG_ALLOW_OTHER_USER_PROCESSES=true lifts the restriction. The operating system still has its own say: on Linux and macOS a normal user cannot attach to another user's process even with this enabled, so in practice it matters when the server runs elevated or as root.

Debugging more than one process

By default the server debugs one process at a time, and SHARPDBG_MAX_SESSIONS raises that. Each session has its own process, breakpoints and stops.

attach_to_process and launch_program return a session_id. While only one session is open you can ignore it, because every tool defaults to the only session. Taking on a second process opens a second session rather than failing, and from then on session_id becomes required: with two processes open, guessing which one a continue_execution was meant for would be worse than asking.

detach_from_process leaves the session open and free, so the next attach or launch reuses it rather than taking another slot.

The default of one is deliberate. Every attach carries a risk of a native crash inside the debugging shim, so more sessions means more exposure. What such a crash costs is bounded: each session drives its own debug adapter in a process of its own, so the one that crashes takes its session with it and leaves the server and any other session running.

Debugging a .NET MAUI app

A MAUI app is debugged the same way a desktop program is - prepare, set breakpoints, start - but two things have to be true before it can be, and neither is true of an app built the ordinary way.

It has to run on CoreCLR. This debugger attaches to CoreCLR and nothing else, while a MAUI app still builds against Mono by default. CoreCLR is there from net10.0-android, and from net11.0 for -ios and -maccatalyst; below those versions the app would build, start, and never connect back, so build_mobile_app refuses them and says which version would work.

It has to carry the remote debugging library. Debugging a runtime on a phone takes a native library inside the app, which opens the connection the debugger attaches through, and a matching one on this side. Both belong to Visual Studio's debugger and cannot be redistributed, so they are not in this package - you point the server at a copy on your machine, laid out as it is distributed:

<some directory>/
  VsdbgRemoteCoreclrHost/     osx-arm64/, win-x64/, linux-x64/ …
  VsdbgRemoteCoreclrTarget/   android/, ios/, maccatalyst/ …

Set SHARPDBG_VSDBG_LIBRARIES to that directory, or pass it to either tool as vsdbg_libraries_path. SHARPDBG_REMOTE_CORECLR_HOST and SHARPDBG_REMOTE_CORECLR_TARGET name the two halves separately for a machine that does not keep them together.

Then the session looks like this:

list_mobile_devices()                                → ids to choose from
build_mobile_app(project_path, device_id)            → the .apk or .app, built to be debuggable
launch_mobile_app(project_path, device_id)           → prepared, not started
set_breakpoint(file, line)                           → in place before the app's first line
start_program()                                      → boots, installs, launches: minutes, not seconds
wait_for_stop()                                      → and from here it is an ordinary debug session

build_mobile_app adds an MSBuild file of its own to the build - it ships beside the server as Resources/CopyRemoteCoreclrTargetLibrary.targets, and is readable - which puts the target library into the app bundle or the Android package. Nothing in your project changes.

Some notes on what each platform does:

  • Android. Pick an emulator by its AVD name; it does not have to be running, because the debugger boots a cold one itself. A phone is picked by its adb serial. The app is built for every ABI at once, so there is no runtime identifier to choose. The app's logcat output arrives in get_program_output. uninstall_app: true clears a previous install first, which is what to reach for when a signature or a permission has changed.

  • iOS. A simulator is picked by its UDID and booted if it is not running. A physical device has to be provisioned for the app the usual way - the debugger installs and launches it, it does not sign it.

  • Mac Catalyst. The device id is maccatalyst; there is nothing to boot or install, which makes it the quickest way to check that the setup works at all.

process_id stays null throughout: the app runs on the device, so its pid is not one this machine could be pointed at. Everything else - breakpoints, stepping, locals, expressions, exceptions - behaves exactly as it does locally.

How failures are reported

Every tool reports a failure the same way:

{
  "success": false,
  "error": "Returned from a call to Continue that was not matched with a stopping event. (0x8013132F)",
  "explanation": "The process was already running, so there was nothing to resume. Check get_process_status before continuing."
}

error is whatever the debugger said, kept verbatim. explanation says what the failure means and what to do about it, for the CORDBG_E_* results the debugger raises: a process that has exited, an operation that needs the debuggee stopped, a variable that is not live at this instruction, a frame id from an earlier stop, another debugger already attached. It is null for failures that are not the debugger's, such as invalid arguments.

Configuration

Set these as environment variables in your client's configuration:

{
  "mcpServers": {
    "dotnet-debugger": {
      "command": "dotnet",
      "args": ["tool", "exec", "DotnetDebugger.Mcp", "--yes"],
      "env": {
        "SHARPDBG_LOG_LEVEL": "Debug"
      }
    }
  }
}

Variable

Description

Default

SHARPDBG_LOG_LEVEL

Trace, Debug, Information, Warning, Error or Critical

Information

SHARPDBG_MAX_SESSIONS

Sessions open at once, each debugging its own process

1

SHARPDBG_OPERATION_TIMEOUT_SECONDS

Bounds attaching, starting, pausing and closing a session. Steps and reads are not bounded

30

SHARPDBG_EVAL_TIMEOUT_MS

Bounds anything that runs code in the debuggee: evaluate_expression and get_exception_info. Minimum 100

5000

SHARPDBG_BREAKPOINT_BIND_TIMEOUT_MS

How long to wait for a breakpoint to bind before reporting it unverified, minimum 100

2000

SHARPDBG_JUST_MY_CODE

Restrict debugging to your own code. See above before turning this off

true

SHARPDBG_ALLOW_OTHER_USER_PROCESSES

Allow attaching to processes not owned by the current user

false

SHARPDBG_ENABLE_DIAGNOSTICS

Detailed diagnostic logging

false

SHARPDBG_VSDBG_LIBRARIES

Directory holding VsdbgRemoteCoreclrHost and VsdbgRemoteCoreclrTarget, needed to debug a MAUI app. See above

unset

SHARPDBG_REMOTE_CORECLR_HOST

The host half on its own, when the two are not kept together

unset

SHARPDBG_REMOTE_CORECLR_TARGET

The target half on its own

unset

SHARPDBG_MOBILE_START_TIMEOUT_SECONDS

Bounds start_program for a mobile app, which boots the emulator, installs and launches

600

SHARPDBG_BUILD_TIMEOUT_SECONDS

Bounds build_mobile_app

900

Troubleshooting

The server does not appear in the client. Check that the path in the configuration is absolute and correct, then fully quit and restart the client. Claude Desktop logs to ~/Library/Logs/Claude/ on macOS and %APPDATA%\Claude\logs\ on Windows.

Attaching fails. The usual causes are that the process is owned by another user (see above), has already exited, is not a .NET process, or already has a debugger attached. list_dotnet_processes shows what the server can see and who owns it.

A breakpoint is not hit. Check that it came back verified: true. If not, the PDB is the first thing to look at. If it is verified and still not hit, confirm the line is actually reached and that the file path matches the one the PDB records.

list_dotnet_processes comes back empty on macOS or Linux. Module enumeration needs permissions there, and the server falls back to detection by process name, which misses programs whose apphost is renamed.

A launch or attach hangs on macOS with no error. See the entitlement section above.

A MAUI app starts and never stops at a breakpoint. It is almost certainly running on Mono rather than CoreCLR - which happens when it was built by something other than build_mobile_app, since an ordinary dotnet build produces neither the runtime nor the library the debugger needs. Rebuild with build_mobile_app and launch the app it reports.

list_mobile_devices shows no Android devices. It reads emulators from the AVD directory and connected phones from adb, so it needs the Android SDK: set ANDROID_HOME or ANDROID_SDK_ROOT if it is somewhere unusual. The warnings in the response say which source could not be read and why.

To see what the server is doing, set SHARPDBG_LOG_LEVEL=Trace and SHARPDBG_ENABLE_DIAGNOSTICS=true, or run it directly and watch stderr:

dotnet tool exec DotnetDebugger.Mcp --yes

Development

git clone --recurse-submodules https://github.com/nevse/dotnet-debugger-mcp.git
cd dotnet-debugger-mcp
dotnet build
dotnet test

The debugger is a submodule at external/clrdbg, and the build compiles it and puts the adapter next to the server, so there is no separate step. A clone made without submodules fails the build with a message saying so; git submodule update --init --recursive is the fix. To build against a different clrdbg checkout - a fork carrying a fix, say - point ClrdbgSourcePath at it:

ClrdbgSourcePath=~/work/clrdbg dotnet build

The integration tests drive a real debuggee with real breakpoints, so they are slower than the rest and are separated by TestCategory=Integration.

To point a client at your working copy instead of the published package:

claude mcp add dotnet-debugger -- dotnet run --project "$(pwd)/src/SharpDbg.MCP/SharpDbg.MCP.csproj"

CONTRIBUTING.md covers the layout and conventions. docs/RELEASING.md covers cutting a release, including the nuget.org trusted-publishing policy that the workflow depends on but does not show.

License

MIT

Related MCP Connectors

  • Live browser debugging for AI assistants — DOM, console, network via MCP.

  • Shared debugging memory for AI coding agents

  • Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.

  • Run, debug, and triage tests from your IDE using natural language, no dashboard switching, no manual data transfers. The TestMu AI (formerly LambdaTest) MCP Server is a single remote server exposing four tool suites: HyperExecute — analyze your project, generate YAML configs and test runner commands, then monitor jobs and sessions. Automation — pull a TestID's details plus command, network, and console logs into one chat for instant root-cause analysis. Includes mobile app upload. SmartUI — explain pixel, layout, DOM, and perceptual changes in a visual regression run, with context-aware React/HTML/CSS fixes. Accessibility — audit any public URL or a local React app against WCAG and get ready-to-apply remediation steps. Connects over https://mcp.lambdatest.com/mcp using OAuth 2.1 — no API keys in your config. One-click install in Cursor; works with Claude, GitHub Copilot, Cline, and any MCP client. Tests execute on the TestMu AI cloud: 3,000+ browsers and 10,000+ real devices.

Related MCP Servers

  • A
    license
    C
    quality
    A
    maintenance
    Enables AI agents to perform step-through debugging of Python, JavaScript/Node.js, and Rust programs using the Debug Adapter Protocol, with support for breakpoints, variable inspection, and stack traces.
    21
    166
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to debug code inside VS Code by setting breakpoints, stepping through execution, inspecting variables, and evaluating expressions across multiple languages.
    507
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Enables AI assistants to start and manage LLDB debugging sessions, including loading programs, setting breakpoints, stepping through code, and examining memory.
    19
    1
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    Enables AI coding agents to debug .NET applications with breakpoints, stepping, variable inspection, and GUI automation for WPF, WinForms, and Avalonia apps.
    135
    6
    MIT