41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from fastmcp import Client
|
|
from fastmcp.client.transports import StdioTransport
|
|
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()}
|
|
|
|
assert await client.list_tools() == []
|
|
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
|
|
|
|
|
|
@pytest.mark.integration
|
|
async def test_stdio_server_enumerates_and_reads_content() -> None:
|
|
transport = StdioTransport(
|
|
command=sys.executable,
|
|
args=["-m", "personal_mcp.mcp"],
|
|
cwd=str(Path(__file__).parent.parent),
|
|
keep_alive=False,
|
|
)
|
|
|
|
async with Client(transport) as client:
|
|
await assert_server_contract(client)
|