MCPcopy Create free account
hub / github.com/IBM/mcp-cli / FakeToolManager

Class FakeToolManager

tests/planning/test_backends.py:38–70  ·  view source on GitHub ↗

Minimal ToolManager stub for testing McpToolBackend.

Source from the content-addressed store, hash-verified

36
37
38class FakeToolManager:
39 """Minimal ToolManager stub for testing McpToolBackend."""
40
41 def __init__(
42 self,
43 *,
44 result: Any = "ok",
45 success: bool = True,
46 error: str | None = None,
47 raise_exc: Exception | None = None,
48 ):
49 self._result = result
50 self._success = success
51 self._error = error
52 self._raise_exc = raise_exc
53 self.calls: list[tuple[str, dict, str | None]] = []
54
55 async def execute_tool(
56 self,
57 tool_name: str,
58 arguments: dict[str, Any],
59 namespace: str | None = None,
60 timeout: float | None = None,
61 ) -> FakeToolCallResult:
62 self.calls.append((tool_name, arguments, namespace))
63 if self._raise_exc:
64 raise self._raise_exc
65 return FakeToolCallResult(
66 tool_name=tool_name,
67 success=self._success,
68 result=self._result,
69 error=self._error,
70 )
71
72
73# ── Tests: Basic Execution ───────────────────────────────────────────────────

Calls

no outgoing calls