alexrwilliam/debug-mcp-server
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.
read_file
Read file contents with optional line ranges.
write_file
Write content to files.
search_file
Search for regex patterns in files.
edit_file
Replace content in existing files.
run_command
Execute shell commands with timeout.
run_python
Run Python scripts in optional venv.
extract_selectors
Find CSS/XPath/Playwright selectors in code.
setup_debug_session
Initialize debug session with artifacts.
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.
๐ 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:
- Generate scraper code
- Execute and test it
- Analyze errors automatically
- Generate and apply fixes
- Retry until working
๐ ๏ธ Available Tools
File Operations
Tool | Description | Example Use |
---|---|---|
read_file | Read file contents with optional line ranges | Read scraper code, debug responses |
write_file | Write content to files | Save generated scrapers, debug scripts |
search_file | Search for regex patterns in files | Find CSS selectors, error patterns |
edit_file | Replace content in existing files | Apply targeted code fixes |
Terminal Operations
Tool | Description | Example Use |
---|---|---|
run_command | Execute shell commands with timeout | Run scrapers, install packages |
run_python | Run Python scripts in optional venv | Test scraper execution |
Code Analysis
Tool | Description | Example Use |
---|---|---|
extract_selectors | Find CSS/XPath/Playwright selectors in code | Audit scraper selectors |
Session Management
Tool | Description | Example Use |
---|---|---|
setup_debug_session | Initialize debug session with artifacts | Start debugging workflow |
get_session_artifacts | List all session files and data | Review 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
- Import Errors: Ensure all dependencies installed with
pip install -r requirements.txt
- Port Conflicts: Use different port with
--port 8933
- Permission Errors: Check file system permissions for session directories
- 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Acknowledgments
- Built for AI-driven development workflows
- Integrates with Model Context Protocol (MCP)
- Designed for LangGraph agent workflows
- Part of automated scraper development pipeline