Download bundles/bookstack/artifacts/check_bookstack/verify.py from earakely-scale/BookStackEnv-REA: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/earakely-scale/BookStackEnv-REA/resolve/main/bundles/bookstack/artifacts/check_bookstack/verify.py
- Command line
-
hf download hf://datasets/earakely-scale/BookStackEnv-REA/bundles/bookstack/artifacts/check_bookstack/verify.py
-
curl -L -o verify.py https://huggingface.co/datasets/earakely-scale/BookStackEnv-REA/resolve/main/bundles/bookstack/artifacts/check_bookstack/verify.py
1.53 kB
| """Checks the replay environment through its MCP endpoint: the tool count and one replayed status.""" | |
| import json | |
| from mcp import ClientSession | |
| from mcp.client.streamable_http import streamable_http_client | |
| TOOL_COUNT = 31 | |
| TOOL = "get_attachments" | |
| RECORDED_STATUS = 200 | |
| def replayed_status(result): | |
| """The status member of a replayed tool result, structured or from its text content.""" | |
| data = result.structuredContent | |
| if data is None: | |
| text = "".join(getattr(part, "text", "") for part in result.content) | |
| data = json.loads(text) if text else {} | |
| return data.get("status") if isinstance(data, dict) else None | |
| async def verify(mcp_url): | |
| async with streamable_http_client(mcp_url) as (read, write, _): | |
| async with ClientSession(read, write) as session: | |
| await session.initialize() | |
| listed = await session.list_tools() | |
| result = await session.call_tool(TOOL, {}) if TOOL is not None else None | |
| count = len(listed.tools) | |
| passed = count == TOOL_COUNT | |
| description = f"listed {count} tools, expected {TOOL_COUNT}" | |
| if result is not None: | |
| status = None if result.isError else replayed_status(result) | |
| passed = passed and status == RECORDED_STATUS | |
| description += f"; {TOOL} replayed status {status!r}, recorded {RECORDED_STATUS!r}" | |
| else: | |
| description += "; no GET tool without path parameters to replay" | |
| print(f"replay: {description}") | |
| return [{"id": "replay", "result": passed, "description": description}] | |