| 189 | # ------------------------------------------------------------------ public |
| 190 | |
| 191 | def call(self, tool: str, args: dict, timeout: float = TIMEOUT) -> tuple[dict | None, float]: |
| 192 | rid = self._next() |
| 193 | self._send({ |
| 194 | "jsonrpc": "2.0", |
| 195 | "method": "tools/call", |
| 196 | "params": {"name": tool, "arguments": args}, |
| 197 | "id": rid, |
| 198 | }) |
| 199 | t0 = time.time() |
| 200 | resp = self._recv_id(rid, timeout=timeout) |
| 201 | dt = time.time() - t0 |
| 202 | if isinstance(resp, dict) and resp.get("_timeout"): |
| 203 | # Caller is giving up — mark id stale so a late reply is dropped. |
| 204 | self._stale.add(rid) |
| 205 | return resp, dt |
| 206 | |
| 207 | def close(self) -> None: |
| 208 | try: |