From fe1eddc25240c31d857b35422dfafa13bb12c682 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Sun, 6 Jul 2025 16:26:02 +0200 Subject: [PATCH] Docs: add example of more concise way to use bearer auth (#1055) --- docs/clients/transports.mdx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/clients/transports.mdx b/docs/clients/transports.mdx index d02aaf6f2..61939fa5d 100644 --- a/docs/clients/transports.mdx +++ b/docs/clients/transports.mdx @@ -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) @@ -434,4 +446,4 @@ If your configuration has only a single server, the client will connect directly 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. - \ No newline at end of file +