Skip to content

Commit a35b89d

Browse files
udpated samples with headers examples
1 parent 0888069 commit a35b89d

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

python/packages/core/agent_framework/_mcp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,6 @@ class MCPStreamableHTTPTool(MCPTool):
898898
mcp_tool = MCPStreamableHTTPTool(
899899
name="web-api",
900900
url="https://api.example.com/mcp",
901-
headers={"Authorization": "Bearer token"},
902901
description="Web API operations",
903902
)
904903

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ ignore = [
146146
"TD003", # allow missing link to todo issue
147147
"FIX002", # allow todo
148148
"B027", # allow empty non-abstract method in ABC
149-
"RUF067", # allow version detection in __init__.py
149+
"RUF067" # Allow version in __init__.py
150150
]
151151

152152
[tool.ruff.lint.per-file-ignores]

python/samples/getting_started/mcp/mcp_api_key_auth.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from agent_framework import ChatAgent, MCPStreamableHTTPTool
66
from agent_framework.openai import OpenAIResponsesClient
7+
from httpx import AsyncClient
78

89
"""
910
MCP Authentication Example
@@ -31,13 +32,16 @@ async def api_key_auth_example() -> None:
3132
"Authorization": f"Bearer {api_key}",
3233
}
3334

34-
# Create MCP tool with authentication headers
35+
# Create HTTP client with authentication headers
36+
http_client = AsyncClient(headers=auth_headers)
37+
38+
# Create MCP tool with the configured HTTP client
3539
async with (
3640
MCPStreamableHTTPTool(
3741
name="MCP tool",
3842
description="MCP tool description",
3943
url=mcp_server_url,
40-
headers=auth_headers, # Authentication headers
44+
http_client=http_client, # Pass HTTP client with authentication headers
4145
) as mcp_tool,
4246
ChatAgent(
4347
chat_client=OpenAIResponsesClient(),

0 commit comments

Comments
 (0)