File tree Expand file tree Collapse file tree 4 files changed +59
-61
lines changed
packages/core/agent_framework
samples/getting_started/mcp Expand file tree Collapse file tree 4 files changed +59
-61
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -145,7 +145,8 @@ ignore = [
145145 " D418" , # allow overload to have a docstring
146146 " TD003" , # allow missing link to todo issue
147147 " FIX002" , # allow todo
148- " B027" # allow empty non-abstract method in ABC
148+ " B027" , # allow empty non-abstract method in ABC
149+ " RUF067" # Allow version in __init__.py
149150]
150151
151152[tool .ruff .lint .per-file-ignores ]
Original file line number Diff line number Diff line change 44
55from agent_framework import ChatAgent , MCPStreamableHTTPTool
66from agent_framework .openai import OpenAIResponsesClient
7+ from httpx import AsyncClient
78
89"""
910MCP 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 (),
You can’t perform that action at this time.
0 commit comments