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
25 lines
775 B
Python
25 lines
775 B
Python
"""Run from the repository root:
|
|
uv run examples/snippets/clients/streamable_basic.py
|
|
"""
|
|
|
|
import asyncio
|
|
|
|
from mcp import ClientSession
|
|
from mcp.client.streamable_http import streamable_http_client
|
|
|
|
|
|
async def main():
|
|
# Connect to a streamable HTTP server
|
|
async with streamable_http_client("http://localhost:8000/mcp") as (read_stream, write_stream):
|
|
# Create a session using the client streams
|
|
async with ClientSession(read_stream, write_stream) as session:
|
|
# Initialize the connection
|
|
await session.initialize()
|
|
# List available tools
|
|
tools = await session.list_tools()
|
|
print(f"Available tools: {[tool.name for tool in tools.tools]}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|