Skip to content

Commit 02a08fd

Browse files
author
Johan Broberg
committed
Add auth_handler_name parameter to Authorization.exchange_token call
1 parent 18d5219 commit 02a08fd

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async def add_tool_servers_to_agent(
4747
initial_tools: List[Any],
4848
agentic_app_id: str,
4949
auth: Authorization,
50+
auth_handler_name: str,
5051
turn_context: TurnContext,
5152
auth_token: Optional[str] = None,
5253
) -> Optional[ChatAgent]:
@@ -59,6 +60,7 @@ async def add_tool_servers_to_agent(
5960
initial_tools: List of initial tools to add to the agent
6061
agentic_app_id: Agentic app identifier for the agent
6162
auth: Authorization context for token exchange
63+
auth_handler_name: Name of the authorization handler.
6264
turn_context: Turn context for the operation
6365
auth_token: Optional bearer token for authentication
6466
@@ -69,7 +71,7 @@ async def add_tool_servers_to_agent(
6971
# Exchange token if not provided
7072
if not auth_token:
7173
scopes = get_mcp_platform_authentication_scope()
72-
authToken = await auth.exchange_token(turn_context, scopes, "AGENTIC")
74+
authToken = await auth.exchange_token(turn_context, scopes, auth_handler_name)
7375
auth_token = authToken.token
7476

7577
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")

libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ async def add_tool_servers_to_agent(
7171
project_client: "AIProjectClient",
7272
agentic_app_id: str,
7373
auth: Authorization,
74+
auth_handler_name: str,
7475
context: TurnContext,
7576
auth_token: Optional[str] = None,
7677
) -> None:
@@ -80,6 +81,9 @@ async def add_tool_servers_to_agent(
8081
Args:
8182
project_client: The Azure Foundry AIProjectClient instance.
8283
agentic_app_id: Agentic App ID for the agent.
84+
auth: Authorization handler for token exchange.
85+
auth_handler_name: Name of the authorization handler.
86+
context: Turn context for the current operation.
8387
auth_token: Authentication token to access the MCP servers.
8488
8589
Raises:
@@ -91,7 +95,7 @@ async def add_tool_servers_to_agent(
9195

9296
if not auth_token:
9397
scopes = get_mcp_platform_authentication_scope()
94-
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
98+
authToken = await auth.exchange_token(context, scopes, auth_handler_name)
9599
auth_token = authToken.token
96100

97101
try:

libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async def add_tool_servers_to_agent(
5252
agent: Agent,
5353
agentic_app_id: str,
5454
auth: Authorization,
55+
auth_handler_name: str,
5556
context: TurnContext,
5657
auth_token: Optional[str] = None,
5758
):
@@ -65,15 +66,18 @@ async def add_tool_servers_to_agent(
6566
Args:
6667
agent: The existing agent to add servers to
6768
agentic_app_id: Agentic App ID for the agent
68-
auth_token: Authentication token to access the MCP servers
69+
auth: Authorization handler for token exchange.
70+
auth_handler_name: Name of the authorization handler.
71+
context: Turn context for the current operation.
72+
auth_token: Authentication token to access the MCP servers.
6973
7074
Returns:
7175
New Agent instance with all MCP servers, or original agent if no new servers
7276
"""
7377

7478
if not auth_token:
7579
scopes = get_mcp_platform_authentication_scope()
76-
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
80+
authToken = await auth.exchange_token(context, scopes, auth_handler_name)
7781
auth_token = authToken.token
7882

7983
# Get MCP server configurations from the configuration service

libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ async def add_tool_servers_to_agent(
7979
kernel: sk.Kernel,
8080
agentic_app_id: str,
8181
auth: Authorization,
82+
auth_handler_name: str,
8283
context: TurnContext,
8384
auth_token: Optional[str] = None,
8485
) -> None:
@@ -88,6 +89,9 @@ async def add_tool_servers_to_agent(
8889
Args:
8990
kernel: The Semantic Kernel instance to which the tools will be added.
9091
agentic_app_id: Agentic App ID for the agent.
92+
auth: Authorization handler for token exchange.
93+
auth_handler_name: Name of the authorization handler.
94+
context: Turn context for the current operation.
9195
auth_token: Authentication token to access the MCP servers.
9296
9397
Raises:
@@ -97,7 +101,7 @@ async def add_tool_servers_to_agent(
97101

98102
if not auth_token:
99103
scopes = get_mcp_platform_authentication_scope()
100-
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
104+
authToken = await auth.exchange_token(context, scopes, auth_handler_name)
101105
auth_token = authToken.token
102106

103107
self._validate_inputs(kernel, agentic_app_id, auth_token)

0 commit comments

Comments
 (0)