
SharkMCP
STDIONetwork packet capture and analysis server with Wireshark integration for AI assistants.
Network packet capture and analysis server with Wireshark integration for AI assistants.
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:
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 │
└─────────────────────────────────────────────────────────┘
/!\ Packet information can be very extensive. Make sure to use a scoped display filter not to overload the context of your conversation.
macOS (using Homebrew):
brew install wireshark
Ubuntu/Debian:
sudo apt update sudo apt install tshark wireshark-common
Windows: Download from wireshark.org
git clone https://github.com/kriztalz/SharkMCP.git cd SharkMCP
pnpm install
pnpm run build
pnpm start
SharkMCP includes comprehensive integration tests that verify packet capture functionality.
# Run all tests pnpm test
{ "mcpServers": { "sharkmcp": { "command": "node", "args": ["/path/to/SharkMCP/dist/index.js"], } } }
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.
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" }
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 mode with auto-reload pnpm run dev # Build for production pnpm run build # Run tests pnpm run test # Type checking pnpm run build
/tmp/
"tshark not found":
tshark -v
Permission denied for packet capture:
wireshark
group or run with sudo
No packets captured:
ip link
on Linux, ifconfig
on macOS)MIT License
Feel free to open an issue with any question or suggestion you may have.