Skip to content

Commit 4e69837

Browse files
author
Jesus Terrazas
committed
Add tool options
1 parent d8018e1 commit 4e69837

File tree

7 files changed

+42
-14
lines changed

7 files changed

+42
-14
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from microsoft_agents_a365.tooling.services.mcp_tool_server_configuration_service import (
1414
McpToolServerConfigurationService,
1515
)
16+
from microsoft_agents_a365.tooling.models import ToolOptions
1617
from microsoft_agents_a365.tooling.utils.constants import Constants
1718

1819
from microsoft_agents_a365.tooling.utils.utility import (
@@ -79,11 +80,13 @@ async def add_tool_servers_to_agent(
7980

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

83+
options = ToolOptions(orchestrator_name=self._orchestrator_name)
84+
8285
# Get MCP server configurations
8386
server_configs = await self._mcp_server_configuration_service.list_tool_servers(
8487
agentic_app_id=agentic_app_id,
8588
auth_token=auth_token,
86-
orchestrator_name=self._orchestrator_name,
89+
options=options,
8790
)
8891

8992
self._logger.info(f"Loaded {len(server_configs)} MCP server configurations")

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from microsoft_agents_a365.tooling.services.mcp_tool_server_configuration_service import (
2222
McpToolServerConfigurationService,
2323
)
24+
from microsoft_agents_a365.tooling.Models import ToolOptions
2425
from microsoft_agents_a365.tooling.utils.constants import Constants
2526
from microsoft_agents_a365.tooling.utils.utility import get_mcp_platform_authentication_scope
2627

@@ -141,9 +142,10 @@ async def _get_mcp_tool_definitions_and_resources(
141142
return ([], None)
142143

143144
# Get MCP server configurations
145+
options = ToolOptions(orchestrator_name=self._orchestrator_name)
144146
try:
145147
servers = await self._mcp_server_configuration_service.list_tool_servers(
146-
agentic_app_id, auth_token, self._orchestrator_name
148+
agentic_app_id, auth_token, options
147149
)
148150
except Exception as ex:
149151
self._logger.error(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
McpToolServerConfigurationService,
1818
)
1919

20+
from microsoft_agents_a365.tooling.models import ToolOptions
2021
from microsoft_agents_a365.tooling.utils.constants import Constants
2122
from microsoft_agents_a365.tooling.utils.utility import (
2223
get_mcp_platform_authentication_scope,
@@ -86,12 +87,13 @@ async def add_tool_servers_to_agent(
8687
# mcp_server_configs = []
8788
# TODO: radevika: Update once the common project is merged.
8889

90+
options = ToolOptions(orchestrator_name=self._orchestrator_name)
8991
agentic_app_id = Utility.resolve_agent_identity(context, auth_token)
9092
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")
9193
mcp_server_configs = await self.config_service.list_tool_servers(
9294
agentic_app_id=agentic_app_id,
9395
auth_token=auth_token,
94-
orchestrator_name=self._orchestrator_name,
96+
options=options,
9597
)
9698

9799
self._logger.info(f"Loaded {len(mcp_server_configs)} MCP server configurations")

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from microsoft_agents_a365.tooling.services.mcp_tool_server_configuration_service import (
2121
McpToolServerConfigurationService,
2222
)
23-
from microsoft_agents_a365.tooling.models.mcp_server_config import MCPServerConfig
23+
from microsoft_agents_a365.tooling.models import MCPServerConfig, ToolOptions
2424
from microsoft_agents_a365.tooling.utils.constants import Constants
2525
from microsoft_agents_a365.tooling.utils.utility import (
2626
get_tools_mode,
@@ -109,8 +109,9 @@ async def add_tool_servers_to_agent(
109109
self._validate_inputs(kernel, agentic_app_id, auth_token)
110110

111111
# Get and process servers
112+
options = ToolOptions(orchestrator_name=self._orchestrator_name)
112113
servers = await self._mcp_server_configuration_service.list_tool_servers(
113-
agentic_app_id, auth_token, self._orchestrator_name
114+
agentic_app_id, auth_token, options
114115
)
115116
self._logger.info(f"🔧 Adding MCP tools from {len(servers)} servers")
116117

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
from .mcp_server_config import MCPServerConfig
1010

11-
__all__ = ["MCPServerConfig"]
11+
__all__ = ["MCPServerConfig", "ToolOptions"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) Microsoft. All rights reserved.
2+
3+
"""
4+
Tooling Options model.
5+
"""
6+
7+
from dataclasses import dataclass
8+
from typing import Optional
9+
10+
11+
@dataclass
12+
class ToolOptions:
13+
"""Configuration options for tooling operations."""
14+
15+
#: Gets or sets the name of the orchestrator.
16+
orchestrator_name: Optional[str]

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import aiohttp
2929

3030
# Local imports
31-
from ..models import MCPServerConfig
31+
from ..models import MCPServerConfig, ToolOptions
3232
from ..utils import Constants
3333
from ..utils.utility import get_tooling_gateway_for_digital_worker, build_mcp_server_url
3434

@@ -69,15 +69,15 @@ def __init__(self, logger: Optional[logging.Logger] = None):
6969
# --------------------------------------------------------------------------
7070

7171
async def list_tool_servers(
72-
self, agentic_app_id: str, auth_token: str, orchestrator_name: Optional[str] = None
72+
self, agentic_app_id: str, auth_token: str, options: Optional[ToolOptions] = None
7373
) -> List[MCPServerConfig]:
7474
"""
7575
Gets the list of MCP Servers that are configured for the agent.
7676
7777
Args:
7878
agentic_app_id: Agentic App ID for the agent.
7979
auth_token: Authentication token to access the MCP servers.
80-
orchestrator_name: Optional orchestrator name to include in User-Agent header.
80+
options: Optional ToolOptions instance containing optional parameters.
8181
8282
Returns:
8383
List[MCPServerConfig]: Returns the list of MCP Servers that are configured.
@@ -89,14 +89,18 @@ async def list_tool_servers(
8989
# Validate input parameters
9090
self._validate_input_parameters(agentic_app_id, auth_token)
9191

92+
# Use default options if none provided
93+
if options is None:
94+
options = ToolOptions(orchestrator_name=None)
95+
9296
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")
9397

9498
# Determine configuration source based on environment
9599
if self._is_development_scenario():
96100
return self._load_servers_from_manifest()
97101
else:
98102
return await self._load_servers_from_gateway(
99-
agentic_app_id, auth_token, orchestrator_name
103+
agentic_app_id, auth_token, options
100104
)
101105

102106
# --------------------------------------------------------------------------
@@ -281,7 +285,7 @@ def _log_manifest_search_failure(self) -> None:
281285
# --------------------------------------------------------------------------
282286

283287
async def _load_servers_from_gateway(
284-
self, agentic_app_id: str, auth_token: str, orchestrator_name: Optional[str] = None
288+
self, agentic_app_id: str, auth_token: str, options: ToolOptions
285289
) -> List[MCPServerConfig]:
286290
"""
287291
Reads MCP server configurations from tooling gateway endpoint for production scenario.
@@ -301,7 +305,7 @@ async def _load_servers_from_gateway(
301305

302306
try:
303307
config_endpoint = get_tooling_gateway_for_digital_worker(agentic_app_id)
304-
headers = self._prepare_gateway_headers(auth_token, orchestrator_name)
308+
headers = self._prepare_gateway_headers(auth_token, options)
305309

306310
self._logger.info(f"Calling tooling gateway endpoint: {config_endpoint}")
307311

@@ -331,7 +335,7 @@ async def _load_servers_from_gateway(
331335
return mcp_servers
332336

333337
def _prepare_gateway_headers(
334-
self, auth_token: str, orchestrator_name: Optional[str] = None
338+
self, auth_token: str, options: ToolOptions
335339
) -> Dict[str, str]:
336340
"""
337341
Prepares headers for tooling gateway requests.
@@ -345,7 +349,7 @@ def _prepare_gateway_headers(
345349
"""
346350
return {
347351
Constants.Headers.AUTHORIZATION: f"{Constants.Headers.BEARER_PREFIX} {auth_token}",
348-
Constants.Headers.USER_AGENT: RuntimeUtility.get_user_agent_header(orchestrator_name),
352+
Constants.Headers.USER_AGENT: RuntimeUtility.get_user_agent_header(options.orchestrator_name),
349353
}
350354

351355
async def _parse_gateway_response(

0 commit comments

Comments
 (0)