mcpcap 0.4.7__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,371 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcpcap
3
+ Version: 0.5.0
4
+ Summary: A modular Python MCP Server for analyzing PCAP files
5
+ Author: mcpcap contributors
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 danohn
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://mcpcap.ai
29
+ Project-URL: Repository, https://github.com/mcpcap/mcpcap
30
+ Project-URL: Issues, https://github.com/mcpcap/mcpcap/issues
31
+ Keywords: pcap,network,analysis,mcp,dns
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Intended Audience :: System Administrators
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: System :: Networking :: Monitoring
41
+ Classifier: Topic :: Security
42
+ Requires-Python: >=3.10
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: fastmcp~=2.12.2
46
+ Requires-Dist: scapy~=2.6.1
47
+ Requires-Dist: requests~=2.32.5
48
+ Provides-Extra: test
49
+ Requires-Dist: pytest; extra == "test"
50
+ Requires-Dist: pytest-cov; extra == "test"
51
+ Requires-Dist: setuptools-scm[toml]; extra == "test"
52
+ Provides-Extra: dev
53
+ Requires-Dist: setuptools-scm[toml]; extra == "dev"
54
+ Requires-Dist: build; extra == "dev"
55
+ Requires-Dist: twine; extra == "dev"
56
+ Requires-Dist: ruff; extra == "dev"
57
+ Requires-Dist: mypy; extra == "dev"
58
+ Requires-Dist: pytest; extra == "dev"
59
+ Requires-Dist: pytest-cov; extra == "dev"
60
+ Provides-Extra: docs
61
+ Requires-Dist: sphinx>=7.0; extra == "docs"
62
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
63
+ Requires-Dist: myst-parser; extra == "docs"
64
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
65
+ Requires-Dist: sphinx-copybutton; extra == "docs"
66
+ Requires-Dist: linkify-it-py; extra == "docs"
67
+ Dynamic: license-file
68
+
69
+ # mcpcap
70
+
71
+ <!-- mcp-name: ai.mcpcap/mcpcap -->
72
+
73
+ ![mcpcap logo](https://raw.githubusercontent.com/mcpcap/mcpcap/main/readme-assets/mcpcap-logo.png)
74
+
75
+ A modular Python MCP (Model Context Protocol) Server for analyzing PCAP files. mcpcap enables LLMs to read and analyze network packet captures with protocol-specific analysis tools that accept local files or remote URLs as parameters.
76
+
77
+ ## Overview
78
+
79
+ mcpcap uses a modular architecture to analyze different network protocols found in PCAP files. Each module provides specialized analysis tools that can be called independently with any PCAP file, making it perfect for integration with Claude Desktop and other MCP clients.
80
+
81
+ ### Key Features
82
+
83
+ - **Stateless MCP Tools**: Each analysis accepts PCAP file paths or URLs as parameters
84
+ - **Modular Architecture**: DNS, DHCP, and ICMP modules with easy extensibility for new protocols
85
+ - **Local & Remote PCAP Support**: Analyze files from local storage or HTTP URLs
86
+ - **Scapy Integration**: Leverages scapy's comprehensive packet parsing capabilities
87
+ - **Specialized Analysis Prompts**: Security, networking, and forensic analysis guidance
88
+ - **JSON Responses**: Structured data format optimized for LLM consumption
89
+
90
+ ## Installation
91
+
92
+ mcpcap requires Python 3.10 or greater.
93
+
94
+ ### Using pip
95
+
96
+ ```bash
97
+ pip install mcpcap
98
+ ```
99
+
100
+ ### Using uv
101
+
102
+ ```bash
103
+ uv add mcpcap
104
+ ```
105
+
106
+ ### Using uvx (for one-time usage)
107
+
108
+ ```bash
109
+ uvx mcpcap
110
+ ```
111
+
112
+ ## Quick Start
113
+
114
+ ### 1. Start the MCP Server
115
+
116
+ Start mcpcap as a stateless MCP server:
117
+
118
+ ```bash
119
+ # Default: Start with DNS, DHCP, and ICMP modules
120
+ mcpcap
121
+
122
+ # Start with specific modules only
123
+ mcpcap --modules dns
124
+
125
+ # With packet analysis limits
126
+ mcpcap --max-packets 1000
127
+ ```
128
+
129
+ ### 2. Connect Your MCP Client
130
+
131
+ Configure your MCP client (like Claude Desktop) to connect to the mcpcap server:
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "mcpcap": {
137
+ "command": "mcpcap",
138
+ "args": []
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ ### 3. Analyze PCAP Files
145
+
146
+ Use the analysis tools with any PCAP file:
147
+
148
+ **DNS Analysis:**
149
+ ```
150
+ analyze_dns_packets("/path/to/dns.pcap")
151
+ analyze_dns_packets("https://example.com/remote.pcap")
152
+ ```
153
+
154
+ **DHCP Analysis:**
155
+ ```
156
+ analyze_dhcp_packets("/path/to/dhcp.pcap")
157
+ analyze_dhcp_packets("https://example.com/dhcp-capture.pcap")
158
+ ```
159
+
160
+ **ICMP Analysis:**
161
+ ```
162
+ analyze_icmp_packets("/path/to/icmp.pcap")
163
+ analyze_icmp_packets("https://example.com/ping-capture.pcap")
164
+ ```
165
+
166
+ ## Available Tools
167
+
168
+ ### DNS Analysis Tools
169
+
170
+ - **`analyze_dns_packets(pcap_file)`**: Complete DNS traffic analysis
171
+ - Extract DNS queries and responses
172
+ - Identify queried domains and subdomains
173
+ - Analyze query types (A, AAAA, MX, CNAME, etc.)
174
+ - Track query frequency and patterns
175
+ - Detect potential security issues
176
+
177
+ ### DHCP Analysis Tools
178
+
179
+ - **`analyze_dhcp_packets(pcap_file)`**: Complete DHCP traffic analysis
180
+ - Track DHCP transactions (DISCOVER, OFFER, REQUEST, ACK)
181
+ - Identify DHCP clients and servers
182
+ - Monitor IP address assignments and lease information
183
+ - Analyze DHCP options and configurations
184
+ - Detect DHCP anomalies and security issues
185
+
186
+ ### ICMP Analysis Tools
187
+
188
+ - **`analyze_icmp_packets(pcap_file)`**: Complete ICMP traffic analysis
189
+ - Analyze ping requests and replies with response times
190
+ - Identify network connectivity and reachability issues
191
+ - Track TTL values and routing paths (traceroute data)
192
+ - Detect ICMP error messages (unreachable, time exceeded)
193
+ - Monitor for potential ICMP-based attacks or reconnaissance
194
+
195
+ ## Analysis Prompts
196
+
197
+ mcpcap provides specialized analysis prompts to guide LLM analysis:
198
+
199
+ ### DNS Prompts
200
+ - **`security_analysis`** - Focus on threat detection, DGA domains, DNS tunneling
201
+ - **`network_troubleshooting`** - Identify DNS performance and configuration issues
202
+ - **`forensic_investigation`** - Timeline reconstruction and evidence collection
203
+
204
+ ### DHCP Prompts
205
+ - **`dhcp_network_analysis`** - Network administration and IP management
206
+ - **`dhcp_security_analysis`** - Security threats and rogue DHCP detection
207
+ - **`dhcp_forensic_investigation`** - Forensic analysis of DHCP transactions
208
+
209
+ ### ICMP Prompts
210
+ - **`icmp_network_diagnostics`** - Network connectivity and path analysis
211
+ - **`icmp_security_analysis`** - ICMP-based attacks and reconnaissance detection
212
+ - **`icmp_forensic_investigation`** - Timeline reconstruction and network mapping
213
+
214
+ ## Configuration Options
215
+
216
+ ### Module Selection
217
+
218
+ ```bash
219
+ # Load specific modules
220
+ mcpcap --modules dns # DNS analysis only
221
+ mcpcap --modules dhcp # DHCP analysis only
222
+ mcpcap --modules icmp # ICMP analysis only
223
+ mcpcap --modules dns,dhcp,icmp # All modules (default)
224
+ ```
225
+
226
+ ### Analysis Limits
227
+
228
+ ```bash
229
+ # Limit packet analysis for large files
230
+ mcpcap --max-packets 1000
231
+ ```
232
+
233
+ ### Complete Configuration Example
234
+
235
+ ```bash
236
+ mcpcap --modules dns,dhcp,icmp --max-packets 500
237
+ ```
238
+
239
+ ## CLI Reference
240
+
241
+ ```bash
242
+ mcpcap [--modules MODULES] [--max-packets N]
243
+ ```
244
+
245
+ **Options:**
246
+ - `--modules MODULES`: Comma-separated modules to load (default: `dns,dhcp,icmp`)
247
+ - Available modules: `dns`, `dhcp`, `icmp`
248
+ - `--max-packets N`: Maximum packets to analyze per file (default: unlimited)
249
+
250
+ **Examples:**
251
+ ```bash
252
+ # Start with all modules
253
+ mcpcap
254
+
255
+ # DNS analysis only
256
+ mcpcap --modules dns
257
+
258
+ # With packet limits for large files
259
+ mcpcap --max-packets 1000
260
+ ```
261
+
262
+ ## Examples
263
+
264
+ Example PCAP files are included in the `examples/` directory:
265
+
266
+ - `dns.pcap` - DNS traffic for testing DNS analysis
267
+ - `dhcp.pcap` - DHCP 4-way handshake capture
268
+ - `icmp.pcap` - ICMP ping and traceroute traffic
269
+
270
+ ### Using with MCP Inspector
271
+
272
+ ```bash
273
+ npm install -g @modelcontextprotocol/inspector
274
+ npx @modelcontextprotocol/inspector mcpcap
275
+ ```
276
+
277
+ Then test the tools:
278
+ ```javascript
279
+ // In the MCP Inspector web interface
280
+ analyze_dns_packets("./examples/dns.pcap")
281
+ analyze_dhcp_packets("./examples/dhcp.pcap")
282
+ analyze_icmp_packets("./examples/icmp.pcap")
283
+ ```
284
+
285
+ ## Architecture
286
+
287
+ mcpcap's modular design supports easy extension:
288
+
289
+ ### Core Components
290
+ 1. **BaseModule**: Shared file handling, validation, and remote download
291
+ 2. **Protocol Modules**: DNS, DHCP, and ICMP analysis implementations
292
+ 3. **MCP Interface**: Tool registration and prompt management
293
+ 4. **FastMCP Framework**: MCP server implementation
294
+
295
+ ### Tool Flow
296
+ ```
297
+ MCP Client Request → analyze_*_packets(pcap_file)
298
+ → BaseModule.analyze_packets()
299
+ → Module._analyze_protocol_file()
300
+ → Structured JSON Response
301
+ ```
302
+
303
+ ### Adding New Modules
304
+
305
+ Create new protocol modules by:
306
+
307
+ 1. Inheriting from `BaseModule`
308
+ 2. Implementing `_analyze_protocol_file(pcap_file)`
309
+ 3. Registering analysis tools with the MCP server
310
+ 4. Adding specialized analysis prompts
311
+
312
+ Future modules might include:
313
+ - HTTP/HTTPS traffic analysis
314
+ - TCP connection tracking
315
+ - BGP routing analysis
316
+ - SSL/TLS certificate analysis
317
+ - Network forensics tools
318
+
319
+ ## Remote File Support
320
+
321
+ Both analysis tools accept remote PCAP files via HTTP/HTTPS URLs:
322
+
323
+ ```bash
324
+ # Examples of remote analysis
325
+ analyze_dns_packets("https://wiki.wireshark.org/uploads/dns.cap")
326
+ analyze_dhcp_packets("https://example.com/network-capture.pcap")
327
+ analyze_icmp_packets("https://example.com/ping-test.pcap")
328
+ ```
329
+
330
+ **Features:**
331
+ - Automatic temporary download and cleanup
332
+ - Support for `.pcap`, `.pcapng`, and `.cap` files
333
+ - HTTP/HTTPS protocols supported
334
+
335
+ ## Security Considerations
336
+
337
+ When analyzing PCAP files:
338
+ - Files may contain sensitive network information
339
+ - Remote downloads are performed over HTTPS when possible
340
+ - Temporary files are cleaned up automatically
341
+ - Consider the source and trustworthiness of remote files
342
+
343
+ ## Contributing
344
+
345
+ Contributions welcome! Areas for contribution:
346
+
347
+ - **New Protocol Modules**: Add support for HTTP, BGP, TCP, etc.
348
+ - **Enhanced Analysis**: Improve existing DNS/DHCP analysis
349
+ - **Security Features**: Add more threat detection capabilities
350
+ - **Performance**: Optimize analysis for large PCAP files
351
+
352
+ ## License
353
+
354
+ MIT
355
+
356
+ ## Requirements
357
+
358
+ - Python 3.10+
359
+ - scapy (packet parsing and analysis)
360
+ - requests (remote file access)
361
+ - fastmcp (MCP server framework)
362
+
363
+ ## Documentation
364
+
365
+ - **GitHub**: [github.com/mcpcap/mcpcap](https://github.com/mcpcap/mcpcap)
366
+ - **Documentation**: [docs.mcpcap.ai](https://docs.mcpcap.ai)
367
+ - **Website**: [mcpcap.ai](https://mcpcap.ai)
368
+
369
+ ## Support
370
+
371
+ For questions, issues, or feature requests, please open an issue on GitHub.
@@ -0,0 +1,17 @@
1
+ mcpcap/__init__.py,sha256=rJwCpBXkhIvmsqHFpeR33Vg8kuipNPJ2JdlAjsTk7I4,1408
2
+ mcpcap/_version.py,sha256=fvHpBU3KZKRinkriKdtAt3crenOyysELF-M9y3ozg3U,704
3
+ mcpcap/cli.py,sha256=KR2XieXSB3YvbkZ5uZSD_Hw-TsD2iLG4-uarLtaOey0,1969
4
+ mcpcap/core/__init__.py,sha256=WM5GTl06ZwwqHTPiKaYB-9hwOOXe3hyHG16FshwSsjE,127
5
+ mcpcap/core/config.py,sha256=027vbqk5bTD583Nk3k4EY3mAG3tey0QgbcMTubQlx9E,933
6
+ mcpcap/core/server.py,sha256=CkNje4-WhUUf2eByEIHxc7lkgTP0nBMq1o0pejPXB1Y,1875
7
+ mcpcap/modules/__init__.py,sha256=kA91h_-f7RE7pvEgcsQTZigDptK5v17-mbqTXZTRTK8,183
8
+ mcpcap/modules/base.py,sha256=ORiSmW3wSV7dmZy6eBV1prEcJbgOxNsgcxFMVIbg5zU,4157
9
+ mcpcap/modules/dhcp.py,sha256=uMK-xplbk13d3cX8cUuZiGUcSEY47wCZHO6hs7JMQuM,12748
10
+ mcpcap/modules/dns.py,sha256=CeLSDaarQxG33Vu9k3sVOzsxXY9IRKl8QRrPiK97k7Y,12135
11
+ mcpcap/modules/icmp.py,sha256=kI87eT78BNrRxGustHsV79FaWpF1C5tq1Bz01kvGFvc,12598
12
+ mcpcap-0.5.0.dist-info/licenses/LICENSE,sha256=Ltj0zxftQyBYQMNva935v0i5QXQQOF8ygE8dQxGEtjk,1063
13
+ mcpcap-0.5.0.dist-info/METADATA,sha256=C-iJDYrYQezSVv0S1EaihTd3kHsmdT3a5VJitQCAq9c,11303
14
+ mcpcap-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ mcpcap-0.5.0.dist-info/entry_points.txt,sha256=ck69gPBEopmU6mzQy9P6o6ssMr89bQbrvv51IaJ50Gc,39
16
+ mcpcap-0.5.0.dist-info/top_level.txt,sha256=YkRkVGjuM3nI7cVB1l8zIAeqiS_5_vrzbUcHNkH3OXE,7
17
+ mcpcap-0.5.0.dist-info/RECORD,,