From 305200a92bd99d1d2c30f88fa9b9460b9af7b0af Mon Sep 17 00:00:00 2001 From: Mackenzie Zastrow Date: Wed, 27 Aug 2025 15:22:16 -0400 Subject: [PATCH 1/2] feat(mcp): Add info about setting auth & headers As we've gotten a couple questions about it --- docs/user-guide/concepts/tools/mcp-tools.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/user-guide/concepts/tools/mcp-tools.md b/docs/user-guide/concepts/tools/mcp-tools.md index bee7975c..dd59df38 100644 --- a/docs/user-guide/concepts/tools/mcp-tools.md +++ b/docs/user-guide/concepts/tools/mcp-tools.md @@ -75,6 +75,16 @@ with streamable_http_mcp_client: agent = Agent(tools=tools) ``` +You can configure additional properties - like authentication and headers - when creating the `streamablehttp_client`. All configuration options from the [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) are supported: + +```python +streamable_http_mcp_client = MCPClient(lambda: streamablehttp_client( + "http://localhost:8000/mcp", + auth=oauth_auth, # instance of httpx.Auth + headers={"X-Agent-Framework": "Strands"}, +)) +``` + ### 3. Server-Sent Events (SSE) For HTTP-based MCP servers that use Server-Sent Events transport: From a2cb68405819bb7b373f988a67e089e51c76de4b Mon Sep 17 00:00:00 2001 From: Mackenzie Zastrow Date: Thu, 28 Aug 2025 10:44:29 -0400 Subject: [PATCH 2/2] Switch to real header example --- docs/user-guide/concepts/tools/mcp-tools.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/user-guide/concepts/tools/mcp-tools.md b/docs/user-guide/concepts/tools/mcp-tools.md index dd59df38..1bb89794 100644 --- a/docs/user-guide/concepts/tools/mcp-tools.md +++ b/docs/user-guide/concepts/tools/mcp-tools.md @@ -78,11 +78,17 @@ with streamable_http_mcp_client: You can configure additional properties - like authentication and headers - when creating the `streamablehttp_client`. All configuration options from the [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) are supported: ```python -streamable_http_mcp_client = MCPClient(lambda: streamablehttp_client( - "http://localhost:8000/mcp", - auth=oauth_auth, # instance of httpx.Auth - headers={"X-Agent-Framework": "Strands"}, -)) +import os +from strands.tools.mcp.mcp_client import MCPClient +from mcp.client.streamable_http import streamablehttp_client + +github_http_mcp_client = MCPClient( + lambda: streamablehttp_client( + url="https://api.githubcopilot.com/mcp/", + # Get pat token from here: https://github.com/settings/personal-access-tokens + headers={"Authorization": f"Bearer {os.getenv('MCP_PAT')}"} + ) +) ``` ### 3. Server-Sent Events (SSE)