mcpcap 0.2.3__tar.gz → 0.3.0__tar.gz
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.
- {mcpcap-0.2.3 → mcpcap-0.3.0}/.gitignore +2 -1
- {mcpcap-0.2.3/src/mcpcap.egg-info → mcpcap-0.3.0}/PKG-INFO +99 -8
- {mcpcap-0.2.3 → mcpcap-0.3.0}/README.md +97 -7
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/user-guide/installation.md +1 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/user-guide/mcp-integration.md +16 -6
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/user-guide/quickstart.md +29 -5
- mcpcap-0.3.0/examples/README.md +64 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/pyproject.toml +2 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/_version.py +3 -3
- mcpcap-0.3.0/src/mcpcap/cli.py +85 -0
- mcpcap-0.3.0/src/mcpcap/core/config.py +230 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/core/server.py +10 -2
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/modules/dns.py +108 -20
- {mcpcap-0.2.3 → mcpcap-0.3.0/src/mcpcap.egg-info}/PKG-INFO +99 -8
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap.egg-info/requires.txt +1 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/tests/test_cli.py +13 -7
- {mcpcap-0.2.3 → mcpcap-0.3.0}/tests/test_dns.py +10 -6
- mcpcap-0.2.3/examples/README.md +0 -49
- mcpcap-0.2.3/src/mcpcap/cli.py +0 -54
- mcpcap-0.2.3/src/mcpcap/core/config.py +0 -52
- {mcpcap-0.2.3 → mcpcap-0.3.0}/.DS_Store +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/.github/FUNDING.yml +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/.github/workflows/release.yml +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/.github/workflows/test.yml +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/.readthedocs.yaml +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/LICENSE +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/Makefile +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/_static/.gitkeep +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/api/cli.rst +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/api/core.rst +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/api/modules.rst +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/conf.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/index.rst +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/docs/source/user-guide/analysis-guides.md +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/examples/dns.pcap +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/readme-assets/mcpcap-logo.png +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/requirements.txt +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/setup.cfg +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/__init__.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/core/__init__.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/modules/__init__.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/modules/base.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/resources/__init__.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap/resources/references.py +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap.egg-info/SOURCES.txt +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap.egg-info/dependency_links.txt +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap.egg-info/entry_points.txt +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/src/mcpcap.egg-info/top_level.txt +0 -0
- {mcpcap-0.2.3 → mcpcap-0.3.0}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcpcap
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: A modular Python MCP Server for analyzing PCAP files
|
5
5
|
Author: mcpcap contributors
|
6
6
|
License: MIT
|
@@ -23,6 +23,7 @@ Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
24
24
|
Requires-Dist: fastmcp
|
25
25
|
Requires-Dist: scapy
|
26
|
+
Requires-Dist: requests
|
26
27
|
Provides-Extra: test
|
27
28
|
Requires-Dist: pytest; extra == "test"
|
28
29
|
Requires-Dist: pytest-cov; extra == "test"
|
@@ -85,10 +86,26 @@ uvx mcpcap
|
|
85
86
|
|
86
87
|
1. **Start the MCP Server**:
|
87
88
|
|
89
|
+
**Local PCAP file:**
|
90
|
+
```bash
|
91
|
+
mcpcap --pcap-path /path/to/specific/file.pcap
|
92
|
+
```
|
93
|
+
|
94
|
+
**Local PCAP directory:**
|
88
95
|
```bash
|
89
96
|
mcpcap --pcap-path /path/to/pcap/files
|
90
97
|
```
|
91
98
|
|
99
|
+
**Remote PCAP file:**
|
100
|
+
```bash
|
101
|
+
mcpcap --pcap-url https://example.com/sample.pcap
|
102
|
+
```
|
103
|
+
|
104
|
+
**With advanced options:**
|
105
|
+
```bash
|
106
|
+
mcpcap --pcap-path /path/to/pcaps --max-packets 100 --protocols dns
|
107
|
+
```
|
108
|
+
|
92
109
|
2. **Connect your LLM client** to the MCP server
|
93
110
|
|
94
111
|
3. **Ask questions** about your network traffic:
|
@@ -121,27 +138,80 @@ The DNS module analyzes Domain Name System packets in PCAP files.
|
|
121
138
|
|
122
139
|
### PCAP Sources
|
123
140
|
|
124
|
-
|
141
|
+
mcpcap supports multiple ways to specify PCAP data sources:
|
125
142
|
|
143
|
+
**Local PCAP File**:
|
144
|
+
```bash
|
145
|
+
mcpcap --pcap-path /local/path/to/specific.pcap
|
146
|
+
```
|
147
|
+
|
148
|
+
**Local Directory**:
|
126
149
|
```bash
|
127
150
|
mcpcap --pcap-path /local/path/to/pcaps
|
128
151
|
```
|
129
152
|
|
130
|
-
**Remote
|
153
|
+
**Remote PCAP File (Direct Link)**:
|
154
|
+
```bash
|
155
|
+
mcpcap --pcap-url https://wiki.wireshark.org/uploads/dns.cap
|
156
|
+
```
|
131
157
|
|
158
|
+
**Remote Directory Listing**:
|
132
159
|
```bash
|
133
160
|
mcpcap --pcap-url http://example.com/pcaps/
|
134
161
|
```
|
135
162
|
|
136
|
-
###
|
163
|
+
### Analysis Options
|
137
164
|
|
165
|
+
**Module Selection**:
|
138
166
|
```bash
|
139
167
|
mcpcap --modules dns --pcap-path /path/to/files
|
140
168
|
```
|
141
169
|
|
170
|
+
**Protocol Filtering**:
|
171
|
+
```bash
|
172
|
+
mcpcap --protocols dns --pcap-path /path/to/files
|
173
|
+
```
|
174
|
+
|
175
|
+
**Packet Limiting** (for large files):
|
176
|
+
```bash
|
177
|
+
mcpcap --max-packets 1000 --pcap-path /path/to/files
|
178
|
+
```
|
179
|
+
|
180
|
+
**Combined Options**:
|
181
|
+
```bash
|
182
|
+
mcpcap --pcap-path /data/capture.pcap --max-packets 500 --protocols dns
|
183
|
+
```
|
184
|
+
|
185
|
+
## CLI Reference
|
186
|
+
|
187
|
+
```bash
|
188
|
+
mcpcap [--pcap-path PATH | --pcap-url URL] [OPTIONS]
|
189
|
+
```
|
190
|
+
|
191
|
+
**Source Options** (choose one):
|
192
|
+
- `--pcap-path PATH`: Local PCAP file or directory
|
193
|
+
- `--pcap-url URL`: Remote PCAP file URL or directory listing
|
194
|
+
|
195
|
+
**Analysis Options**:
|
196
|
+
- `--modules MODULES`: Comma-separated modules to load (default: dns)
|
197
|
+
- `--protocols PROTOCOLS`: Comma-separated protocols to analyze (default: dns)
|
198
|
+
- `--max-packets N`: Maximum packets to analyze per file (default: unlimited)
|
199
|
+
|
200
|
+
**Examples**:
|
201
|
+
```bash
|
202
|
+
# Analyze specific file
|
203
|
+
mcpcap --pcap-path ./capture.pcap
|
204
|
+
|
205
|
+
# Remote file with packet limit
|
206
|
+
mcpcap --pcap-url https://example.com/dns.cap --max-packets 100
|
207
|
+
|
208
|
+
# Directory with protocol filter
|
209
|
+
mcpcap --pcap-path /captures --protocols dns --modules dns
|
210
|
+
```
|
211
|
+
|
142
212
|
## Example
|
143
213
|
|
144
|
-
An example PCAP file (`
|
214
|
+
An example PCAP file (`dns.pcap`) containing DNS traffic is included in the `examples/` directory to help you get started.
|
145
215
|
|
146
216
|
## Architecture
|
147
217
|
|
@@ -170,7 +240,26 @@ Future modules might include:
|
|
170
240
|
|
171
241
|
## Remote Access
|
172
242
|
|
173
|
-
mcpcap supports reading PCAP files from remote HTTP servers
|
243
|
+
mcpcap supports reading PCAP files from remote HTTP servers in two modes:
|
244
|
+
|
245
|
+
**Direct File Access**: Point directly to a PCAP file URL
|
246
|
+
```bash
|
247
|
+
mcpcap --pcap-url https://wiki.wireshark.org/uploads/__moin_import__/attachments/SampleCaptures/dns.cap
|
248
|
+
```
|
249
|
+
|
250
|
+
**Directory Listing**: Parse HTML directory listings to find PCAP files
|
251
|
+
```bash
|
252
|
+
mcpcap --pcap-url http://server.com/pcap-files/
|
253
|
+
```
|
254
|
+
|
255
|
+
**Supported File Types**: `.pcap`, `.pcapng`, `.cap`
|
256
|
+
|
257
|
+
**Current Limitations**:
|
258
|
+
- HTTP/HTTPS only (no authentication)
|
259
|
+
- Directory listings require standard HTML format
|
260
|
+
- Files are downloaded temporarily for analysis
|
261
|
+
|
262
|
+
Future versions may include support for Basic Authentication and other security mechanisms.
|
174
263
|
|
175
264
|
## Contributing
|
176
265
|
|
@@ -190,8 +279,10 @@ MIT
|
|
190
279
|
## Requirements
|
191
280
|
|
192
281
|
- Python 3.10+
|
193
|
-
- scapy
|
194
|
-
-
|
282
|
+
- scapy (packet parsing and analysis)
|
283
|
+
- requests (HTTP remote file access)
|
284
|
+
- fastmcp (MCP server framework)
|
285
|
+
- All dependencies are automatically installed via pip
|
195
286
|
|
196
287
|
## Support
|
197
288
|
|
@@ -42,10 +42,26 @@ uvx mcpcap
|
|
42
42
|
|
43
43
|
1. **Start the MCP Server**:
|
44
44
|
|
45
|
+
**Local PCAP file:**
|
46
|
+
```bash
|
47
|
+
mcpcap --pcap-path /path/to/specific/file.pcap
|
48
|
+
```
|
49
|
+
|
50
|
+
**Local PCAP directory:**
|
45
51
|
```bash
|
46
52
|
mcpcap --pcap-path /path/to/pcap/files
|
47
53
|
```
|
48
54
|
|
55
|
+
**Remote PCAP file:**
|
56
|
+
```bash
|
57
|
+
mcpcap --pcap-url https://example.com/sample.pcap
|
58
|
+
```
|
59
|
+
|
60
|
+
**With advanced options:**
|
61
|
+
```bash
|
62
|
+
mcpcap --pcap-path /path/to/pcaps --max-packets 100 --protocols dns
|
63
|
+
```
|
64
|
+
|
49
65
|
2. **Connect your LLM client** to the MCP server
|
50
66
|
|
51
67
|
3. **Ask questions** about your network traffic:
|
@@ -78,27 +94,80 @@ The DNS module analyzes Domain Name System packets in PCAP files.
|
|
78
94
|
|
79
95
|
### PCAP Sources
|
80
96
|
|
81
|
-
|
97
|
+
mcpcap supports multiple ways to specify PCAP data sources:
|
82
98
|
|
99
|
+
**Local PCAP File**:
|
100
|
+
```bash
|
101
|
+
mcpcap --pcap-path /local/path/to/specific.pcap
|
102
|
+
```
|
103
|
+
|
104
|
+
**Local Directory**:
|
83
105
|
```bash
|
84
106
|
mcpcap --pcap-path /local/path/to/pcaps
|
85
107
|
```
|
86
108
|
|
87
|
-
**Remote
|
109
|
+
**Remote PCAP File (Direct Link)**:
|
110
|
+
```bash
|
111
|
+
mcpcap --pcap-url https://wiki.wireshark.org/uploads/dns.cap
|
112
|
+
```
|
88
113
|
|
114
|
+
**Remote Directory Listing**:
|
89
115
|
```bash
|
90
116
|
mcpcap --pcap-url http://example.com/pcaps/
|
91
117
|
```
|
92
118
|
|
93
|
-
###
|
119
|
+
### Analysis Options
|
94
120
|
|
121
|
+
**Module Selection**:
|
95
122
|
```bash
|
96
123
|
mcpcap --modules dns --pcap-path /path/to/files
|
97
124
|
```
|
98
125
|
|
126
|
+
**Protocol Filtering**:
|
127
|
+
```bash
|
128
|
+
mcpcap --protocols dns --pcap-path /path/to/files
|
129
|
+
```
|
130
|
+
|
131
|
+
**Packet Limiting** (for large files):
|
132
|
+
```bash
|
133
|
+
mcpcap --max-packets 1000 --pcap-path /path/to/files
|
134
|
+
```
|
135
|
+
|
136
|
+
**Combined Options**:
|
137
|
+
```bash
|
138
|
+
mcpcap --pcap-path /data/capture.pcap --max-packets 500 --protocols dns
|
139
|
+
```
|
140
|
+
|
141
|
+
## CLI Reference
|
142
|
+
|
143
|
+
```bash
|
144
|
+
mcpcap [--pcap-path PATH | --pcap-url URL] [OPTIONS]
|
145
|
+
```
|
146
|
+
|
147
|
+
**Source Options** (choose one):
|
148
|
+
- `--pcap-path PATH`: Local PCAP file or directory
|
149
|
+
- `--pcap-url URL`: Remote PCAP file URL or directory listing
|
150
|
+
|
151
|
+
**Analysis Options**:
|
152
|
+
- `--modules MODULES`: Comma-separated modules to load (default: dns)
|
153
|
+
- `--protocols PROTOCOLS`: Comma-separated protocols to analyze (default: dns)
|
154
|
+
- `--max-packets N`: Maximum packets to analyze per file (default: unlimited)
|
155
|
+
|
156
|
+
**Examples**:
|
157
|
+
```bash
|
158
|
+
# Analyze specific file
|
159
|
+
mcpcap --pcap-path ./capture.pcap
|
160
|
+
|
161
|
+
# Remote file with packet limit
|
162
|
+
mcpcap --pcap-url https://example.com/dns.cap --max-packets 100
|
163
|
+
|
164
|
+
# Directory with protocol filter
|
165
|
+
mcpcap --pcap-path /captures --protocols dns --modules dns
|
166
|
+
```
|
167
|
+
|
99
168
|
## Example
|
100
169
|
|
101
|
-
An example PCAP file (`
|
170
|
+
An example PCAP file (`dns.pcap`) containing DNS traffic is included in the `examples/` directory to help you get started.
|
102
171
|
|
103
172
|
## Architecture
|
104
173
|
|
@@ -127,7 +196,26 @@ Future modules might include:
|
|
127
196
|
|
128
197
|
## Remote Access
|
129
198
|
|
130
|
-
mcpcap supports reading PCAP files from remote HTTP servers
|
199
|
+
mcpcap supports reading PCAP files from remote HTTP servers in two modes:
|
200
|
+
|
201
|
+
**Direct File Access**: Point directly to a PCAP file URL
|
202
|
+
```bash
|
203
|
+
mcpcap --pcap-url https://wiki.wireshark.org/uploads/__moin_import__/attachments/SampleCaptures/dns.cap
|
204
|
+
```
|
205
|
+
|
206
|
+
**Directory Listing**: Parse HTML directory listings to find PCAP files
|
207
|
+
```bash
|
208
|
+
mcpcap --pcap-url http://server.com/pcap-files/
|
209
|
+
```
|
210
|
+
|
211
|
+
**Supported File Types**: `.pcap`, `.pcapng`, `.cap`
|
212
|
+
|
213
|
+
**Current Limitations**:
|
214
|
+
- HTTP/HTTPS only (no authentication)
|
215
|
+
- Directory listings require standard HTML format
|
216
|
+
- Files are downloaded temporarily for analysis
|
217
|
+
|
218
|
+
Future versions may include support for Basic Authentication and other security mechanisms.
|
131
219
|
|
132
220
|
## Contributing
|
133
221
|
|
@@ -147,8 +235,10 @@ MIT
|
|
147
235
|
## Requirements
|
148
236
|
|
149
237
|
- Python 3.10+
|
150
|
-
- scapy
|
151
|
-
-
|
238
|
+
- scapy (packet parsing and analysis)
|
239
|
+
- requests (HTTP remote file access)
|
240
|
+
- fastmcp (MCP server framework)
|
241
|
+
- All dependencies are automatically installed via pip
|
152
242
|
|
153
243
|
## Support
|
154
244
|
|
@@ -57,6 +57,7 @@ mcpcap depends on:
|
|
57
57
|
|
58
58
|
- **fastmcp**: MCP server framework
|
59
59
|
- **scapy**: Packet parsing and analysis
|
60
|
+
- **requests**: HTTP client for remote PCAP access
|
60
61
|
- **Python 3.10+**: Modern Python features and type hints
|
61
62
|
|
62
63
|
All dependencies are automatically installed when you install mcpcap.
|
@@ -144,11 +144,17 @@ Analyzes DNS packets in a PCAP file.
|
|
144
144
|
### Server Configuration
|
145
145
|
|
146
146
|
```bash
|
147
|
-
#
|
147
|
+
# Local directory
|
148
148
|
mcpcap --pcap-path /path/to/pcaps
|
149
149
|
|
150
|
-
#
|
151
|
-
mcpcap --pcap-path /path/to/
|
150
|
+
# Local file
|
151
|
+
mcpcap --pcap-path /path/to/specific.pcap
|
152
|
+
|
153
|
+
# Remote file
|
154
|
+
mcpcap --pcap-url https://example.com/capture.pcap
|
155
|
+
|
156
|
+
# With analysis options
|
157
|
+
mcpcap --pcap-path /path/to/pcaps --max-packets 1000 --protocols dns --modules dns
|
152
158
|
```
|
153
159
|
|
154
160
|
### Client Configuration Examples
|
@@ -158,16 +164,20 @@ mcpcap --pcap-path /path/to/pcaps --max-packets 1000 --protocols dns,http
|
|
158
164
|
```json
|
159
165
|
{
|
160
166
|
"mcpServers": {
|
167
|
+
"mcpcap-local-file": {
|
168
|
+
"command": "mcpcap",
|
169
|
+
"args": ["--pcap-path", "/path/to/specific.pcap", "--max-packets", "500"]
|
170
|
+
},
|
161
171
|
"mcpcap-production": {
|
162
172
|
"command": "mcpcap",
|
163
|
-
"args": ["--pcap-path", "/production/captures"],
|
173
|
+
"args": ["--pcap-path", "/production/captures", "--protocols", "dns"],
|
164
174
|
"env": {
|
165
175
|
"LOG_LEVEL": "INFO"
|
166
176
|
}
|
167
177
|
},
|
168
|
-
"mcpcap-
|
178
|
+
"mcpcap-remote": {
|
169
179
|
"command": "mcpcap",
|
170
|
-
"args": ["--pcap-
|
180
|
+
"args": ["--pcap-url", "https://example.com/samples/dns.cap"]
|
171
181
|
}
|
172
182
|
}
|
173
183
|
}
|
@@ -8,24 +8,40 @@ Get up and running with mcpcap in minutes!
|
|
8
8
|
pip install mcpcap
|
9
9
|
```
|
10
10
|
|
11
|
-
## 2.
|
11
|
+
## 2. Choose Your PCAP Source
|
12
12
|
|
13
|
-
|
13
|
+
mcpcap supports multiple PCAP sources:
|
14
14
|
|
15
|
+
**Single PCAP file**:
|
16
|
+
```bash
|
17
|
+
# Use a specific PCAP file
|
18
|
+
mcpcap --pcap-path ~/Downloads/capture.pcap
|
19
|
+
```
|
20
|
+
|
21
|
+
**Directory of PCAP files**:
|
15
22
|
```bash
|
16
23
|
mkdir ~/pcap-analysis
|
17
24
|
# Copy your PCAP files to this directory
|
18
25
|
cp your-capture.pcap ~/pcap-analysis/
|
26
|
+
mcpcap --pcap-path ~/pcap-analysis
|
19
27
|
```
|
20
28
|
|
21
|
-
|
22
|
-
|
29
|
+
**Remote PCAP file**:
|
23
30
|
```bash
|
24
|
-
|
31
|
+
# Direct link to a PCAP file
|
32
|
+
mcpcap --pcap-url https://wiki.wireshark.org/uploads/__moin_import__/attachments/SampleCaptures/dns.cap
|
25
33
|
```
|
26
34
|
|
35
|
+
## 3. Start the MCP Server
|
36
|
+
|
27
37
|
The server will start and display connection information. Keep this terminal open.
|
28
38
|
|
39
|
+
**With analysis options**:
|
40
|
+
```bash
|
41
|
+
# Limit to first 100 packets for faster analysis
|
42
|
+
mcpcap --pcap-path ~/pcap-analysis --max-packets 100
|
43
|
+
```
|
44
|
+
|
29
45
|
## 4. Connect with an MCP Client
|
30
46
|
|
31
47
|
### Option A: MCP Inspector (Quick Testing)
|
@@ -34,7 +50,15 @@ Install and run MCP Inspector:
|
|
34
50
|
|
35
51
|
```bash
|
36
52
|
npm install -g @modelcontextprotocol/inspector
|
53
|
+
|
54
|
+
# Test with local directory
|
37
55
|
npx @modelcontextprotocol/inspector mcpcap --pcap-path ~/pcap-analysis
|
56
|
+
|
57
|
+
# Test with specific file
|
58
|
+
npx @modelcontextprotocol/inspector mcpcap --pcap-path ~/capture.pcap
|
59
|
+
|
60
|
+
# Test with remote file
|
61
|
+
npx @modelcontextprotocol/inspector mcpcap --pcap-url https://example.com/dns.cap
|
38
62
|
```
|
39
63
|
|
40
64
|
This opens a web interface where you can test the tools interactively.
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# mcpcap Examples
|
2
|
+
|
3
|
+
This directory contains example PCAP files and usage demonstrations.
|
4
|
+
|
5
|
+
## Example Files
|
6
|
+
|
7
|
+
- `dns.pcap` - Sample DNS traffic capture for testing mcpcap functionality
|
8
|
+
|
9
|
+
## Usage Examples
|
10
|
+
|
11
|
+
### Basic Analysis
|
12
|
+
|
13
|
+
**Analyze the entire examples directory:**
|
14
|
+
```bash
|
15
|
+
mcpcap --pcap-path ./examples
|
16
|
+
```
|
17
|
+
|
18
|
+
**Analyze specific file:**
|
19
|
+
```bash
|
20
|
+
mcpcap --pcap-path ./examples/dns.pcap
|
21
|
+
```
|
22
|
+
|
23
|
+
**With packet limits for faster testing:**
|
24
|
+
```bash
|
25
|
+
mcpcap --pcap-path ./examples/dns.pcap --max-packets 50
|
26
|
+
```
|
27
|
+
|
28
|
+
### MCP Client Testing
|
29
|
+
|
30
|
+
**With MCP Inspector:**
|
31
|
+
```bash
|
32
|
+
npm install -g @modelcontextprotocol/inspector
|
33
|
+
npx @modelcontextprotocol/inspector mcpcap --pcap-path ./examples/dns.pcap
|
34
|
+
```
|
35
|
+
|
36
|
+
Then use the web interface to:
|
37
|
+
- Call `list_pcap_files()` to see available files
|
38
|
+
- Call `list_dns_packets()` (leave filename empty for direct file mode)
|
39
|
+
- View structured DNS analysis results
|
40
|
+
|
41
|
+
### Analysis Prompts
|
42
|
+
|
43
|
+
Use these specialized prompts in your MCP client:
|
44
|
+
|
45
|
+
- **`security_analysis`** - Focus on threat detection in DNS traffic
|
46
|
+
- **`network_troubleshooting`** - Identify DNS performance issues
|
47
|
+
- **`forensic_investigation`** - Detailed timeline and attribution analysis
|
48
|
+
|
49
|
+
## Creating Your Own Examples
|
50
|
+
|
51
|
+
To add new example files:
|
52
|
+
|
53
|
+
1. Place PCAP files (`.pcap` or `.pcapng`) in this directory
|
54
|
+
2. Update this README with descriptions
|
55
|
+
3. Test with the mcpcap server
|
56
|
+
|
57
|
+
## Sample Output
|
58
|
+
|
59
|
+
When analyzing DNS packets, you'll get structured JSON output including:
|
60
|
+
|
61
|
+
- Packet timestamps and network details
|
62
|
+
- DNS query/response information
|
63
|
+
- Statistics (queries, responses, unique domains)
|
64
|
+
- Security-relevant metadata
|
@@ -28,6 +28,7 @@ classifiers = [
|
|
28
28
|
dependencies = [
|
29
29
|
"fastmcp",
|
30
30
|
"scapy",
|
31
|
+
"requests",
|
31
32
|
]
|
32
33
|
|
33
34
|
[project.optional-dependencies]
|
@@ -73,6 +74,7 @@ include = ["mcpcap*"]
|
|
73
74
|
target-version = "py310"
|
74
75
|
line-length = 88
|
75
76
|
src = ["src", "tests"]
|
77
|
+
exclude = ["src/mcpcap/_version.py"]
|
76
78
|
|
77
79
|
[tool.ruff.lint]
|
78
80
|
select = [
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
28
28
|
commit_id: COMMIT_ID
|
29
29
|
__commit_id__: COMMIT_ID
|
30
30
|
|
31
|
-
__version__ = version = '0.
|
32
|
-
__version_tuple__ = version_tuple = (0,
|
31
|
+
__version__ = version = '0.3.0'
|
32
|
+
__version_tuple__ = version_tuple = (0, 3, 0)
|
33
33
|
|
34
|
-
__commit_id__ = commit_id = '
|
34
|
+
__commit_id__ = commit_id = 'gc1a9a0372'
|
@@ -0,0 +1,85 @@
|
|
1
|
+
"""CLI entry point for mcpcap.
|
2
|
+
|
3
|
+
This module provides the command-line interface for mcpcap, handling argument parsing
|
4
|
+
and server initialization.
|
5
|
+
"""
|
6
|
+
|
7
|
+
import argparse
|
8
|
+
import sys
|
9
|
+
|
10
|
+
from .core import Config, MCPServer
|
11
|
+
|
12
|
+
|
13
|
+
def main():
|
14
|
+
"""Main function to parse arguments and start the MCP server.
|
15
|
+
|
16
|
+
Parses command-line arguments, initializes the configuration and MCP server,
|
17
|
+
and handles graceful shutdown and error conditions.
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
int: Exit code (0 for success, 1 for error)
|
21
|
+
|
22
|
+
Raises:
|
23
|
+
ValueError: If the provided PCAP path is invalid
|
24
|
+
KeyboardInterrupt: If the user interrupts the server
|
25
|
+
Exception: For any unexpected errors during server operation
|
26
|
+
"""
|
27
|
+
parser = argparse.ArgumentParser(description="mcpcap MCP Server")
|
28
|
+
|
29
|
+
# PCAP source options (mutually exclusive)
|
30
|
+
source_group = parser.add_mutually_exclusive_group(required=True)
|
31
|
+
source_group.add_argument(
|
32
|
+
"--pcap-path", help="Path to PCAP file or directory containing PCAP files"
|
33
|
+
)
|
34
|
+
source_group.add_argument(
|
35
|
+
"--pcap-url",
|
36
|
+
help="HTTP URL to PCAP file (direct link) or directory containing PCAP files",
|
37
|
+
)
|
38
|
+
|
39
|
+
# Analysis options
|
40
|
+
parser.add_argument(
|
41
|
+
"--modules",
|
42
|
+
help="Comma-separated list of modules to load (default: dns)",
|
43
|
+
default="dns",
|
44
|
+
)
|
45
|
+
parser.add_argument(
|
46
|
+
"--protocols",
|
47
|
+
help="Comma-separated list of protocols to analyze (default: dns)",
|
48
|
+
default="dns",
|
49
|
+
)
|
50
|
+
parser.add_argument(
|
51
|
+
"--max-packets",
|
52
|
+
type=int,
|
53
|
+
help="Maximum number of packets to analyze per file (default: unlimited)",
|
54
|
+
)
|
55
|
+
|
56
|
+
args = parser.parse_args()
|
57
|
+
|
58
|
+
try:
|
59
|
+
# Initialize configuration
|
60
|
+
config = Config(
|
61
|
+
pcap_path=args.pcap_path,
|
62
|
+
pcap_url=args.pcap_url,
|
63
|
+
modules=args.modules.split(",") if args.modules else ["dns"],
|
64
|
+
protocols=args.protocols.split(",") if args.protocols else ["dns"],
|
65
|
+
max_packets=args.max_packets,
|
66
|
+
)
|
67
|
+
|
68
|
+
# Create and start MCP server
|
69
|
+
server = MCPServer(config)
|
70
|
+
server.run()
|
71
|
+
return 0
|
72
|
+
|
73
|
+
except ValueError as e:
|
74
|
+
print(f"Error: {e}", file=sys.stderr)
|
75
|
+
return 1
|
76
|
+
except KeyboardInterrupt:
|
77
|
+
print("\\nServer stopped by user", file=sys.stderr)
|
78
|
+
return 0
|
79
|
+
except Exception as e:
|
80
|
+
print(f"Unexpected error: {e}", file=sys.stderr)
|
81
|
+
return 1
|
82
|
+
|
83
|
+
|
84
|
+
if __name__ == "__main__":
|
85
|
+
exit(main())
|