Files
modelcontextprotocol--pytho…/docs_src/client_transports/tutorial003.py
T
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:10:27 +08:00

17 lines
560 B
Python

import httpx
from mcp import Client
from mcp.client.streamable_http import streamable_http_client
async def main() -> None:
async with httpx.AsyncClient(
headers={"Authorization": "Bearer ..."},
timeout=httpx.Timeout(30.0, read=300.0),
follow_redirects=True,
) as http_client:
transport = streamable_http_client("http://localhost:8000/mcp", http_client=http_client)
async with Client(transport) as client:
result = await client.list_tools()
print([tool.name for tool in result.tools])