Add story-style examples suite (27 stories + harness + CI) (#2957)
This commit is contained in:
parent
9dc8c5f02d
commit
4caa41f6d5
1 changed files with 6801 additions and 26 deletions
23
examples/stories/starlette_mount/client.py
Normal file
23
examples/stories/starlette_mount/client.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""Connect to the sub-mounted MCP endpoint at /api/, list tools and call greet. HTTP-only: the mount is the story."""
|
||||
|
||||
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()
|
||||
assert [t.name for t in listed.tools] == ["greet"]
|
||||
|
||||
result = await client.call_tool("greet", {"name": "Starlette"})
|
||||
assert not result.is_error
|
||||
first = result.content[0]
|
||||
assert isinstance(first, TextContent)
|
||||
assert "Hello, Starlette!" in first.text, result
|
||||
assert result.structured_content == {"result": "Hello, Starlette! (served from a Starlette sub-mount)"}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_client(main)
|
||||
Loading…
Reference in a new issue