Docs: add example of more concise way to use bearer auth (#1055)

This commit is contained in:
Neil Conway 2025-07-06 16:26:02 +02:00 committed by GitHub
commit fe1eddc252
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -88,6 +88,18 @@ transport = StreamableHttpTransport(
client = Client(transport)
```
This can be written more concisely using the `BearerAuth` helper function:
```python
from fastmcp import Client
from fastmcp.client.auth import BearerAuth
client = Client(
"https://example.com/mcp",
auth=BearerAuth("your-token-here"),
)
```
### SSE (Server-Sent Events)
<VersionBadge version="2.0.0" />
@ -434,4 +446,4 @@ If your configuration has only a single server, the client will connect directly
<Note>
The MCPConfig format is an emerging standard for MCP server configuration and may change as the MCP ecosystem evolves. While FastMCP aims to maintain compatibility with future versions, be aware that field names or structure might change.
</Note>
</Note>