Skip to main content
Glama
assertions.py1.2 kB
""" Test assertion helpers for YNAB MCP Server tests. This module provides helper functions for common test assertions and response parsing to reduce boilerplate in test files. """ import json from typing import Any from mcp.types import TextContent def extract_response_data(result: Any) -> dict[str, Any]: """Extract JSON data from MCP client response.""" # Handle FastMCP CallToolResult format if not hasattr(result, "content"): raise TypeError(f"Expected CallToolResult with content, got {type(result)}") content = result.content assert len(content) == 1 response_data: dict[str, Any] | None = ( json.loads(content[0].text) if isinstance(content[0], TextContent) else None ) assert response_data is not None return response_data def assert_pagination_info( pagination: dict[str, Any], *, total_count: int, limit: int, offset: int = 0, has_more: bool = False, ) -> None: """Assert pagination info matches expected values.""" assert pagination["total_count"] == total_count assert pagination["limit"] == limit assert pagination["offset"] == offset assert pagination["has_more"] == has_more

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chrisguidry/you-need-an-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server