Introduce a function to create a standard AsyncClient with options (#655)
Some checks failed
Main branch checks / checks (push) Has been cancelled

This commit is contained in:
ihrpr 2025-05-08 20:53:21 +01:00 • committed by GitHub
commit ed25167fa5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,8 @@
import anyio
import click
import httpx
import mcp.types as types
from mcp.server.lowlevel import Server
from mcp.shared._httpx_utils import create_mcp_http_client
async def fetch_website(
@ -11,7 +11,7 @@ async def fetch_website(
headers = {
"User-Agent": "MCP Test Server (github.com/modelcontextprotocol/python-sdk)"
}
async with httpx.AsyncClient(follow_redirects=True, headers=headers) as client:
async with create_mcp_http_client(headers=headers) as client:
response = await client.get(url)
response.raise_for_status()
return [types.TextContent(type="text", text=response.text)]