MCP-PDB logo

MCP-PDB

Community
samefarrar

MCP-PDB provides tools for using Python's debugger (pdb) with Claude and other LLMs through the Model Context Protocol (MCP). This was inspired by debug-gym by Microsoft, which showed gains in…

Publishersamefarrar
Repositorymcp-pdb
LanguagePython
Forks
18
Stars
54
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    MCP-PDB exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    54 stars and 18 forks from the linked repository.

MCP-PDB: Python Debugger Interface for Claude/LLMs

Python License

MCP-PDB provides tools for using Python's debugger (pdb) with Claude and other LLMs through the Model Context Protocol (MCP). This was inspired by debug-gym by Microsoft, which showed gains in various coding benchmarks by providing a coding agent access to a python debugger.

⚠️ Security Warning

This tool executes Python code through the debugger. Use in trusted environments only.

Installation

Works best with uv

Claude Code

bash
# Install the MCP server
claude mcp add mcp-pdb -- uv run --with mcp-pdb mcp-pdb

# Alternative: Install with specific Python version
claude mcp add mcp-pdb -- uv run --python 3.13 --with mcp-pdb mcp-pdb

# Note: The -- separator is required for Claude Code CLI

Windsurf

json
{
  "mcpServers": {
    "mcp-pdb": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-pdb",
        "mcp-pdb"
      ]
    }
  }
}

Available Tools

ToolDescription
start_debug(file_path, use_pytest, args)Start a local debugging session for a Python file
connect_remote_debug(host, port, timeout)Connect to a remote PDB session over TCP
send_pdb_command(command)Send a command to the running PDB instance (local or remote)
set_breakpoint(file_path, line_number)Set a breakpoint at a specific line
clear_breakpoint(file_path, line_number)Clear a breakpoint at a specific line
list_breakpoints()List all current breakpoints
restart_debug()Restart/reconnect the current debugging session
examine_variable(variable_name)Get detailed information about a variable
get_debug_status()Show the current state of the debugging session
end_debug()End the current debugging session (closes socket for remote)

Remote Debugging

Connect to a Python process that exposes PDB over a TCP socket. All existing tools (send_pdb_command, set_breakpoint, examine_variable, etc.) work identically once connected.

rpdb — dual-session debugger (recommended)

rpdb is installed alongside mcp-pdb and is the easiest way to debug with both a local terminal and the MCP agent simultaneously.

Terminal ──→ stdin ──→ PDB ──→ stdout ──→ Terminal
                            └──→ socket ──→ mcp-pdb
mcp-pdb  ──→ socket ──┘  (local stdin takes priority)

Start a script under rpdb:

bash
REMOTE_PDB_PORT=4444 rpdb script.py [args]
REMOTE_PDB_PORT=4444 rpdb -m mymodule [args]

rpdb prints waiting for mcp connection on 127.0.0.1:4444 ... and blocks until the MCP agent connects. All normal pdb flags (-c, --help, etc.) are supported.

Then connect from Claude / the MCP agent:

connect_remote_debug(host="127.0.0.1", port=4444)

All PDB output is now mirrored to both the terminal and the agent. Commands typed in the terminal take priority; the agent's commands are echoed to the terminal so you can follow along.

Environment variables:

VariableDefaultDescription
REMOTE_PDB_HOST127.0.0.1Interface to listen on (0.0.0.0 for remote machines)
REMOTE_PDB_PORT4444TCP port

In-source one-liner (correct frame, all locals visible):

python
# Add at the line you want to break at:
from mcp_pdb.rpdb import set_trace; set_trace()

The process blocks here until the MCP agent (or any TCP client) connects.

Zero-code-change with breakpoint():

bash
PYTHONBREAKPOINT=mcp_pdb.rpdb.set_trace python script.py

Python ≥ 3.11 with --pdbcls (remote only, no local terminal):

bash
python -m pdb --pdbcls=mcp_pdb.rpdb:Debugger script.py
pytest --pdb --pdbcls=mcp_pdb.rpdb:Debugger

Manual remote-pdb setup

If you need to attach to an already-running process without using rpdb:

Option A – remote-pdb package

python
from remote_pdb import RemotePdb
RemotePdb("0.0.0.0", 4444).set_trace()

Option B – stdlib only

python
import io, socket, pdb

srv = socket.socket()
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(("0.0.0.0", 4444))
srv.listen(1)
conn, _ = srv.accept()   # blocks until MCP connects
f = conn.makefile("rwb", buffering=0)
pdb.Pdb(stdin=io.TextIOWrapper(f), stdout=io.TextIOWrapper(f)).set_trace()

Connect from Claude / the LLM:

connect_remote_debug(host="192.168.1.10", port=4444)

timeout (default 30 s) controls how long to retry on ConnectionRefused— useful when the remote process has not yet reached set_trace().

restart_debug() reconnects to the same host/port. end_debug() closes the socket gracefully (sends q first).

Common PDB Commands

CommandDescription
nNext line (step over)
sStep into function
cContinue execution
rReturn from current function
p variablePrint variable value
pp variablePretty print variable
b file:lineSet breakpoint
cl numClear breakpoint
lList source code
qQuit debugging

Features

  • Project-aware debugging with automatic virtual environment detection
  • Support for both direct Python debugging and pytest-based debugging
  • Automatic breakpoint tracking and restoration between sessions
  • Works with UV package manager
  • Variable inspection with type information and attribute listing

Troubleshooting

Claude Code Installation Issues

If you encounter an error like:

MCP server "mcp-pdb" Connection failed: spawn /Users/xxx/.local/bin/uv run --python 3.13 --with mcp-pdb mcp-pdb ENOENT

Make sure to include the -- separator when using claude mcp add:

bash
# ✅ Correct
claude mcp add mcp-pdb -- uv run --with mcp-pdb mcp-pdb

# ❌ Incorrect (missing --)
claude mcp add mcp-pdb uv run --with mcp-pdb mcp-pdb

To verify your installation:

bash
# Check if mcp-pdb is listed
claude mcp list | grep mcp-pdb

# Check server status in Claude Code
# Type /mcp in Claude Code to see connection status

License

MIT License - See LICENSE file for details.

Installation

TypingMind
{
  "mcpServers": {
    "mcp-pdb": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp-pdb",
        "mcp-pdb"
      ]
    }
  }
}

Use MCP-PDB MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP-PDB is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP-PDB as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP-PDB MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mcp-pdb": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP-PDB MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP-PDB MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP-PDB to help me with this task?
MCP-PDB
Sure. I read it.
Here is what I found using MCP-PDB.

Frequently asked questions

What is the MCP-PDB MCP server used for?

MCP-PDB is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP-PDB MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP-PDB with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP-PDB MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP-PDB connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP-PDB MCP to TypingMind?

MCP-PDB runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCP-PDB MCP provide in TypingMind?

MCP-PDB exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP-PDB MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP-PDB requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇