Spaces:
Sleeping
Sleeping
File size: 6,768 Bytes
d9ac8a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | # Network Forensics MCP Interfaces
This document describes the two MCP (Model Context Protocol) interfaces available in the Network Forensics Environment.
## Overview
The Network Forensics Environment provides **two distinct MCP interfaces** to support different use cases and client compatibility:
1. **Simplified MCP Interface** (`/mcp`) - OpenEnv custom protocol
2. **Standard MCP Interface** (`/mcp-standard`) - Full MCP protocol compliance
## Interface Comparison
| Feature | Simplified MCP (`/mcp`) | Standard MCP (`/mcp-standard`) |
|---------|-------------------------|--------------------------------|
| **Protocol** | OpenEnv custom JSON-RPC | Full MCP specification |
| **Compatibility** | OpenEnv clients | Claude Desktop, Cursor, LangChain |
| **Initialize** | Not required | Required (`/initialize`) |
| **Tool Discovery** | Static | Dynamic (`/tools/list`) |
| **WebSocket** | Custom format | Standard MCP format |
| **Use Case** | Legacy support | Modern MCP clients |
## Simplified MCP Interface (`/mcp`)
**Endpoint**: `http://localhost:8000/mcp`
This interface maintains compatibility with existing OpenEnv clients and provides a simplified JSON-RPC style API.
### Usage
```bash
# HTTP POST
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"action_type": "inspect_packet", "packet_id": "pkt_0001"}'
# WebSocket
ws://localhost:8000/mcp
```
### Tools Available
- `inspect_packet` - Reveal packet payload
- `flag_as_suspicious` - Mark packet as malicious
- `group_into_session` - Group related packets
- `tag_pattern` - Classify attack patterns
- `identify_entry_point` - Find initial compromise
- `submit_report` - Submit final analysis
## Standard MCP Interface (`/mcp-standard`)
**Endpoints**:
- HTTP: `http://localhost:8000/mcp-standard`
- WebSocket: `ws://localhost:8000/mcp-standard/ws`
This interface implements the full MCP specification and is compatible with standard MCP clients like Claude Desktop, Cursor, and LangChain.
### Quick Start
1. **Start the server**:
```bash
python -m server.app
```
2. **Get MCP interface info**:
```bash
curl http://localhost:8000/mcp-info
```
3. **Initialize connection**:
```bash
curl -X POST http://localhost:8000/mcp-standard/initialize \
-H "Content-Type: application/json" \
-d '{
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {"name": "claude-desktop", "version": "1.0.0"}
}'
```
4. **List available tools**:
```bash
curl -X POST http://localhost:8000/mcp-standard/tools/list
```
5. **Call a tool**:
```bash
curl -X POST http://localhost:8000/mcp-standard/tools/call \
-H "Content-Type: application/json" \
-d '{
"name": "inspect_packet",
"arguments": {"packet_id": "pkt_0001"}
}'
```
### Available Tools
#### `reset_env`
Start a new investigation episode.
```json
{
"name": "reset_env",
"arguments": {
"task_id": "easy" // "easy", "medium", or "hard"
}
}
```
#### `get_status`
Get current investigation status.
```json
{
"name": "get_status",
"arguments": {}
}
```
#### `inspect_packet`
Reveal packet payload for analysis.
```json
{
"name": "inspect_packet",
"arguments": {
"packet_id": "pkt_0001"
}
}
```
#### `flag_as_suspicious`
Flag a packet as malicious.
```json
{
"name": "flag_as_suspicious",
"arguments": {
"packet_id": "pkt_0001"
}
}
```
#### `group_into_session`
Group related packets.
```json
{
"name": "group_into_session",
"arguments": {
"session_name": "ddos_attack_1",
"packet_ids": ["pkt_0001", "pkt_0002", "pkt_0003"]
}
}
```
#### `tag_pattern`
Classify attack patterns.
```json
{
"name": "tag_pattern",
"arguments": {
"session_name": "ddos_attack_1",
"pattern_type": "ddos"
}
}
```
#### `identify_entry_point`
Find initial compromise.
```json
{
"name": "identify_entry_point",
"arguments": {
"claimed_entry_point": "pkt_0001"
}
}
```
#### `submit_report`
Submit final analysis.
```json
{
"name": "submit_report",
"arguments": {
"incident_summary": "Found DDoS attack targeting...",
"claimed_entry_point": "pkt_0001"
}
}
```
## WebSocket Usage (Standard MCP)
For real-time communication, use the WebSocket endpoint:
```javascript
const ws = new WebSocket('ws://localhost:8000/mcp-standard/ws');
ws.onopen = () => {
// Initialize
ws.send(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "2024-11-05",
capabilities: {},
clientInfo: { name: "claude-desktop", version: "1.0.0" }
}
}));
};
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
console.log("MCP Response:", response);
};
```
## Testing Both Interfaces
Use the provided test script to verify both interfaces work correctly:
```bash
python test_mcp_interfaces.py
```
This will test:
- ✅ Simplified MCP interface
- ✅ Standard MCP HTTP endpoints
- ✅ Standard MCP WebSocket
- ✅ Complete forensics workflow
## Choosing the Right Interface
### Use Simplified MCP (`/mcp`) when:
- Working with existing OpenEnv clients
- Need backward compatibility
- Prefer simpler JSON-RPC style
### Use Standard MCP (`/mcp-standard`) when:
- Integrating with Claude Desktop
- Building Cursor plugins
- Using LangChain or other MCP-compatible tools
- Need full protocol compliance
## Troubleshooting
### "Method not found: initialize"
**Cause**: Using standard MCP client with simplified interface
**Solution**: Use `/mcp-standard` endpoint instead of `/mcp`
### Connection refused
**Cause**: Server not running
**Solution**: Start the server first:
```bash
python -m server.app
```
### WebSocket connection fails
**Cause**: Port conflicts or firewall issues
**Solution**: Check port 8000 is available and firewall allows WebSocket connections
## Migration Guide
### From Simplified to Standard MCP
1. **Add initialization step**:
```bash
# Old (simplified)
curl -X POST /mcp -d '{"action_type": "inspect_packet", ...}'
# New (standard)
curl -X POST /mcp-standard/initialize -d '{...}'
curl -X POST /mcp-standard/tools/call -d '{"name": "inspect_packet", ...}'
```
2. **Use tool discovery**:
```bash
curl -X POST /mcp-standard/tools/list
```
3. **Update WebSocket format**:
```javascript
// Old (simplified)
ws.send(JSON.stringify({"action_type": "inspect_packet", ...}));
// New (standard)
ws.send(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: {name: "inspect_packet", arguments: {...}}
}));
```
## Further Reading
- [Model Context Protocol Specification](https://modelcontextprotocol.io/)
- [OpenEnv Documentation](https://openenv.readthedocs.io/)
- [Network Forensics Environment README](README.md) |