49b9bb6724
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""List tools, inspect schemas + annotations, call both tools, assert structured output."""
|
|
|
|
from mcp_types import TextContent
|
|
|
|
from mcp.client import Client
|
|
from stories._harness import Target, run_client
|
|
|
|
|
|
async def main(target: Target, *, mode: str = "auto") -> None:
|
|
async with Client(target, mode=mode) as client:
|
|
listed = await client.list_tools()
|
|
by_name = {t.name: t for t in listed.tools}
|
|
assert set(by_name) == {"calc", "echo"}
|
|
|
|
calc = by_name["calc"]
|
|
assert calc.annotations is not None and calc.annotations.read_only_hint is True
|
|
assert calc.annotations.idempotent_hint is True
|
|
assert calc.output_schema is not None
|
|
assert set(calc.input_schema.get("required", ())) >= {"op", "a", "b"}
|
|
assert by_name["echo"].output_schema is None
|
|
|
|
result = await client.call_tool("calc", {"op": "add", "a": 2, "b": 3})
|
|
assert not result.is_error
|
|
assert result.structured_content == {"op": "add", "result": 5.0}, result
|
|
|
|
echoed = await client.call_tool("echo", {"text": "hi"})
|
|
assert echoed.structured_content is None
|
|
assert isinstance(echoed.content[0], TextContent) and echoed.content[0].text == "hi"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_client(main)
|