Replace httpx and httpx-sse with httpx2 (#2972)
Co-authored-by: Max Isbey <224885523+maxisbey@users.noreply.github.com>
This commit is contained in:
parent
1216c53693
commit
2713b53b12
4 changed files with 1029 additions and 948 deletions
|
|
@ -1,13 +1,13 @@
|
|||
import httpx
|
||||
import httpx2
|
||||
|
||||
from mcp import Client
|
||||
from mcp.client.streamable_http import streamable_http_client
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
headers={"Authorization": "Bearer ..."},
|
||||
timeout=httpx.Timeout(30.0, read=300.0),
|
||||
timeout=httpx2.Timeout(30.0, read=300.0),
|
||||
follow_redirects=True,
|
||||
) as http_client:
|
||||
transport = streamable_http_client("http://localhost:8000/mcp", http_client=http_client)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import time
|
||||
import uuid
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
import jwt
|
||||
|
||||
from mcp import Client
|
||||
|
|
@ -62,7 +62,7 @@ oauth = IdentityAssertionOAuthProvider(
|
|||
|
||||
|
||||
async def main() -> None:
|
||||
async with httpx.AsyncClient(auth=oauth, follow_redirects=True) as http_client:
|
||||
async with httpx2.AsyncClient(auth=oauth, follow_redirects=True) as http_client:
|
||||
transport = streamable_http_client("http://localhost:8001/mcp", http_client=http_client)
|
||||
async with Client(transport) as client:
|
||||
result = await client.list_tools()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
from pydantic import AnyUrl
|
||||
|
||||
from mcp import Client
|
||||
|
|
@ -55,7 +55,7 @@ oauth = OAuthClientProvider(
|
|||
|
||||
|
||||
async def main() -> None:
|
||||
async with httpx.AsyncClient(auth=oauth, follow_redirects=True) as http_client:
|
||||
async with httpx2.AsyncClient(auth=oauth, follow_redirects=True) as http_client:
|
||||
transport = streamable_http_client("http://localhost:8001/mcp", http_client=http_client)
|
||||
async with Client(transport) as client:
|
||||
result = await client.list_tools()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import httpx
|
||||
import httpx2
|
||||
|
||||
from mcp import Client
|
||||
from mcp.client.auth.extensions.client_credentials import ClientCredentialsOAuthProvider
|
||||
|
|
@ -34,7 +34,7 @@ oauth = ClientCredentialsOAuthProvider(
|
|||
|
||||
|
||||
async def main() -> None:
|
||||
async with httpx.AsyncClient(auth=oauth, follow_redirects=True) as http_client:
|
||||
async with httpx2.AsyncClient(auth=oauth, follow_redirects=True) as http_client:
|
||||
transport = streamable_http_client("http://localhost:8001/mcp", http_client=http_client)
|
||||
async with Client(transport) as client:
|
||||
result = await client.list_tools()
|
||||
|
|
|
|||
Loading…
Reference in a new issue