from __future__ import annotations import asyncio from typing import Any import pytest from mcp.types import TextContent import pyro_mcp.server as server_module from pyro_mcp.server import HELLO_STATIC_PAYLOAD, create_server def test_create_server_registers_static_tool() -> None: async def _run() -> list[str]: server = create_server() tools = await server.list_tools() return [tool.name for tool in tools] tool_names = asyncio.run(_run()) assert "hello_static" in tool_names def test_hello_static_returns_expected_payload() -> None: async def _run() -> tuple[list[TextContent], dict[str, Any]]: server = create_server() blocks, structured = await server.call_tool("hello_static", {}) assert isinstance(blocks, list) assert all(isinstance(block, TextContent) for block in blocks) assert isinstance(structured, dict) return blocks, structured _, structured_output = asyncio.run(_run()) assert structured_output == HELLO_STATIC_PAYLOAD def test_server_main_runs_stdio_transport(monkeypatch: pytest.MonkeyPatch) -> None: called: dict[str, str] = {} class StubServer: def run(self, transport: str) -> None: called["transport"] = transport monkeypatch.setattr(server_module, "create_server", lambda: StubServer()) server_module.main() assert called == {"transport": "stdio"}