mitmproxy-mcp

mitmproxy-mcp

Transforms mitmproxy into a toolset for AI agents to inspect, modify, and replay HTTP/HTTPS traffic in real-time.

Category
访问服务器

README

mitmproxy MCP Server

A Model Context Protocol (MCP) server that transforms mitmproxy into a powerful toolset for AI agents. This allows LLMs (like Claude, GPT-4, or local models) to inspect, modify, and replay HTTP/HTTPS traffic in real-time.

New in this build (the fun stuff)

This project has grown beyond simple capture + replay. You can now:

  • Search traffic quickly with filters by domain/method/body text.
  • Extract data from responses using JSONPath or CSS selectors.
  • Use session variables to grab tokens from one response and reuse them in later replays.
  • Run lightweight fuzzing against query params or JSON body fields for quick DAST checks.
  • Reconstruct API patterns and export an OpenAPI-style spec from captured traffic.
  • Detect auth patterns (Bearer/JWT/API key/session cookie/CSRF/OAuth hints).
  • Generate starter scraper code from real captured flows.

Why use this?

Standard "web search" or "fetch" tools are stateless and easily detected. mitmproxy-mcp provides:

  • Deep Debugging: The agent can inspect full request/response cycles (headers, payloads, cookies) to identify why a frontend is failing or why an API is returning a 4xx/500 error.
  • API Reverse Engineering: Let the LLM observe undocumented internal APIs, map out JSON schemas, and generate client libraries or documentation automatically.
  • Automated Security Testing: Perform DAST (Dynamic Application Security Testing) by allowing the agent to inject payloads into specific parameters and analyze the response.
  • Live Interception: Modify traffic on the fly: inject headers, mock responses for testing, or block tracking pixels to reduce noise.
  • Stealth Replay: Uses curl-cffi to mimic Chrome/Safari TLS fingerprints, bypassing basic anti-bot measures that standard Python libraries trigger.

Key Features

  • Lifecycle Control: Start and stop the mitmproxy instance directly from the LLM.
  • Deep Inspection: Capture full request/response cycles, including headers, bodies, and timing.
  • Traffic Search & Filtering: Scope by domain, then search flows by query/method so context stays clean.
  • Active Interception: Dynamic rules to inject headers, replace body content via regex, or block requests.
  • Stealth Replay: Re-execute flows using curl-cffi to impersonate modern browser TLS fingerprints (e.g., Chrome).
  • Session-Aware Workflows: Extract dynamic values (like CSRF tokens) and re-inject them into replayed traffic.
  • Response Data Extraction: Pull structured values from HTML/JSON responses via CSS selectors and JSONPath.
  • API Discovery: Group similar endpoints, identify path/query params, and export OpenAPI JSON.
  • Security Recon Helpers: Detect common auth patterns and run targeted fuzz payloads.
  • Scraper Bootstrapping: Generate executable curl-cffi automation code from observed traffic.

Quickstart

Option 1: Using uvx (Recommended)

Add this to your MCP client configuration (e.g., Claude Desktop, Cursor, or AntiGravity):

{
  "mcpServers": {
    "mitmproxy-mcp": {
      "command": "uvx",
      "args": ["mitmproxy-mcp"]
    }
  }
}

Option 2: From a Cloned Repository

If you want to run from a local clone (useful for development or testing unreleased changes):

git clone https://github.com/snapspecter/mitmproxy-mcp.git

Then add this to your MCP client configuration, replacing the path with your clone location:

{
  "mcpServers": {
    "mitmproxy-mcp": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mitmproxy-mcp", "mitmproxy-mcp"]
    }
  }
}

Installation

Option 1: Global Install (with uv)

uv tool install mitmproxy-mcp

Option 2: Docker (Isolated Environment)

# Build and run
docker build -t mitmproxy-mcp .
docker run -p 8080:8080 mitmproxy-mcp

Option 3: Manual Pip Install

python -m venv venv
source venv/bin/activate
pip install mitmproxy-mcp

Available Tools

Lifecycle & Configuration

  • start_proxy(port=8080): Starts the mitmproxy server.
  • stop_proxy(): Shuts down the proxy.
  • set_scope(allowed_domains): Filters recorded traffic (e.g., ["api.github.com", "example.com"]).
  • list_tools(): Returns all exposed MCP tools and input schemas.

Inspection

  • get_traffic_summary(limit=20): Returns a list of recent network flows.
  • inspect_flow(flow_id): Provides full details and a curl equivalent for a specific flow.
  • search_traffic(query, domain, method, limit=50): Filter captured traffic by keyword/domain/method.
  • clear_traffic(): Clears persisted traffic history.

Modification & Interception

  • add_interception_rule(rule_id, action_type, ...):
  • action_type: inject_header, replace_body, or block.
  • phase: request or response.
  • set_global_header(key, value): Injects a header into every request.
  • remove_global_header(key): Removes a previously injected global header.
  • list_rules(): Shows currently active interception rules.
  • clear_rules(): Flushes all active interception rules.

Replay

  • replay_flow(flow_id, method, headers_json, body): Re-sends a request with modifications using browser-grade impersonation.

Extraction & Session Variables

  • extract_from_flow(flow_id, json_path=None, css_selector=None): Extract values from captured response bodies.
  • set_session_variable(name, value): Manually set a session variable.
  • extract_session_variable(name, flow_id, regex_pattern, group_index=1): Extract and save a variable from a response body.

Security & API Analysis

  • fuzz_endpoint(flow_id, target_param, param_type, payload_category, timeout=10.0): Replay with payload substitutions and report anomalies.
  • get_api_patterns(domain=None, limit=50): Cluster captured traffic into endpoint patterns.
  • export_openapi_spec(domain=None, limit=50): Produce an OpenAPI v3 JSON spec from captured traffic.
  • detect_auth_pattern(flow_ids=None): Infer likely auth mechanisms from observed requests.

Code Generation

  • generate_scraper_code(flow_ids, target_framework="curl_cffi"): Generate starter scraper/automation code from captured flows.

Programmatic Usage

Note: These are JSON-RPC calls sent by the MCP Host (Client). You do not need to type these manually in the terminal.

  1. Initialize the Proxy: {"method": "tools/call", "params": {"name": "start_proxy", "arguments": {"port": 8080}}}
  2. Intercept & Block: {"method": "tools/call", "params": {"name": "add_interception_rule", "arguments": {"rule_id": "block-ads", "action_type": "block", "url_pattern": ".*analytics.*"}}}
  3. Modify Response: {"method": "tools/call", "params": {"name": "add_interception_rule", "arguments": {"rule_id": "mock-api", "action_type": "replace_body", "url_pattern": ".*user/profile.*", "action_value": "{\"name\": \"AI Agent\"}"}}}

Helpful Tips

  • Manage Context: Use set_scope immediately. LLMs perform poorly when flooded with background OS telemetry.
  • Browser Setup: Ensure your browser or application is configured to use the proxy (usually localhost:8080) and has the mitmproxy CA certificates installed for HTTPS inspection.
  • Stealth: The replay_flow tool uses curl-cffi specifically to avoid being flagged as a bot by services that check TLS fingerprints.

Development

git clone [https://github.com/snapspecter/mitmproxy-mcp.git](https://github.com/snapspecter/mitmproxy-mcp.git)
cd mitmproxy-mcp
uv sync
uv run pytest

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选