mitmproxy-mcp

mitmproxy-mcp

MCP server for mitmproxy that lets any MCP client analyze, intercept, and replay HTTP/HTTPS traffic.

Category
访问服务器

README

mitmproxy-mcp

CI Python 3.10+ License: MIT

MCP server for mitmproxy that lets any MCP client analyze, intercept, and replay HTTP/HTTPS traffic.

What is this

mitmproxy-mcp runs as a mitmproxy addon. It embeds an MCP server directly in the proxy process, giving AI agents access to 24 tools for traffic analysis, request replay, interception control, and proxy configuration.

All captured data stays in-memory. Sensitive values (tokens, passwords, API keys, JWTs) are automatically redacted before being sent to the AI.

Installation

git clone https://github.com/moha-abdi/mitmproxy-mcp.git
cd mitmproxy-mcp

python3.10 -m venv .venv
source .venv/bin/activate

uv pip install -e ".[dev]"

# one-time: make mitmproxy/mitmdump/mitmweb use this env
# (prevents missing addon deps like `mcp` when system mitmproxy is used)
mitmproxy-mcp install-shims --force

Requires Python 3.10+ and mitmproxy >= 10.0.0.

Agent Skill (optional)

This repo also ships a skill definition in SKILL.md for the npx skills ecosystem.

Install it with:

npx skills add moha-abdi/mitmproxy-mcp

After installing, compatible coding agents can load the mitmproxy-mcp skill and get project-specific usage guidance.

Setup

1. Configure mitmproxy

Create or edit ~/.mitmproxy/config.yaml:

scripts:
  - /absolute/path/to/mitmproxy-mcp/addon.py

mcp_transport: sse
mcp_port: 9011

2. Start mitmproxy

mitmproxy      # interactive TUI
mitmweb        # web interface
mitmdump       # headless

The MCP server starts automatically on http://localhost:9011/sse. If the command still resolves to a system install, ensure your shim directory (default ~/.local/bin) is earlier in PATH, then restart the terminal.

3. Connect your AI client

All clients connect to the same SSE endpoint. Make sure mitmproxy is running before connecting.

<details> <summary><b>OpenCode</b></summary>

OpenCode's local type bridges via supergateway. Requires Node.js.

Add to opencode.json in your project root, or ~/.config/opencode/opencode.json globally:

{
  "mcp": {
    "mitmproxy": {
      "type": "local",
      "command": ["npx", "-y", "supergateway", "--sse", "http://127.0.0.1:9011/sse"],
      "enabled": true
    }
  }
}

</details>

<details> <summary><b>Claude Code</b></summary>

Via the CLI (project-level):

claude mcp add --transport sse mitmproxy http://localhost:9011/sse

To add globally across all projects:

claude mcp add --scope user --transport sse mitmproxy http://localhost:9011/sse

Or add manually to ~/.claude.json:

{
  "mcpServers": {
    "mitmproxy": {
      "type": "sse",
      "url": "http://localhost:9011/sse"
    }
  }
}

</details>

<details> <summary><b>Cursor</b></summary>

Add to .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "mitmproxy": {
      "url": "http://localhost:9011/sse"
    }
  }
}

</details>

<details> <summary><b>Windsurf</b></summary>

Add to ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "mitmproxy": {
      "url": "http://localhost:9011/sse"
    }
  }
}

</details>

<details> <summary><b>VS Code (Copilot)</b></summary>

Add to .vscode/mcp.json in your project root:

{
  "servers": {
    "mitmproxy": {
      "type": "http",
      "url": "http://localhost:9011/sse"
    }
  }
}

</details>

<details> <summary><b>Claude Desktop</b></summary>

Claude Desktop doesn't natively support SSE, so we use supergateway to bridge SSE to STDIO. Requires Node.js.

Add to your config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows):

{
  "mcpServers": {
    "mitmproxy": {
      "command": "npx",
      "args": ["-y", "supergateway", "--sse", "http://127.0.0.1:9011/sse"]
    }
  }
}

</details>

<details> <summary><b>Other clients</b></summary>

Any MCP client that supports SSE transport can connect directly to:

http://localhost:9011/sse

If your client only supports STDIO, use supergateway to bridge:

npx -y supergateway --sse http://127.0.0.1:9011/sse

</details>

Tools

Flow tools (12)

Tool Description
get_flows List captured flows with pagination and filtering
get_flow_by_id Get complete flow details
search_flows Search flows by regex pattern
get_flow_request Get request details
get_flow_response Get response details
mark_flow Mark a flow (same behavior as UI mark action)
unmark_flow Remove mark from a flow
focus_flow Move UI focus to a visible flow by ID
focus_flow_index Move UI focus by visible list index
clear_flows Clear all captured flows (and UI view when sync includes clear)
get_flow_count Count captured flows
export_flows Export flows to HAR format

Replay tools (4)

Tool Description
replay_request Replay a captured request as-is
send_request Send a new HTTP request
modify_and_send Modify a captured request and send it
duplicate_flow Clone a flow for comparison

Replay tool flows are reflected to mitmproxy's flow list when mcp_view_sync_actions includes replay (default all). replay_request replays the original flow in-place when replay sync is enabled; otherwise it creates a detached replay flow.

Intercept tools (5)

Tool Description
set_intercept_filter Set filter expression (e.g. ~u example.com)
get_intercepted_flows List currently intercepted flows
resume_flow Resume a single intercepted flow
resume_all Resume all intercepted flows
drop_flow Drop an intercepted flow

Config tools (3)

Tool Description
get_options Get current mitmproxy options
set_option Set a mitmproxy option (dangerous ones are blocked)
get_status Get proxy status and version info

Options

Pass via --set flag or set in ~/.mitmproxy/config.yaml:

Option Default Description
mcp_transport stdio Transport: stdio, sse, or tcp
mcp_port 9011 Port for SSE/TCP transport
mcp_max_flows 1000 Max flows to keep in memory (oldest evicted first)
mcp_redact false Redact sensitive data (tokens, keys, passwords) before sending to AI
mcp_redact_patterns (empty) Additional redaction patterns as JSON array (requires mcp_redact: true)
mcp_view_sync_actions all Which MCP actions sync to mitmproxy view: all, none, replay, clear, or replay,clear

Example:

mitmdump -s addon.py --set mcp_transport=sse --set mcp_port=9011 --set mcp_max_flows=5000

Privacy

By default, redaction is off -- you see the raw traffic as-is. To enable it, set mcp_redact to true in your config or via flags:

# ~/.mitmproxy/config.yaml
mcp_redact: true
# or via flags
mitmdump -s addon.py --set mcp_redact=true

When enabled, the following are automatically redacted before reaching the AI:

  • Bearer tokens, Basic auth credentials
  • API keys (header and query parameter)
  • Passwords, secrets
  • JWTs
  • Session IDs, auth tokens, session cookies

Request and response bodies are truncated to 10KB to prevent context overflow.

You can also add custom redaction patterns:

mitmdump -s addon.py --set mcp_redact=true --set mcp_redact_patterns='["internal_secret", "x-custom-key"]'

Project structure

mitmproxy-mcp/
  addon.py              thin wrapper for mitmproxy script loading
  mitmproxy_mcp/        main package
    __init__.py
    addon.py            mitmproxy addon with MCP server
    models.py           pydantic models for flow serialization
    storage.py          thread-safe in-memory flow storage
    privacy.py          redaction engine
    transport.py        stdio, sse, tcp transport layer
    tools/
      flows.py          flow query tools
      replay.py         replay and modification tools
      intercept.py      interception control tools
      config.py         proxy configuration tools
  tests/                test suite

Development

# install in editable mode (required for imports to work)
uv pip install -e ".[dev]"

# run tests
pytest tests/ -v

# run a specific test file
pytest tests/test_flow_tools.py -v

# with coverage
pytest tests/ --cov=mitmproxy_mcp --cov-report=html

# lint
ruff check .

# type check
mypy

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选