Skip to content

Commit cf40ca7

Browse files
committed
docs(session-groups): add asyncio runner to auth example
1 parent 84e6778 commit cf40ca7

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎docs/client/session-groups.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ If you already hold a connected `ClientSession` (`Client.session` is one), hand
7575
When connecting to HTTP servers using `StreamableHttpParameters` or `SseServerParameters`, you can configure an authentication provider (such as an OAuth 2.0 `OAuthClientProvider` or custom `httpx2.Auth` handler) via the `auth=` parameter:
7676

7777
```python
78+
import asyncio
79+
7880
from mcp.client.auth import OAuthClientProvider
7981
from mcp.client.session_group import ClientSessionGroup, StreamableHttpParameters
8082

@@ -95,6 +97,10 @@ async def main() -> None:
9597

9698
async with ClientSessionGroup() as group:
9799
await group.connect_to_server(server_params)
100+
101+
102+
if __name__ == "__main__":
103+
asyncio.run(main())
98104
```
99105

100106
Because `auth` is configured per `ServerParameters` instance, each server in the session group maintains independent authentication context, scopes, and token-refresh lifecycle. Custom headers can still be supplied alongside `auth` via `headers=`.

‎src/mcp/client/session_group.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class StreamableHttpParameters(BaseModel):
7676
auth: httpx2.Auth | None = Field(default=None, description="Optional HTTPX authentication handler.", exclude=True)
7777

7878

79-
8079
ServerParameters: TypeAlias = StdioServerParameters | SseServerParameters | StreamableHttpParameters
8180

8281

0 commit comments

Comments
 (0)