debug-mcp-server

alexrwilliam/debug-mcp-server

3.2

If you are the rightful owner of debug-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server designed for debugging and development operations in AI-driven scraper workflows.

Tools
  1. read_file

    Read file contents with optional line ranges.

  2. write_file

    Write content to files.

  3. search_file

    Search for regex patterns in files.

  4. edit_file

    Replace content in existing files.

  5. run_command

    Execute shell commands with timeout.

  6. run_python

    Run Python scripts in optional venv.

  7. extract_selectors

    Find CSS/XPath/Playwright selectors in code.

  8. setup_debug_session

    Initialize debug session with artifacts.

  9. get_session_artifacts

    List all session files and data.

Debug MCP Server

A Model Context Protocol (MCP) server that provides debugging and development operations for AI-driven scraper development workflows.

License: MIT Python 3.8+

๐Ÿš€ Features

  • ๐Ÿ“ File Operations: Read, write, search, and edit files with line-level precision
  • ๐Ÿ’ป Terminal Execution: Run commands, Python scripts, and manage virtual environments
  • ๐Ÿ” Code Analysis: Extract CSS/XPath selectors, validate syntax, and analyze code patterns
  • ๐Ÿ“Š Session Management: Persistent debug sessions with structured artifact management
  • ๐Ÿ”— Integration Ready: Designed to work seamlessly with Playwright MCP and HTTP MCP servers

๐Ÿ“ฆ Installation

From GitHub (Recommended)

pip install git+https://github.com/alexwilliamson/debug-mcp-server.git

For Development

git clone https://github.com/alexwilliamson/debug-mcp-server.git
cd debug-mcp-server
pip install -e .

๐Ÿƒ Quick Start

1. Start the Server

# HTTP transport (recommended for AI agents)
debug-mcp http --port 8932

# Or stdio transport (for direct MCP clients)
debug-mcp stdio

2. Connect from AI Agent

from mcp.client.sse import sse_client
from mcp import ClientSession
from langchain_mcp_adapters.tools import load_mcp_tools

async with sse_client("http://localhost:8932/sse") as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        debug_tools = await load_mcp_tools(session)
        
        # Now you have 9 powerful debugging tools available!
        for tool in debug_tools:
            print(f"Available: {tool.name}")

3. Use in Debug Workflows

This server powers automated scraper debugging workflows where AI agents:

  1. Generate scraper code
  2. Execute and test it
  3. Analyze errors automatically
  4. Generate and apply fixes
  5. Retry until working

๐Ÿ› ๏ธ Available Tools

File Operations

ToolDescriptionExample Use
read_fileRead file contents with optional line rangesRead scraper code, debug responses
write_fileWrite content to filesSave generated scrapers, debug scripts
search_fileSearch for regex patterns in filesFind CSS selectors, error patterns
edit_fileReplace content in existing filesApply targeted code fixes

Terminal Operations

ToolDescriptionExample Use
run_commandExecute shell commands with timeoutRun scrapers, install packages
run_pythonRun Python scripts in optional venvTest scraper execution

Code Analysis

ToolDescriptionExample Use
extract_selectorsFind CSS/XPath/Playwright selectors in codeAudit scraper selectors

Session Management

ToolDescriptionExample Use
setup_debug_sessionInitialize debug session with artifactsStart debugging workflow
get_session_artifactsList all session files and dataReview debug history

๐Ÿ—๏ธ Architecture Integration

This server is part of a complete AI scraper debugging stack:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Playwright MCP โ”‚    โ”‚   Debug MCP     โ”‚    โ”‚   HTTP MCP      โ”‚
โ”‚  Browser Auto   โ”‚    โ”‚  This Server    โ”‚    โ”‚  Network Test   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚    AI Agent         โ”‚
                    โ”‚                     โ”‚
                    โ”‚ 1. Plan Website     โ”‚
                    โ”‚ 2. Generate Code    โ”‚
                    โ”‚ 3. Debug & Fix      โ”‚
                    โ”‚ 4. Deliver Scraper  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”ง Configuration

Command Line Options

debug-mcp --help

# Common configurations:
debug-mcp http --port 8932                    # HTTP on custom port
debug-mcp stdio                               # Stdio for direct integration
debug-mcp http --session-dir ./my_sessions    # Custom session directory

Session Artifacts

Debug sessions create structured artifact directories:

debug_artifacts/
โ””โ”€โ”€ sessions/
    โ””โ”€โ”€ {session_id}/
        โ”œโ”€โ”€ metadata.json       # Session info
        โ”œโ”€โ”€ responses/          # HTTP responses, HTML files
        โ”œโ”€โ”€ code/              # Generated scrapers, fixes
        โ”œโ”€โ”€ analysis/          # Error analysis, reports  
        โ””โ”€โ”€ logs/              # Execution logs

๐Ÿค Integration Examples

With LangGraph Agents

from debug_subgraph import run_debug_workflow
from scraping_plan_models import PageAnalysis

# Your AI agent creates a scraping plan
plan = PageAnalysis(url="...", selectors=["..."], ...)

# Debug workflow automatically implements and tests
result = await run_debug_workflow(plan, goal, url)

if result["success"]:
    print(f"Working scraper: {result['scraper_path']}")
else:
    print(f"Debug failed: {result['error']}")

Standalone Usage

# Setup debug session
session = await setup_debug_session("/path/to/project")

# Generate and test code
scraper_code = "..."
await write_file(f"{session['debug_directory']}/scraper.py", scraper_code)
result = await run_python(f"{session['debug_directory']}/scraper.py")

# Analyze and fix if needed
if not result["success"]:
    errors = await search_file("debug.log", "ERROR")
    # Apply fixes based on error analysis

๐Ÿงช Testing

# Test the server directly
python -m debug_mcp.server http --port 8932

# In another terminal:
curl http://localhost:8932/health

๐Ÿ› Troubleshooting

Common Issues

  1. Import Errors: Ensure all dependencies installed with pip install -r requirements.txt
  2. Port Conflicts: Use different port with --port 8933
  3. Permission Errors: Check file system permissions for session directories
  4. Timeout Issues: Increase timeout for long-running operations

Debug Mode

Set logging level for detailed output:

export PYTHONPATH=/path/to/debug-mcp-server/src
debug-mcp http --port 8932 --log-level DEBUG

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“œ License

This project is licensed under the MIT License - see the file for details.

๐Ÿ™ Acknowledgments