Spaces:
Running
Running
Merge pull request #809 from jlowin/welcome
Browse files
docs/clients/auth/bearer.mdx
CHANGED
|
@@ -73,14 +73,17 @@ async with Client(
|
|
| 73 |
|
| 74 |
## Custom Headers
|
| 75 |
|
| 76 |
-
If the MCP server expects a custom header or token scheme, you can manually set the client's `headers` instead of using the `auth` parameter:
|
| 77 |
|
| 78 |
```python {5}
|
| 79 |
from fastmcp import Client
|
|
|
|
| 80 |
|
| 81 |
async with Client(
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
| 84 |
) as client:
|
| 85 |
await client.ping()
|
| 86 |
```
|
|
|
|
| 73 |
|
| 74 |
## Custom Headers
|
| 75 |
|
| 76 |
+
If the MCP server expects a custom header or token scheme, you can manually set the client's `headers` instead of using the `auth` parameter by setting them on your transport:
|
| 77 |
|
| 78 |
```python {5}
|
| 79 |
from fastmcp import Client
|
| 80 |
+
from fastmcp.client.transports import StreamableHttpTransport
|
| 81 |
|
| 82 |
async with Client(
|
| 83 |
+
transport=StreamableHttpTransport(
|
| 84 |
+
"https://fastmcp.cloud/mcp",
|
| 85 |
+
headers={"X-API-Key": "<your-token>"},
|
| 86 |
+
),
|
| 87 |
) as client:
|
| 88 |
await client.ping()
|
| 89 |
```
|