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

Function mock_execute

examples/apps/apps_demo.py:246–261  ·  view source on GitHub ↗
(
        tool_name: str, arguments: dict[str, Any], namespace: str = ""
    )

Source from the content-addressed store, hash-verified

244 self.error = None
245
246 async def mock_execute(
247 tool_name: str, arguments: dict[str, Any], namespace: str = ""
248 ) -> FakeResult:
249 import datetime
250
251 if tool_name == "echo":
252 return FakeResult({"echoed": arguments.get("message", "")})
253 if tool_name == "get_time":
254 return FakeResult({"time": datetime.datetime.now().isoformat()})
255 if tool_name == "calculate":
256 a = arguments.get("a", 0)
257 b = arguments.get("b", 0)
258 op = arguments.get("operation", "add")
259 ops = {"add": a + b, "subtract": a - b, "multiply": a * b}
260 return FakeResult({"result": ops.get(op, 0), "operation": op})
261 return FakeResult({"error": f"Unknown tool: {tool_name}"})
262
263 tm.execute_tool = AsyncMock(side_effect=mock_execute)
264

Callers

nothing calls this directly

Calls 2

FakeResultClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected