from fastmcp import Client from mcp_types import TextContent from mcp_types import TextResourceContents async def assert_server_contract(client: Client) -> None: resources = {str(resource.uri) for resource in await client.list_resources()} templates = {str(template.uri_template) for template in await client.list_resource_templates()} prompts = {prompt.name for prompt in await client.list_prompts()} tools = {tool.name for tool in await client.list_tools()} assert tools == {"get_prompt", "list_prompts", "list_resources", "read_resource"} assert "skill://pytesting/SKILL.md" in resources assert "resource://docs/{path*}" in templates assert "skill://pytesting/{path*}" in templates assert "pytest-fill-scaffold" in prompts skill_content = await client.read_resource("skill://pytesting/SKILL.md") docs_content = await client.read_resource("resource://docs/index.md") assert isinstance(skill_content[0], TextResourceContents) assert "# Pytesting" in skill_content[0].text assert isinstance(docs_content[0], TextResourceContents) assert '"format": "markdown"' in docs_content[0].text listed = await client.call_tool("list_resources") listed_content = listed.content[0] assert isinstance(listed_content, TextContent) assert "skill://pytesting/SKILL.md" in listed_content.text read = await client.call_tool("read_resource", {"uri": "skill://pytesting/SKILL.md"}) read_content = read.content[0] assert isinstance(read_content, TextContent) assert "# Pytesting" in read_content.text