dynamic-mcp 0.2.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.
- dynamic_mcp-0.2.0/LICENSE +22 -0
- dynamic_mcp-0.2.0/PKG-INFO +387 -0
- dynamic_mcp-0.2.0/README.md +351 -0
- dynamic_mcp-0.2.0/pyproject.toml +60 -0
- dynamic_mcp-0.2.0/setup.cfg +4 -0
- dynamic_mcp-0.2.0/setup.py +229 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/bpftrace_executor.py +210 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/config.py +106 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/crash_discovery.py +134 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/crash_session.py +209 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/dynamic-mcp.service +55 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/kernel_detection.py +196 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/permission_manager.py +193 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/server.py +951 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/systemd_installer.py +238 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp/tunnel_manager.py +243 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp.egg-info/PKG-INFO +387 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp.egg-info/SOURCES.txt +21 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp.egg-info/dependency_links.txt +1 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp.egg-info/entry_points.txt +4 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp.egg-info/requires.txt +9 -0
- dynamic_mcp-0.2.0/src/dynamic_mcp.egg-info/top_level.txt +1 -0
- dynamic_mcp-0.2.0/tests/test_kernel_detection.py +86 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 42Research Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dynamic-mcp
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: MCP server for crash dump analysis
|
|
5
|
+
Author-email: 42Research Ltd <software@42research.co.uk>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ablagodarenko/42Research
|
|
8
|
+
Project-URL: Repository, https://github.com/ablagodarenko/42Research
|
|
9
|
+
Project-URL: Documentation, https://github.com/ablagodarenko/42Research/tree/main/dynamic_mcp
|
|
10
|
+
Project-URL: Issues, https://github.com/ablagodarenko/42Research/issues
|
|
11
|
+
Keywords: mcp,crash,analysis,debugging,kernel
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
22
|
+
Classifier: Topic :: System :: Monitoring
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: mcp>=1.0.0
|
|
27
|
+
Requires-Dist: uvicorn>=0.24.0
|
|
28
|
+
Requires-Dist: starlette>=0.27.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
31
|
+
Requires-Dist: pexpect>=4.8.0
|
|
32
|
+
Requires-Dist: psutil>=5.9.0
|
|
33
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
34
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Dynamic MCP Server
|
|
38
|
+
|
|
39
|
+
A professional MCP (Model Context Protocol) server for crash dump analysis and kernel debugging.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Real Crash Utility Integration**: Execute actual crash utility commands with real output
|
|
44
|
+
- **Automatic Crash Dump Discovery**: Find and list crash dumps in `/var/crash`
|
|
45
|
+
- **Intelligent Kernel Matching**: Automatic kernel debug symbol detection and matching
|
|
46
|
+
- **Session Management**: Robust crash analysis session lifecycle management
|
|
47
|
+
- **Multiple Dump Formats**: Support for vmcore, core, crash, and dump files
|
|
48
|
+
- **Professional Forensics**: Real kernel debugging and system forensics capabilities
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
- **Crash Utility**: Version 8.0.4+ (system package: `crash`)
|
|
53
|
+
- **Python**: 3.10+ (3.11+ recommended)
|
|
54
|
+
- **Kernel Debug Symbols**: Available in `/usr/lib/debug/lib/modules/`
|
|
55
|
+
- **Crash Dumps**: Accessible in `/var/crash/` or custom location
|
|
56
|
+
- **Permissions**: Read access to crash dumps and kernel files
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
### Quick Install (Recommended)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Install directly from source
|
|
64
|
+
pip install -e .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Development Install
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Create virtual environment (optional but recommended)
|
|
71
|
+
python3 -m venv dynamic_mcp_env
|
|
72
|
+
source dynamic_mcp_env/bin/activate
|
|
73
|
+
|
|
74
|
+
# Install dependencies and package
|
|
75
|
+
pip install -e .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### System Install
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Install system-wide (requires sudo)
|
|
82
|
+
sudo pip install .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### System Install with Systemd Service
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Install system-wide with automatic systemd service setup
|
|
89
|
+
sudo pip install .
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This automatically:
|
|
93
|
+
- Installs the package
|
|
94
|
+
- Copies the systemd service file
|
|
95
|
+
- Creates the dynamic-mcp user and group
|
|
96
|
+
- Creates required directories
|
|
97
|
+
- Registers the service with systemd
|
|
98
|
+
|
|
99
|
+
See [SYSTEMD_INSTALLATION.md](SYSTEMD_INSTALLATION.md) for detailed systemd setup instructions.
|
|
100
|
+
|
|
101
|
+
## Usage
|
|
102
|
+
|
|
103
|
+
### Running the MCP Server
|
|
104
|
+
|
|
105
|
+
#### Stdio Mode (Default)
|
|
106
|
+
```bash
|
|
107
|
+
# Run the server with stdio transport
|
|
108
|
+
dynamic-mcp
|
|
109
|
+
|
|
110
|
+
# Or with module syntax
|
|
111
|
+
python -m dynamic_mcp.server
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### HTTP/SSE Mode
|
|
115
|
+
```bash
|
|
116
|
+
# Run the server with HTTP transport on default port 8080
|
|
117
|
+
dynamic-mcp-http
|
|
118
|
+
|
|
119
|
+
# Or with module syntax
|
|
120
|
+
python -m dynamic_mcp.server --http
|
|
121
|
+
|
|
122
|
+
# Access the server at: http://localhost:8080/sse
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### MCP Client Configuration
|
|
126
|
+
|
|
127
|
+
#### For Stdio Transport
|
|
128
|
+
Add to your MCP client configuration (e.g., Claude Desktop):
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"dynamic-mcp": {
|
|
134
|
+
"command": "python",
|
|
135
|
+
"args": ["-m", "dynamic_mcp.server"],
|
|
136
|
+
"env": {
|
|
137
|
+
"LOG_LEVEL": "INFO"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### For HTTP/SSE Transport
|
|
145
|
+
Configure your MCP client to connect to the HTTP endpoint:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"dynamic-mcp": {
|
|
151
|
+
"url": "http://localhost:8080/sse",
|
|
152
|
+
"env": {
|
|
153
|
+
"LOG_LEVEL": "INFO"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Testing
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Run crash analysis tests
|
|
164
|
+
pytest tests/crash/
|
|
165
|
+
|
|
166
|
+
# Test crash utility integration
|
|
167
|
+
python tests/crash/test_crash_server.py
|
|
168
|
+
|
|
169
|
+
# Run all tests
|
|
170
|
+
pytest
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Configuration
|
|
174
|
+
|
|
175
|
+
Create a `.env` file with optional configuration:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Crash dump paths
|
|
179
|
+
CRASH_DUMP_PATH=/var/crash
|
|
180
|
+
KERNEL_PATH=/boot
|
|
181
|
+
|
|
182
|
+
# Session timeouts
|
|
183
|
+
CRASH_SESSION_TIMEOUT=180
|
|
184
|
+
CRASH_COMMAND_TIMEOUT=120
|
|
185
|
+
|
|
186
|
+
# Logging configuration
|
|
187
|
+
LOG_LEVEL=INFO
|
|
188
|
+
SUPPRESS_MCP_WARNINGS=true
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## MCP Tools
|
|
192
|
+
|
|
193
|
+
The server provides 5 comprehensive crash analysis tools:
|
|
194
|
+
|
|
195
|
+
### 1. crash_command
|
|
196
|
+
Execute crash utility commands with real output.
|
|
197
|
+
|
|
198
|
+
**Parameters:**
|
|
199
|
+
- `command` (string): Crash utility command to execute
|
|
200
|
+
- `timeout` (integer, optional): Command timeout in seconds (default: 120)
|
|
201
|
+
|
|
202
|
+
**Example:**
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"command": "sys",
|
|
206
|
+
"timeout": 60
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 2. get_crash_info
|
|
211
|
+
Get information about current crash dump and session.
|
|
212
|
+
|
|
213
|
+
**Returns:**
|
|
214
|
+
- Active session details
|
|
215
|
+
- Available crash dumps
|
|
216
|
+
- System requirements status
|
|
217
|
+
|
|
218
|
+
### 3. list_crash_dumps
|
|
219
|
+
List all available crash dumps.
|
|
220
|
+
|
|
221
|
+
**Parameters:**
|
|
222
|
+
- `max_dumps` (integer, optional): Maximum number of dumps to return (default: 10)
|
|
223
|
+
|
|
224
|
+
**Returns:**
|
|
225
|
+
- Crash dump details (name, path, size, timestamp)
|
|
226
|
+
- Readability status
|
|
227
|
+
|
|
228
|
+
### 4. start_crash_session
|
|
229
|
+
Start a new crash analysis session.
|
|
230
|
+
|
|
231
|
+
**Parameters:**
|
|
232
|
+
- `dump_name` (string, optional): Specific dump name (uses latest if not specified)
|
|
233
|
+
- `timeout` (integer, optional): Session startup timeout (default: 180)
|
|
234
|
+
|
|
235
|
+
**Returns:**
|
|
236
|
+
- Session startup status
|
|
237
|
+
- Matched kernel information
|
|
238
|
+
|
|
239
|
+
### 5. close_crash_session
|
|
240
|
+
Close the active crash analysis session.
|
|
241
|
+
|
|
242
|
+
**Returns:**
|
|
243
|
+
- Session closure status
|
|
244
|
+
|
|
245
|
+
## Example Usage
|
|
246
|
+
|
|
247
|
+
### Basic Crash Analysis Workflow
|
|
248
|
+
|
|
249
|
+
1. **List available crash dumps:**
|
|
250
|
+
```bash
|
|
251
|
+
# Use the list_crash_dumps tool
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
2. **Start a crash session:**
|
|
255
|
+
```bash
|
|
256
|
+
# Use start_crash_session tool (auto-selects latest dump)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
3. **Execute crash commands:**
|
|
260
|
+
```bash
|
|
261
|
+
# System information
|
|
262
|
+
crash_command: "sys"
|
|
263
|
+
|
|
264
|
+
# Backtrace
|
|
265
|
+
crash_command: "bt"
|
|
266
|
+
|
|
267
|
+
# Process list
|
|
268
|
+
crash_command: "ps"
|
|
269
|
+
|
|
270
|
+
# Kernel log
|
|
271
|
+
crash_command: "log"
|
|
272
|
+
|
|
273
|
+
# Module information
|
|
274
|
+
crash_command: "mod"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
4. **Close session when done:**
|
|
278
|
+
```bash
|
|
279
|
+
# Use close_crash_session tool
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Troubleshooting
|
|
283
|
+
|
|
284
|
+
### System Requirements
|
|
285
|
+
|
|
286
|
+
**Crash utility not found:**
|
|
287
|
+
```bash
|
|
288
|
+
# Install crash utility (RHEL/CentOS/Fedora)
|
|
289
|
+
sudo yum install crash
|
|
290
|
+
# or
|
|
291
|
+
sudo dnf install crash
|
|
292
|
+
|
|
293
|
+
# Install crash utility (Ubuntu/Debian)
|
|
294
|
+
sudo apt-get install crash
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**No crash dumps found:**
|
|
298
|
+
- Check `/var/crash/` directory exists and has crash dumps
|
|
299
|
+
- Ensure read permissions on crash dump files
|
|
300
|
+
- Verify crash dumps are valid format (vmcore, core, etc.)
|
|
301
|
+
|
|
302
|
+
**Kernel debug symbols missing:**
|
|
303
|
+
- Install kernel debug packages
|
|
304
|
+
- Check `/usr/lib/debug/lib/modules/` for debug symbols
|
|
305
|
+
- Ensure kernel version matches crash dump
|
|
306
|
+
|
|
307
|
+
### MCP Initialization Warnings
|
|
308
|
+
|
|
309
|
+
You may see warnings like:
|
|
310
|
+
```
|
|
311
|
+
WARNING - Failed to validate request: Received request before initialization was complete
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**This is normal MCP protocol behavior** and doesn't affect functionality.
|
|
315
|
+
|
|
316
|
+
**To suppress these warnings:**
|
|
317
|
+
```bash
|
|
318
|
+
export SUPPRESS_MCP_WARNINGS=true
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## How It Works
|
|
322
|
+
|
|
323
|
+
1. **Crash Dump Discovery**: Automatically scans `/var/crash/` for crash dumps
|
|
324
|
+
2. **Kernel Matching**: Finds matching kernel debug symbols in `/usr/lib/debug/`
|
|
325
|
+
3. **Session Management**: Starts crash utility process with proper kernel and dump
|
|
326
|
+
4. **Command Execution**: Uses pexpect to interact with crash utility process
|
|
327
|
+
5. **Output Capture**: Returns real crash utility output with proper formatting
|
|
328
|
+
|
|
329
|
+
## Supported Crash Analysis
|
|
330
|
+
|
|
331
|
+
### Crash Commands
|
|
332
|
+
- **System Info**: `sys`, `mach`, `help`
|
|
333
|
+
- **Process Analysis**: `ps`, `task`, `files`
|
|
334
|
+
- **Memory Analysis**: `kmem`, `vm`, `search`
|
|
335
|
+
- **Stack Analysis**: `bt`, `bt -a`, `bt -f`
|
|
336
|
+
- **Kernel Analysis**: `log`, `dmesg`, `mod`
|
|
337
|
+
- **Disassembly**: `dis`, `gdb`
|
|
338
|
+
- **Lustre Analysis**: Lustre-specific commands for filesystem debugging
|
|
339
|
+
|
|
340
|
+
### Crash Dump Formats
|
|
341
|
+
- **vmcore**: Standard Linux kernel crash dumps
|
|
342
|
+
- **core**: Core dump files
|
|
343
|
+
- **crash**: Crash utility format
|
|
344
|
+
- **dump**: Generic dump files
|
|
345
|
+
|
|
346
|
+
### Kernel Support
|
|
347
|
+
- **Debug Symbols**: Automatic detection from `/usr/lib/debug/`
|
|
348
|
+
- **Kernel Versions**: Support for multiple kernel versions
|
|
349
|
+
- **Lustre Kernels**: Special support for Lustre filesystem kernels
|
|
350
|
+
|
|
351
|
+
## Architecture
|
|
352
|
+
|
|
353
|
+
- **MCP Protocol**: Full compliance with Model Context Protocol
|
|
354
|
+
- **Real Integration**: Uses actual crash utility (not simulation)
|
|
355
|
+
- **Session Management**: Robust process lifecycle management
|
|
356
|
+
- **Error Handling**: Comprehensive error handling and recovery
|
|
357
|
+
- **Logging**: Detailed logging for debugging and monitoring
|
|
358
|
+
|
|
359
|
+
## License
|
|
360
|
+
|
|
361
|
+
This project is licensed under the MIT License.
|
|
362
|
+
|
|
363
|
+
Copyright © 2025 42Research Ltd
|
|
364
|
+
|
|
365
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
366
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
367
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
368
|
+
and/or sell copies of the Software.
|
|
369
|
+
|
|
370
|
+
For full license terms, see the [LICENSE](LICENSE) file.
|
|
371
|
+
|
|
372
|
+
**Contact**: Email: software@42research.co.uk | Website: https://42research.co.uk
|
|
373
|
+
|
|
374
|
+
## Contributing
|
|
375
|
+
|
|
376
|
+
1. Fork the repository
|
|
377
|
+
2. Create a feature branch
|
|
378
|
+
3. Make your changes
|
|
379
|
+
4. Add tests for new functionality
|
|
380
|
+
5. Submit a pull request
|
|
381
|
+
|
|
382
|
+
## Support
|
|
383
|
+
|
|
384
|
+
For issues and questions:
|
|
385
|
+
- Check the troubleshooting section above
|
|
386
|
+
- Review system requirements
|
|
387
|
+
- Ensure crash utility and debug symbols are properly installed
|