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
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""Expose two filesystem roots and verify the server's tool can read them back."""
|
|
|
|
from mcp_types import ListRootsResult, Root, TextContent
|
|
from pydantic import FileUrl
|
|
|
|
from mcp.client import Client, ClientRequestContext
|
|
from stories._harness import Target, run_client
|
|
|
|
|
|
async def list_roots(context: ClientRequestContext) -> ListRootsResult:
|
|
return ListRootsResult(
|
|
roots=[
|
|
Root(uri=FileUrl("file:///workspace/project"), name="project"),
|
|
Root(uri=FileUrl("file:///workspace/scratch")),
|
|
]
|
|
)
|
|
|
|
|
|
async def main(target: Target, *, mode: str = "auto") -> None:
|
|
async with Client(target, mode=mode, list_roots_callback=list_roots) as client:
|
|
result = await client.call_tool("show_roots", {})
|
|
|
|
assert not result.is_error, result
|
|
assert isinstance(result.content[0], TextContent)
|
|
assert result.content[0].text == ("file:///workspace/project (project)\nfile:///workspace/scratch (unnamed)"), (
|
|
result.content[0].text
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_client(main)
|