Skip to content

Commit b6a7d66

Browse files
Redesign cli and client (#135)
* Redesign cli and client
1 parent 89e8521 commit b6a7d66

40 files changed

+3277
-3056
lines changed

docs/getting-started/examples.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ mcp-fuzzer --mode tools --protocol http --endpoint http://localhost:8000 --runs
1919
mcp-fuzzer --mode tools --protocol http --endpoint http://localhost:8000 --runs 10 --timeout 60.0
2020
```
2121

22+
#### Single Tool Fuzzing
23+
24+
```bash
25+
# Fuzz only a specific tool
26+
mcp-fuzzer --mode tool --tool analyze_repository --protocol http --endpoint http://localhost:8000 --runs 20
27+
28+
# Fuzz a specific tool with both phases
29+
mcp-fuzzer --mode tool --tool generate_terraform --phase both --protocol http --endpoint http://localhost:8000 --runs 15
30+
```
31+
2232
#### Protocol Fuzzing
2333

2434
```bash

docs/getting-started/getting-started.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ First, ensure you have an MCP server running. You can use any of these transport
4343
#### Tool Fuzzing (Default Mode)
4444

4545
```bash
46-
# Basic tool fuzzing
46+
# Basic tool fuzzing (all tools)
4747
mcp-fuzzer --mode tools --protocol http --endpoint http://localhost:8000 --runs 10
4848

4949
# With verbose output
@@ -53,6 +53,16 @@ mcp-fuzzer --mode tools --protocol http --endpoint http://localhost:8000 --runs
5353
mcp-fuzzer --mode tools --protocol stdio --endpoint "python test_server.py" --runs 5 --enable-safety-system
5454
```
5555

56+
#### Single Tool Fuzzing
57+
58+
```bash
59+
# Fuzz only a specific tool
60+
mcp-fuzzer --mode tool --tool analyze_repository --protocol http --endpoint http://localhost:8000 --runs 20
61+
62+
# Fuzz a specific tool with both phases
63+
mcp-fuzzer --mode tool --tool generate_terraform --phase both --protocol http --endpoint http://localhost:8000 --runs 15
64+
```
65+
5666
#### Protocol Fuzzing
5767

5868
```bash

examples/custom_websocket_transport.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ async def send_request(
159159
response = json.loads(response_text)
160160
if isinstance(response, dict) and response.get("id") == request_id:
161161
logger.debug(
162-
f"Received WebSocket response for {method} (id={request_id})"
162+
"Received WebSocket response for %s (id=%s)",
163+
method,
164+
request_id,
163165
)
164166
if "error" in response:
165167
error_msg = f"Server error: {response['error']}"
@@ -278,11 +280,19 @@ async def _stream_request(
278280
timeout=self.timeout
279281
)
280282
response = json.loads(response_text)
281-
req_id = payload.get("id") if isinstance(payload, dict) else None
282-
if req_id is None or (isinstance(response, dict) and response.get("id") == req_id):
283+
req_id = (
284+
payload.get("id") if isinstance(payload, dict) else None
285+
)
286+
if req_id is None or (
287+
isinstance(response, dict)
288+
and response.get("id") == req_id
289+
):
283290
yield response
284291
else:
285-
logger.debug("Ignoring out-of-band WebSocket message during stream: %s", response)
292+
logger.debug(
293+
"Ignoring extra WebSocket stream message: %s",
294+
response,
295+
)
286296
except asyncio.TimeoutError:
287297
logger.debug("WebSocket stream timeout")
288298
break
@@ -369,5 +379,11 @@ def _factory(first_arg: str, **kwargs):
369379

370380
print("WebSocket transport example loaded successfully!")
371381
print("Usage in MCP Fuzzer:")
372-
print(" transport = create_transport('websocket://localhost:8080/mcp') # custom scheme")
373-
print(" transport = create_transport('ws://localhost:8080/mcp') # direct ws URL")
382+
print(
383+
" transport = create_transport('websocket://localhost:8080/mcp')"
384+
" # custom scheme"
385+
)
386+
print(
387+
" transport = create_transport('ws://localhost:8080/mcp')"
388+
" # direct ws URL"
389+
)

0 commit comments

Comments
 (0)