SharkMCP
A Model Context Protocol server that provides network packet capture and analysis capabilities through Wireshark/tshark integration, enabling AI assistants to perform network security analysis and troubleshooting.
Tools
start_capture_session
Start a background packet capture session. LLMs control all capture parameters including filters, interfaces, and packet limits. Can use saved configurations.
stop_capture_session
Stop a running capture session and analyze packets. LLMs control all analysis parameters including display filters and output formats. Can use saved configurations.
analyze_pcap_file
Analyze a local pcap/pcapng file. LLMs control all analysis parameters including filters, output formats, and custom fields. Can use saved configurations.
manage_config
Save, load, list, or delete reusable filter configurations. Allows LLMs to store commonly used capture and analysis parameters for easy reuse.
README
SharkMCP - Network Packet Analysis MCP Server
A Model Context Protocol (MCP) server that provides network packet capture and analysis capabilities through Wireshark/tshark integration. Designed for AI assistants to perform network security analysis, troubleshooting, and packet inspection.
This server was thought for situations where you want your agent to debug a program that sends requests and verify the packet traffic, allowing the following workflow:
- Start recording packets
- Run tool or perform request
- Stop recording and analyze results
Architecture
SharkMCP provides a simple, local development-focused architecture:
┌─────────────────────────────────────────────────────────┐
│ SharkMCP Server │
├─────────────────────────────────────────────────────────┤
│ MCP Protocol Layer │
│ ├─ start_capture_session │
│ ├─ stop_capture_session │
│ ├─ analyze_pcap_file │
│ └─ manage_config │
├─────────────────────────────────────────────────────────┤
│ tshark Integration Layer │
│ ├─ Cross-platform executable detection │
│ ├─ Process management │
│ └─ Output parsing (JSON/fields/text) │
├─────────────────────────────────────────────────────────┤
│ Host System Integration │
│ ├─ Local tshark installation │
│ ├─ Direct network interface access │
│ └─ Native file system operations │
└─────────────────────────────────────────────────────────┘
Features
- Async Packet Capture: Start background capture sessions with configurable filters and timeouts.
- PCAP File Analysis: Analyze existing packet capture files
- Flexible Output Formats: JSON, custom fields, or traditional text output
- SSL/TLS Decryption: Support for SSL keylog files to decrypt HTTPS traffic
- Reusable Configurations: Save and reuse capture/analysis configurations
/!\ Packet information can be very extensive. Make sure to use a scoped display filter not to overload the context of your conversation.
Prerequisites
System Requirements
- Wireshark/tshark: Must be installed and accessible
- Node.js: Version 18+
- pnpm: Package manager (recommended)
Installing Wireshark/tshark
macOS (using Homebrew):
brew install wireshark
Ubuntu/Debian:
sudo apt update
sudo apt install tshark wireshark-common
Windows: Download from wireshark.org
Installation
- Clone the repository:
git clone https://github.com/kriztalz/SharkMCP.git
cd SharkMCP
- Install dependencies:
pnpm install
- Build the project:
pnpm run build
- Run the server:
pnpm start
Testing
SharkMCP includes comprehensive integration tests that verify packet capture functionality.
Running Tests
# Run all tests
pnpm test
Configuration
MCP Client Setup
{
"mcpServers": {
"sharkmcp": {
"command": "node",
"args": ["/path/to/SharkMCP/dist/index.js"],
}
}
}
SSL/TLS Decryption (Optional)
To decrypt HTTPS traffic, export the SSLKEYLOGFILE environment variable:
export SSLKEYLOGFILE=/path/to/sslkeylog.log
Then configure your applications to log SSL keys to this file. Many applications support this automatically when the environment variable is set.
Then pass the log file pathname to the MCP server in the stop_capture_session tool.
Usage
Available Tools
- start_capture_session: Start background packet capture
- stop_capture_session: Stop capture and analyze results
- analyze_pcap_file: Analyze existing PCAP files
- manage_config: Save/load reusable configurations
Basic Examples
Start a capture session:
Interface: en0
Capture Filter: port 443
Timeout: 30 seconds
Analyze captured traffic:
Display Filter: tls.handshake.type == 1
Output Format: json
Save a configuration:
{
"name": "https-monitoring",
"description": "Monitor HTTPS traffic",
"captureFilter": "port 443",
"displayFilter": "tls.handshake.type == 1",
"outputFormat": "json",
"timeout": 60,
"interface": "en0"
}
Development
Project Structure
SharkMCP/
├── src/
│ ├── index.ts # Main server setup
│ ├── types.ts # TypeScript interfaces
│ ├── utils.ts # Utility functions
│ └── tools/ # Individual tool implementations
│ ├── start-capture-session.ts
│ ├── stop-capture-session.ts
│ ├── analyze-pcap-file.ts
│ └── manage-config.ts
├── test/ # Test files
│ └── integration.test.js # Integration tests
├── package.json
└── README.md
Development Commands
# Development mode with auto-reload
pnpm run dev
# Build for production
pnpm run build
# Run tests
pnpm run test
# Type checking
pnpm run build
Security Considerations
- Network Permissions: Packet capture requires elevated privileges
- File Access: Temporary files are created in
/tmp/ - Docker Security: Container runs as non-root user
- SSL Keylog: Sensitive SSL keys should be handled securely
Troubleshooting
Common Issues
"tshark not found":
- Ensure Wireshark is installed and tshark is in PATH
- Check installation with:
tshark -v
Permission denied for packet capture:
- On Linux: Add user to
wiresharkgroup or run withsudo - On macOS: Grant Terminal network access in System Preferences
- On Windows: Run as Administrator
No packets captured:
- Verify network interface name (
ip linkon Linux,ifconfigon macOS) - Check capture filter syntax
- Ensure traffic is present on the interface
Contributing (Very welcome!)
- Fork the repository
- Create a feature branch
- Make your changes following the existing code style
- Add tests for new functionality
- Submit a pull request
License
MIT License
Issues / Suggestions
Feel free to open an issue with any question or suggestion you may have.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。