Skip to content

Commit 2378179

Browse files
authored
Merge pull request #10 from sleeyax/fix/body-key-mismatch
fix: use correct `body_preview` key instead of `body`
2 parents 5cba569 + fc5e67d commit 2378179

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/mitmproxy_mcp/core/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,10 @@ async def extract_from_flow(flow_id: str, json_path: str = None, css_selector: s
300300
return "No matching flow."
301301

302302
response = flow_data.get("response")
303-
if not response or not response.get("body"):
303+
body_content = response.get("body_preview") if response else None
304+
if not body_content:
304305
return "Flow has no response body."
305306

306-
body_content = response["body"]
307-
308307
if json_path:
309308
try:
310309
# Parse body as JSON
@@ -377,10 +376,11 @@ async def extract_session_variable(
377376
return "No matching flow."
378377

379378
response = flow_data.get("response")
380-
if not response or not response.get("body"):
379+
body_content = response.get("body_preview") if response else None
380+
if not body_content:
381381
return "Flow has no response body."
382382
try:
383-
match = re.search(regex_pattern, response["body"])
383+
match = re.search(regex_pattern, body_content)
384384
if match:
385385
value = match.group(group_index)
386386
controller.session_variables[name] = value

0 commit comments

Comments
 (0)