MCPHawk 标志

MCPHawk

社区
tech4242

MCPHawk is a new Logging & Monitoring solution for Model Context Protocol (MCP) traffic, providing deep visibility into MCP client-server interactions. It started off as a mix between Wireshark and mcpinspector, purpose-built for the MCP ecosystem, and is now slowly turning into something more.

发布者tech4242
代码仓库mcphawk
语言Python
复刻数
1
星标数
14
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    MCPHawk 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 14 个 Star 和 1 个 Fork。

CI codecov Python Typer FastAPI Vue.js Ruff PEP8 License: MIT

MCPHawk is a new Logging & Monitoring solution for Model Context Protocol (MCP) traffic, providing deep visibility into MCP client-server interactions. It started off as a mix between Wireshark and mcpinspector, purpose-built for the MCP ecosystem, and is now slowly turning into something more.

Key Capabilities:

  • Protocol-Aware Capture: Understands MCP's JSON-RPC 2.0 transport layer, capturing and reassembling messages from stdio pipes and HTTP streams
  • Transport Agnostic: Monitors MCP traffic across all standard transports (stdio, HTTP Streaming, HTTP+SSE)
  • Full Message Reconstruction: Advanced stream reassembly handles fragmented packets, chunked HTTP transfers, SSE streams, and stdio pipes

Core Features

🔍 MCP Protocol Analysis

  • Complete JSON-RPC 2.0 Support: Correctly identifies and categorizes all MCP message types
    • Requests: Method calls with unique IDs for correlation
    • Responses: Success results and error responses with matching IDs
    • Notifications: Fire-and-forget method calls without IDs
    • Batch Operations: Support for JSON-RPC batch requests/responses
  • Transport-Specific Handling: See MCP Transport Support table below for full details
    • Chunked Transfer: Handles HTTP chunked transfer encoding transparently
  • Protocol Compliance: Validates JSON-RPC 2.0 structure and MCP-specific extensions

🚀 Advanced Capture Capabilities

  • Auto-Discovery Mode: Intelligently detects MCP traffic on any port using pattern matching
  • TCP Stream Reassembly: Reconstructs complete messages from fragmented packets
  • Multi-Stream Tracking: Simultaneously monitors multiple MCP client-server connections
  • IPv4/IPv6 Dual Stack: Native support for both IP protocols
  • Zero-Copy Architecture: Efficient packet processing without client/server overhead

📊 Analysis & Visualization

  • Real-Time Web Dashboard: Live traffic visualization with WebSocket updates
  • Message Flow Visualization: Track request-response pairs using JSON-RPC IDs
  • Traffic Statistics: Method frequency, error rates, response times
  • Search & Filter: Query by method name, message type, content patterns
  • Export Capabilities: Save captured sessions for offline analysis

🛠️ Developer Experience

  • MCP Server Integration: Query captured data using MCP protocol itself
    • FastMCP-based implementation for maximum compatibility
    • Available tools: query_traffic, search_traffic, get_stats, list_methods
    • Supports both stdio and HTTP transports
  • Multiple Interfaces:
    • Web UI for interactive exploration
    • CLI for scripting and automation
    • MCP server for programmatic access
  • Flexible Deployment:
    • Standalone sniffer mode
    • Integrated web + sniffer
    • Historical log analysis without active capture

MCP Transport Support

Official MCP TransportProtocol VersionCapture SupportDetails
stdioAll versions✅ FullProcess wrapper transparently captures stdin/stdout between client and server
HTTP Streaming2025-03-26+✅ FullHTTP POST with optional SSE streaming responses
HTTP+SSE (deprecated)2024-11-05✅ FullLegacy transport with separate SSE endpoint

Note: Raw TCP traffic with JSON-RPC is also captured and marked as "unknown" transport type

Comparison with Similar Tools

FeatureMCPHawkmcpinspectorWireshark
Passive sniffing (no proxy needed)✅❌✅
MCP/JSON-RPC protocol awareness✅✅❌
SSE/Chunked HTTP support✅❓❌
TCP stream reassembly✅❌✅
Auto-detect MCP traffic✅❌❌
Web UI for live/historical traffic✅✅❌
JSON-RPC message type detection✅❌❌
MCP server for data access✅❌❌
No client/server config needed✅❌✅
Interactive testing/debugging❌✅❌
Proxy/MITM capabilities✅ (stdio)✅❌

When to use each tool:

  • MCPHawk: Passive monitoring, protocol analysis, debugging MCP implementations, understanding traffic patterns
  • mcpinspector: Active testing, crafting requests, interactive debugging with proxy
  • Wireshark: General network analysis, non-MCP protocols, packet-level inspection

TLS/HTTPS Limitations

MCPHawk captures unencrypted MCP traffic only. It cannot decrypt:

  • HTTPS/WSS (WebSocket Secure) connections
  • TLS-encrypted TCP connections
  • Any SSL/TLS encrypted traffic

This tool is ideal for:

  • 🛠️ Local MCP development - Debug your MCP server implementations
  • 🔍 Understanding MCP protocol - See actual JSON-RPC message flow
  • 🐛 Troubleshooting local tools - Monitor Claude Desktop, Cline, etc. with YOUR local MCP servers
  • 📊 Development/staging environments - Where TLS is often disabled

Installation

For Users

bash
# Install from PyPI
pip install mcphawk

# Or install directly from GitHub
pip install git+https://github.com/tech4242/mcphawk.git

Requirements

  • macOS/Linux: Requires sudo for packet capture (standard for network sniffers)
  • Python: 3.9 or higher
  • Permissions: Must run with elevated privileges to access network interfaces

Quick Start

bash
# Get help
mcphawk --help

# Get help for specific command
mcphawk sniff --help
mcphawk web --help

# Start web UI with auto-detect mode (requires sudo on macOS)
sudo mcphawk web --auto-detect

# Monitor MCP traffic on a specific port (console output)
sudo mcphawk sniff --port 3000

# Monitor multiple ports with a custom filter
sudo mcphawk sniff --filter "tcp port 3000 or tcp port 8080"

# Auto-detect MCP traffic on any port
sudo mcphawk sniff --auto-detect

# Start web UI with sniffer on specific port
sudo mcphawk web --port 3000

# Start web UI with custom filter for multiple ports
sudo mcphawk web --filter "tcp port 3000 or tcp port 8080"

# View historical logs only (no active sniffing)
sudo mcphawk web --no-sniffer

# Custom web server configuration
sudo mcphawk web --port 3000 --host 0.0.0.0 --web-port 9000

# Enable debug output for troubleshooting
sudo mcphawk sniff --port 3000 --debug
sudo mcphawk web --port 3000 --debug

# Wrap an MCP server to capture stdio traffic
mcphawk wrap /path/to/mcp-server --arg1 --arg2

# Example: Wrap Context7 MCP server to monitor Claude Desktop's documentation lookups
mcphawk wrap npx -y @upstash/context7-mcp@latest

# Claude Desktop config to use the wrapped version:
# {
#   "mcpServers": {
#     "context7": {
#       "command": "mcphawk",
#       "args": ["wrap", "npx", "-y", "@upstash/context7-mcp@latest"]
#     }
#   }
# }

# Start MCP server with Streamable HTTP transport (default)
mcphawk mcp --transport http --mcp-port 8765

# Start MCP server with stdio transport (for Claude Desktop integration)
mcphawk mcp --transport stdio

# Start sniffer with integrated MCP server (HTTP transport)
sudo mcphawk sniff --port 3000 --with-mcp --mcp-transport http

# Start web UI with integrated MCP server
sudo mcphawk web --port 3000 --with-mcp --mcp-transport http --mcp-port 8765

MCP Server Integration

MCPHawk includes a built-in MCP server, allowing you to query captured traffic through the Model Context Protocol itself. This creates powerful possibilities:

  • AI-Powered Analysis: Connect Claude or other LLMs to analyze traffic patterns
  • Automated Monitoring: Build agents that detect anomalies or specific behaviors
  • Integration Testing: Programmatically verify MCP interactions in CI/CD pipelines

Available Tools

The MCP server exposes these tools for traffic analysis:

ToolDescriptionParameters
query_trafficFetch captured logs with paginationlimit, offset
get_logRetrieve specific log entrylog_id
search_trafficSearch logs by content or typesearch_term, message_type, traffic_type, limit
get_statsGet traffic statisticsNone
list_methodsList unique JSON-RPC methodsNone

Transport Options

HTTP Transport (Development & Testing)

The HTTP transport uses Server-Sent Events (SSE) for streaming responses:

bash
# Start MCP server
mcphawk mcp --transport http --mcp-port 8765

# Initialize session (note: returns SSE stream)
curl -N -X POST http://localhost:8765/mcp \
  -H 'Accept: text/event-stream' \
  -d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}},"id":1}'

# Example response (SSE format):
# event: message
# data: {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05",...}}

stdio Transport (Production & Claude Desktop)

For Claude Desktop integration:

json
{
  "mcpServers": {
    "mcphawk": {
      "command": "mcphawk",
      "args": ["mcp", "--transport", "stdio"]
    }
  }
}

The stdio transport follows the standard MCP communication pattern:

  1. Client sends initialize request
  2. Server responds with capabilities
  3. Client sends initialized notification
  4. Normal tool calls can proceed

See examples/mcp_sdk_client.py for HTTP client example or examples/stdio_client.py for stdio communication.

Platform Support

Tested Platforms

  • ✅ macOS (Apple Silicon & Intel) - Fully tested
  • ✅ Linux (Ubuntu, Debian) - Fully tested
  • ⚠️ Windows - Experimental (Scapy should work but untested)

Known Limitations

  • Requires elevated privileges (sudo) on macOS/Linux for packet capture
  • Limited to localhost/loopback interface monitoring
  • Cannot decrypt TLS/HTTPS traffic (WSS, HTTPS)
  • IPv6 support requires explicit interface configuration on some systems
  • High traffic volumes (>1000 msgs/sec) may impact performance

Troubleshooting

Permission Denied Error:

bash
# On macOS/Linux, use sudo:
sudo mcphawk web --auto-detect

No Traffic Captured:

  • Ensure the MCP server/client is using localhost (127.0.0.1 or ::1)
  • Check if traffic is on the expected port
  • Try auto-detect mode to find MCP traffic: --auto-detect
  • Verify traffic is unencrypted (not HTTPS/TLS)
  • On macOS, ensure Terminal has permission to capture packets in System Preferences

SSE/HTTP Responses Not Showing:

  • Confirm the server uses standard SSE format (event: message\ndata: {...}\n\n)
  • Check if responses use chunked transfer encoding
  • Enable debug mode to see detailed packet analysis: --debug

Potential Upcoming Features

Vote for features by opening a GitHub issue!

  • Auto-detect MCP traffic - Automatically discover MCP traffic on any port without prior configuration
  • MCP Server Interface - Expose captured traffic via MCP server for AI agents to query and analyze traffic patterns
  • Stdio capture - Transparent process wrapper to capture stdin/stdout communication
  • Protocol Version Detection - Identify and display MCP protocol version from captured traffic
  • Smart Search & Filtering - Search by method name, params, or any JSON field with regex support
  • Performance Analytics - Request/response timing, method frequency charts, and latency distribution
  • Export & Share - Export sessions as JSON/CSV, generate shareable links, create HAR-like files
  • Test Generation - Auto-generate test cases from captured traffic
  • Error Analysis - Highlight errors, group similar issues, show error trends
  • Session Management - Save/load capture sessions, compare sessions side-by-side
  • Interactive Replay - Click any request to re-send it, edit and replay captured messages
  • Real-time Alerts - Alert on specific methods or error patterns with webhook support
  • Visualization - Sequence diagrams, resource heat maps, method dependency graphs

... and a few more off the deep end:

  • TLS/HTTPS Support (MITM Proxy Mode) - Optional man-in-the-middle proxy with certificate installation for encrypted traffic
  • External Decryption Integration - Import decrypted streams from Wireshark, Chrome DevTools, or SSLKEYLOGFILE

For Developers

bash
# Set up Python environment
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install backend dependencies
pip3 install -r requirements-dev.txt
pip3 install -e .

# Install frontend dependencies and build
cd frontend
npm install
npm run build
cd ..

# Run tests
python3 -m pytest -v

Some Vue options:

bash
# Option 1: Use make (recommended)
make dev  # Runs both frontend and backend

# Option 2: Run separately
# Terminal 1 - Frontend with hot reload
cd frontend && npm run dev

# Terminal 2 - Backend
mcphawk web --port 3000

# Option 3: Watch mode
cd frontend && npm run build:watch  # Auto-rebuild on changes
mcphawk web --port 3000           # In another terminal

安装

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "tech4242-mcphawk": {
      "command": "uvx",
      "args": [
        "mcphawk"
      ]
    }
  }
}

将 MCPHawk MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 MCPHawk 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 MCPHawk 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 MCPHawk MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "tech4242-mcphawk": {
      "command": "npx",
      "args": [
        "-y",
        "mcphawk"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 MCPHawk MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 MCPHawk MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 MCPHawk 帮我完成这项任务吗?
MCPHawk
当然。我已阅读。
以下是我使用 MCPHawk 得到的结果。

常见问题

MCPHawk MCP 服务器有什么用途?

MCPHawk 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 MCPHawk MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 MCPHawk,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 MCPHawk MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 MCPHawk 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 MCPHawk MCP 连接到 TypingMind?

MCPHawk 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

MCPHawk MCP 在 TypingMind 中提供哪些工具?

MCPHawk 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 MCPHawk MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 MCPHawk 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇