Testing MCP tools in process
Save the complete module below as tests/integration/test_greeting_mcp.py in your generated project (create the directories if necessary). Its server declaration is local to the test: it does not require adding an HTTP route or running a separate MCP server.
The MCP client sends encoded JSON-RPC through the real dispatcher and opens a new scope for each call. It integrates the protocol and container without sockets. It does not replace testing an HTTP proxy, allowed origin, or stdio transport. The following server declaration belongs in the test module and runs through the Orionis runner.
Examples
Section titled “Examples”Exercise a real MCP tool
Section titled “Exercise a real MCP tool”from orionis.mcp import McpResponse, Server, Toolfrom orionis.schemas import Schemafrom orionis.test import TestCase
class GreetingInput(Schema): name: str
class HelloTool(Tool[GreetingInput]): name = "hello"
def handle(self, payload: GreetingInput) -> McpResponse: return McpResponse.text(f"Hello, {payload.name}")
class GreetingServer(Server): name = "greetings" tools = (HelloTool,)
class TestGreetingServer(TestCase): async def testHello(self) -> None: client = await self.mcp(GreetingServer) response = await client.tool("hello", {"name": "Ada"}) response.assertOk() response.assertTextContains("Hello, Ada")Run and interpret the test
Section titled “Run and interpret the test”uv run python -B reactor test --start-dir tests/integration --file-pattern "test_greeting_mcp.py"Expect one passing test and exit code 0. assertOk() rejects JSON-RPC errors and tool results marked isError=True; assertTextContains() checks the returned text content. The tool must return McpResponse, not a raw Python dictionary or string. To test an existing application tool, import its real server class instead of declaring the example server and call the tool with representative input.