MCPcopy
hub / github.com/opentrace/opentrace / dispatch

Method dispatch

agent/src/opentrace_agent/benchmarks/agent.py:251–266  ·  view source on GitHub ↗

Execute a tool and return the result as a string.

(self, name: str, input_args: dict[str, Any])

Source from the content-addressed store, hash-verified

249 return self._patch
250
251 def dispatch(self, name: str, input_args: dict[str, Any]) -> str:
252 """Execute a tool and return the result as a string."""
253 try:
254 if name == "read_file":
255 return self._read_file(input_args["path"])
256 elif name == "list_directory":
257 return self._list_directory(input_args.get("path", "."))
258 elif name == "generate_patch":
259 self._patch = input_args["patch"]
260 return "Patch submitted successfully."
261 elif name in ("search_graph", "list_nodes", "get_node", "traverse_graph", "get_stats"):
262 return self._call_mcp(name, input_args)
263 else:
264 return json.dumps({"error": f"Unknown tool: {name}"})
265 except Exception as e:
266 return json.dumps({"error": f"{type(e).__name__}: {e}"})
267
268 def _read_file(self, rel_path: str) -> str:
269 target = (self._repo_path / rel_path).resolve()

Callers 10

agent_fnFunction · 0.95
test_read_fileMethod · 0.95
test_list_directoryMethod · 0.95
test_generate_patchMethod · 0.95
test_unknown_toolMethod · 0.95

Calls 4

_read_fileMethod · 0.95
_list_directoryMethod · 0.95
_call_mcpMethod · 0.95
getMethod · 0.65

Tested by 9

test_read_fileMethod · 0.76
test_list_directoryMethod · 0.76
test_generate_patchMethod · 0.76
test_unknown_toolMethod · 0.76