Skip to content

testing

nimblebrain_server_sdk.testing · install nimblebrain-server-sdk · version 0.7.2

from nimblebrain_server_sdk.testing import Mode, assert_bounded_rows, served_facets

Checks a server’s tests share: what a host sees of the server, checked as a host would.

def assert_bounded_rows(rows: Iterable[Mapping[str, Any]], *, unbounded: Iterable[str], max_chars: int = 1000) -> None

Assert a listing or search page is bounded and addressed, row by row.

Each row carries a non-empty uri, none of the unbounded fields, and no text longer than max_chars anywhere in it (nested values included). Seed every unbounded field longer than max_chars before listing, so a field that leaks under another name fails the length check, not only the name check. The default sits above any preview and any bounded field a row carries (a title, a URL); a server whose rows hold a longer bounded field passes its own. An empty page proves nothing, so it fails.

async def served_facets(mcp: FastMCP, mode: Mode = 'auto') -> dict[str, dict[str, Any]]

What a host sees of mcp’s facets, checked the way a host checks it.

Connects in mode, takes the resources whose _meta carries the facets marker (never a URI shape), and asserts each has a title, mimeType: application/json and a level the extension defines, and reads back one JSON text whose count is an integer at least zero. On 2026-07-28 it also asserts the server declares the extension; a legacy handshake carries no extensions, so there the marked resources are ordinary resources a host ignores. Returns {name: {"title", "level", "count"}} for a server’s tests to compare against the facets it means to serve.

async def served_skills(mcp: FastMCP, mode: Mode = 'auto') -> dict[str, dict[str, Any]]

What a host sees of mcp’s skills, checked the way a host checks it.

Connects in mode ("auto" negotiates 2026-07-28, "legacy" 2025-11-25), calls skills/list, reads every listed file back through resources/read and asserts its bytes match the listed digest and size, and asserts skills/get answers each skill with its list entry. On 2026-07-28 it also asserts the server declares the extension; a legacy handshake carries no extensions. Returns the entries by SKILL.md URI, for a server’s tests to compare against the skills it means to publish.

type Mode = Literal['auto', 'legacy']

The protocol era a check connects on, as fastmcp.Client(mcp, mode=...) takes it: "auto" negotiates 2026-07-28 and "legacy" runs the 2025-11-25 initialize handshake.