From 601e024d774f8f75df16c99b9873b1ea9bf61939 Mon Sep 17 00:00:00 2001 From: Yongteng Lei Date: Mon, 16 Jun 2025 16:27:40 +0800 Subject: [PATCH] Docs: add authorization header for MCP server based on OAuth 2.1 (#8293) ### What problem does this PR solve? Add documentation of authorization header for MCP server based on OAuth 2.1 ### Type of change - [x] Documentation Update --------- Co-authored-by: writinwaters <93570324+writinwaters@users.noreply.github.com> --- docs/develop/mcp/mcp_client_example.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/develop/mcp/mcp_client_example.md b/docs/develop/mcp/mcp_client_example.md index 40b38b039..1b6d72514 100644 --- a/docs/develop/mcp/mcp_client_example.md +++ b/docs/develop/mcp/mcp_client_example.md @@ -13,4 +13,10 @@ If your MCP server is running in host mode, include your acquired API key in you async with sse_client("http://localhost:9382/sse", headers={"api_key": "YOUR_KEY_HERE"}) as streams: # Rest of your code... ``` -::: \ No newline at end of file + +Or follow the requirements of [OAuth 2.1 Section 5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5) by providing an Authorization request headers field: +```python +async with sse_client("http://localhost:9382/sse", headers={"Authorization": "YOUR_KEY_HERE"}) as streams: + # Rest of your code... +``` +:::