forked from Keelrleek/Harbor
Per-agent x64dbg session through debugger()/debugger_tools()
Harbor starts the x64dbg-automate MCP server (stdio) on first use and keeps it for the life of the agent's Harbor process; the debuggee is terminated when that process exits. Configured by debugger_command/_path/_temp in [reverse].
This commit is contained in:
1 parent
7ed914ebdb
commit
584fabeb74
5 files changed
+175
-4
No files matched your search
@@ -0,0 +1,18 @@
|
||||
"""A fake stdio MCP server for the debugger forwarder test: one tool that echoes, one that fails."""
|
||||
import json
|
||||
import sys
|
||||
|
||||
for line in sys.stdin:
|
||||
msg = json.loads(line)
|
||||
if "id" not in msg:
|
||||
continue
|
||||
if msg["method"] == "initialize":
|
||||
result = {"protocolVersion": "2025-06-18"}
|
||||
elif msg["method"] == "tools/list":
|
||||
result = {"tools": [{"name": "echo", "description": "Echo", "inputSchema": {"properties": {"x": {}}}}]}
|
||||
elif msg["params"]["name"] == "echo":
|
||||
result = {"content": [{"type": "text", "text": "echo " + json.dumps(msg["params"]["arguments"])}]}
|
||||
else:
|
||||
result = {"isError": True, "content": [{"type": "text", "text": "no such session"}]}
|
||||
print(json.dumps({"jsonrpc": "2.0", "method": "notifications/message", "params": {}}), flush=True)
|
||||
print(json.dumps({"jsonrpc": "2.0", "id": msg["id"], "result": result}), flush=True)
|
||||
@@ -117,3 +117,22 @@ class GhidraForwarder(unittest.TestCase):
|
||||
with self.assertRaises(HarborError):
|
||||
from harbor.reverse import Ghidra
|
||||
Ghidra({"ghidra_url": "http://127.0.0.1:9/mcp"}).tools()
|
||||
|
||||
|
||||
class DebuggerForwarder(unittest.TestCase):
|
||||
"""debugger() keeps one stdio MCP server per Harbor process and skips its notifications."""
|
||||
|
||||
def test_call_and_error(self):
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from harbor.reverse import Debugger
|
||||
d = Debugger({"debugger_command": [sys.executable, "-B", str(Path(__file__).with_name("fake_stdio_mcp.py"))]})
|
||||
try:
|
||||
self.assertEqual(d.tools()[0]["name"], "echo")
|
||||
self.assertEqual(d.call("echo", {"x": 1}), 'echo {"x": 1}')
|
||||
with self.assertRaises(HarborError):
|
||||
d.call("terminate_session")
|
||||
finally:
|
||||
d.close()
|
||||
with self.assertRaises(HarborError):
|
||||
Debugger({})
|
||||
Reference in new issue
Block a user