From 1942d4f69644f1e5544258050f59249e1caba966 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 08:04:34 -0800 Subject: [PATCH 1/8] Update get_tooling_gateway_for_digital_worker Also get the platform scope from env similar to dotnet sdk. --- .../microsoft_agents_a365/tooling/utils/utility.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py index b9d07ab7..69997018 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py @@ -33,7 +33,7 @@ def get_tooling_gateway_for_digital_worker(agent_user_id: str) -> str: str: The tooling gateway URL for the digital worker. """ # The endpoint needs to be updated based on the environment (prod, dev, etc.) - return f"{_get_mcp_platform_base_url()}/agentGateway/agentApplicationInstances/{agent_user_id}/mcpServers" + return f"{_get_mcp_platform_base_url()}/agents/{agent_user_id}/mcpServers" def get_mcp_base_url() -> str: @@ -136,6 +136,11 @@ def get_ppapi_token_scope(): """ environment = _get_current_environment().lower() + envScope = os.getenv("MCP_PLATFORM_AUTHENTICATION_SCOPE", "") + + if envScope: + return envScope; + if environment == "development": return [PPAPI_TEST_TOKEN_SCOPE + "/.default"] else: From e9928ddb899fcb8bad933a5720c234bfc13eec00 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 08:24:24 -0800 Subject: [PATCH 2/8] Fix formating issue. --- .../microsoft_agents_a365/tooling/utils/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py index 69997018..2e1d4289 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py @@ -139,7 +139,7 @@ def get_ppapi_token_scope(): envScope = os.getenv("MCP_PLATFORM_AUTHENTICATION_SCOPE", "") if envScope: - return envScope; + return envScope if environment == "development": return [PPAPI_TEST_TOKEN_SCOPE + "/.default"] From 22267ccfa7f888a83df68e5e1b474c4d62dd1597 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 08:45:32 -0800 Subject: [PATCH 3/8] Fix review comment. --- .../microsoft_agents_a365/tooling/utils/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py index 2e1d4289..6a295a4b 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py @@ -139,7 +139,7 @@ def get_ppapi_token_scope(): envScope = os.getenv("MCP_PLATFORM_AUTHENTICATION_SCOPE", "") if envScope: - return envScope + return [envScope] if environment == "development": return [PPAPI_TEST_TOKEN_SCOPE + "/.default"] From 85ae734251ba23796f2090a4c77b4f9ef8323096 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 12:24:06 -0800 Subject: [PATCH 4/8] Refactor agent_user_id to agent_instance_id Replaced `agent_user_id` with `agent_instance_id` across the codebase to standardize the unique identifier for agents. Updated method signatures, arguments, logging, and validation logic to reflect this change. Aligned token scope handling with the new authentication mechanism by replacing `get_ppapi_token_scope` with `get_mcp_platform_authentication_scope`. Removed legacy token scopes and updated constants accordingly. Modified tooling gateway URL generation to use `agent_instance_id`. Updated documentation, examples, and logging to ensure consistency with the new identifier. --- .../README.md | 6 ++--- .../services/mcp_tool_registration_service.py | 8 +++---- .../services/mcp_tool_registration_service.py | 24 +++++++++---------- .../README.md | 2 +- .../openai/mcp_tool_registration_service.py | 12 +++++----- .../README.md | 2 +- .../services/mcp_tool_registration_service.py | 18 +++++++------- .../microsoft-agents-a365-tooling/README.md | 2 +- .../mcp_tool_server_configuration_service.py | 24 +++++++++---------- .../tooling/utils/__init__.py | 4 ++-- .../tooling/utils/utility.py | 20 +++++++--------- 11 files changed, 59 insertions(+), 63 deletions(-) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md index 7d98d56a..5c583876 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md +++ b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md @@ -82,7 +82,7 @@ async def main(): chat_client=chat_client, agent_instructions="You are a helpful assistant that can provide weather and restaurant information.", initial_tools=[], # Your existing tools - agent_user_id="user-123", + agent_instance_id="user-123", environment_id="prod", auth_token="your-auth-token" ) @@ -139,7 +139,7 @@ async def main(): loaded from configured servers. Use these tools to enhance your capabilities. """, initial_tools=existing_tools, - agent_user_id="user-123", + agent_instance_id="user-123", environment_id="production", auth_token="your-auth-token" ) @@ -190,7 +190,7 @@ agent = await service.add_tool_servers_to_agent( chat_client=chat_client, agent_instructions="You are a helpful assistant with access to various tools.", initial_tools=[], # Your existing tools - agent_user_id="user-123", + agent_instance_id="user-123", environment_id="prod", auth_token="your-token" ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py index 50237f6b..a64dd928 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py @@ -41,7 +41,7 @@ async def add_tool_servers_to_agent( chat_client: Union[OpenAIChatClient, AzureOpenAIChatClient], agent_instructions: str, initial_tools: List[Any], - agent_user_id: str, + agent_instance_id: str, environment_id: str, auth: Optional[Authorization] = None, auth_token: Optional[str] = None, @@ -54,7 +54,7 @@ async def add_tool_servers_to_agent( chat_client: The chat client instance (Union[OpenAIChatClient, AzureOpenAIChatClient]) agent_instructions: Instructions for the agent behavior initial_tools: List of initial tools to add to the agent - agent_user_id: Unique identifier for the agent user + agent_instance_id: Unique identifier for the agent instance environment_id: Environment identifier for MCP server discovery auth: Optional authorization context auth_token: Optional bearer token for authentication @@ -65,12 +65,12 @@ async def add_tool_servers_to_agent( """ try: self._logger.info( - f"Listing MCP tool servers for agent {agent_user_id} in environment {environment_id}" + f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" ) # Get MCP server configurations server_configs = await self._mcp_server_configuration_service.list_tool_servers( - agent_user_id=agent_user_id, + agent_instance_id=agent_instance_id, environment_id=environment_id, auth_token=auth_token, ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py index 18f213cc..66571870 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py @@ -18,7 +18,7 @@ from azure.ai.agents.models import McpTool, ToolResources from microsoft_agents.hosting.core import Authorization, TurnContext -from ...common.utils.utility import get_ppapi_token_scope, get_use_environment_id +from ...common.utils.utility import get_mcp_platform_authentication_scope, get_use_environment_id # Local imports from microsoft_kairo.tooling.common.services.mcp_tool_server_configuration_service import ( @@ -72,7 +72,7 @@ def __init__( async def add_tool_servers_to_agent( self, project_client: "AIProjectClient", - agent_user_id: str, + agent_instance_id: str, environment_id: str, auth: Authorization, context: TurnContext, @@ -83,7 +83,7 @@ async def add_tool_servers_to_agent( Args: project_client: The Azure Foundry AIProjectClient instance. - agent_user_id: Agent User ID for the agent. + agent_instance_id: Agent Instance ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -95,19 +95,19 @@ async def add_tool_servers_to_agent( raise ValueError("project_client cannot be None") if not auth_token: - scopes = get_ppapi_token_scope() + scopes = get_mcp_platform_authentication_scope() authToken = await auth.exchange_token(context, scopes, "AGENTIC") auth_token = authToken.token try: # Get the tool definitions and resources using the async implementation tool_definitions, tool_resources = await self._get_mcp_tool_definitions_and_resources( - agent_user_id, environment_id, auth_token or "" + agent_instance_id, environment_id, auth_token or "" ) # Update the agent with the tools project_client.agents.update_agent( - agent_user_id, tools=tool_definitions, tool_resources=tool_resources + agent_instance_id, tools=tool_definitions, tool_resources=tool_resources ) self._logger.info( @@ -116,12 +116,12 @@ async def add_tool_servers_to_agent( except Exception as ex: self._logger.error( - f"Unhandled failure during MCP tool registration workflow for agent user {agent_user_id}: {ex}" + f"Unhandled failure during MCP tool registration workflow for agent user {agent_instance_id}: {ex}" ) raise async def _get_mcp_tool_definitions_and_resources( - self, agent_user_id: str, environment_id: str, auth_token: str + self, agent_instance_id: str, environment_id: str, auth_token: str ) -> Tuple[List[McpTool], Optional[ToolResources]]: """ Internal method to get MCP tool definitions and resources. @@ -129,7 +129,7 @@ async def _get_mcp_tool_definitions_and_resources( This implements the core logic equivalent to the C# method of the same name. Args: - agent_user_id: Agent User ID for the agent. + agent_instance_id: Agent Instance ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -143,17 +143,17 @@ async def _get_mcp_tool_definitions_and_resources( # Get MCP server configurations try: servers = await self._mcp_server_configuration_service.list_tool_servers( - agent_user_id, environment_id, auth_token + agent_instance_id, environment_id, auth_token ) except Exception as ex: self._logger.error( - f"Failed to list MCP tool servers for AgentUserId={agent_user_id}: {ex}" + f"Failed to list MCP tool servers for AgentInstanceId={agent_instance_id}: {ex}" ) return ([], None) if len(servers) == 0: self._logger.info( - f"No MCP servers configured for AgentUserId={agent_user_id}, EnvironmentId={environment_id}" + f"No MCP servers configured for AgentInstanceId={agent_instance_id}, EnvironmentId={environment_id}" ) return ([], None) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md b/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md index 5198f310..60844226 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md +++ b/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md @@ -53,7 +53,7 @@ registration_service = McpToolRegistrationService() # Add MCP tool servers to your OpenAI agent await registration_service.add_tool_servers_to_agent( agent=your_openai_agent, - agent_user_id="user-123", + agent_instance_id="user-123", environment_id="prod", auth=authorization_context, context=turn_context, diff --git a/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py index 206459fc..1b62f1fb 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py @@ -17,7 +17,7 @@ ) from microsoft_agents_a365.tooling.utils.utility import ( - get_ppapi_token_scope, + get_mcp_platform_authentication_scope, get_use_environment_id, ) @@ -51,7 +51,7 @@ def __init__(self, logger: Optional[logging.Logger] = None): async def add_tool_servers_to_agent( self, agent: Agent, - agent_user_id: str, + agent_instance_id: str, environment_id: str, auth: Authorization, context: TurnContext, @@ -66,7 +66,7 @@ async def add_tool_servers_to_agent( Args: agent: The existing agent to add servers to - agent_user_id: Agent User ID for the agent + agent_instance_id: Agent Instance ID for the agent environment_id: Environment ID for the environment auth_token: Authentication token to access the MCP servers @@ -75,7 +75,7 @@ async def add_tool_servers_to_agent( """ if not auth_token: - scopes = get_ppapi_token_scope() + scopes = get_mcp_platform_authentication_scope() authToken = await auth.exchange_token(context, scopes, "AGENTIC") auth_token = authToken.token @@ -83,10 +83,10 @@ async def add_tool_servers_to_agent( # mcp_server_configs = [] # TODO: radevika: Update once the common project is merged. self._logger.info( - f"Listing MCP tool servers for agent {agent_user_id} in environment {environment_id}" + f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" ) mcp_server_configs = await self.config_service.list_tool_servers( - agent_user_id=agent_user_id, environment_id=environment_id, auth_token=auth_token + agent_instance_id=agent_instance_id, environment_id=environment_id, auth_token=auth_token ) self._logger.info(f"Loaded {len(mcp_server_configs)} MCP server configurations") diff --git a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md index 58b72af5..e6f787b5 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md +++ b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md @@ -55,7 +55,7 @@ registration_service = McpToolRegistrationService() # Add MCP tool servers to your Semantic Kernel await registration_service.add_tool_servers_to_kernel( kernel=kernel, - agent_user_id="user-123", + agent_instance_id="user-123", environment_id="prod", auth_token="your-auth-token" ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py index 3d7b0ddd..3c1db93c 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py @@ -24,7 +24,7 @@ ) from ...common.models import MCPServerConfig from ...common.utils.constants import Constants -from ...common.utils.utility import get_tools_mode, get_ppapi_token_scope, get_use_environment_id +from ...common.utils.utility import get_tools_mode, get_mcp_platform_authentication_scope, get_use_environment_id from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin @@ -80,7 +80,7 @@ def __init__( async def add_tool_servers_to_agent( self, kernel: sk.Kernel, - agent_user_id: str, + agent_instance_id: str, environment_id: str, auth: Authorization, context: TurnContext, @@ -91,7 +91,7 @@ async def add_tool_servers_to_agent( Args: kernel: The Semantic Kernel instance to which the tools will be added. - agent_user_id: Agent User ID for the agent. + agent_instance_id: Agent Instance ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -101,15 +101,15 @@ async def add_tool_servers_to_agent( """ if not auth_token: - scopes = get_ppapi_token_scope() + scopes = get_mcp_platform_authentication_scope() authToken = await auth.exchange_token(context, scopes, "AGENTIC") auth_token = authToken.token - self._validate_inputs(kernel, agent_user_id, environment_id, auth_token) + self._validate_inputs(kernel, agent_instance_id, environment_id, auth_token) # Get and process servers servers = await self._mcp_server_configuration_service.list_tool_servers( - agent_user_id, environment_id, auth_token + agent_instance_id, environment_id, auth_token ) self._logger.info(f"🔧 Adding MCP tools from {len(servers)} servers") @@ -174,13 +174,13 @@ async def add_tool_servers_to_agent( # ============================================================================ def _validate_inputs( - self, kernel: Any, agent_user_id: str, environment_id: str, auth_token: str + self, kernel: Any, agent_instance_id: str, environment_id: str, auth_token: str ) -> None: """Validate all required inputs.""" if kernel is None: raise ValueError("kernel cannot be None") - if not agent_user_id or not agent_user_id.strip(): - raise ValueError("agent_user_id cannot be null or empty") + if not agent_instance_id or not agent_instance_id.strip(): + raise ValueError("agent_instance_id cannot be null or empty") if not environment_id or not environment_id.strip(): raise ValueError("environment_id cannot be null or empty") if not auth_token or not auth_token.strip(): diff --git a/libraries/microsoft-agents-a365-tooling/README.md b/libraries/microsoft-agents-a365-tooling/README.md index 2392d33b..6909b5ea 100644 --- a/libraries/microsoft-agents-a365-tooling/README.md +++ b/libraries/microsoft-agents-a365-tooling/README.md @@ -58,7 +58,7 @@ mcp_config = MCPServerConfig( # Use configuration service to list available MCP servers config_service = McpToolServerConfigurationService() mcp_servers = await config_service.list_tool_servers( - agent_user_id="agent-123", + agent_instance_id="agent-123", environment_id="prod", auth_token="your-auth-token" ) diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py index a8a4b58c..e7657230 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py @@ -70,13 +70,13 @@ def __init__(self, logger: Optional[logging.Logger] = None): # -------------------------------------------------------------------------- async def list_tool_servers( - self, agent_user_id: str, environment_id: str, auth_token: str + self, agent_instance_id: str, environment_id: str, auth_token: str ) -> List[MCPServerConfig]: """ Gets the list of MCP Servers that are configured for the agent. Args: - agent_user_id: Agent User ID for the agent. + agent_instance_id: Agent Instance ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -88,17 +88,17 @@ async def list_tool_servers( Exception: If there's an error communicating with the tooling gateway. """ # Validate input parameters - self._validate_input_parameters(agent_user_id, environment_id, auth_token) + self._validate_input_parameters(agent_instance_id, environment_id, auth_token) self._logger.info( - f"Listing MCP tool servers for agent {agent_user_id} in environment {environment_id}" + f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" ) # Determine configuration source based on environment if self._is_development_scenario(): return self._load_servers_from_manifest(environment_id) else: - return await self._load_servers_from_gateway(agent_user_id, environment_id, auth_token) + return await self._load_servers_from_gateway(agent_instance_id, environment_id, auth_token) # -------------------------------------------------------------------------- # ENVIRONMENT DETECTION @@ -290,13 +290,13 @@ def _log_manifest_search_failure(self) -> None: # -------------------------------------------------------------------------- async def _load_servers_from_gateway( - self, agent_user_id: str, environment_id: str, auth_token: str + self, agent_instance_id: str, environment_id: str, auth_token: str ) -> List[MCPServerConfig]: """ Reads MCP server configurations from tooling gateway endpoint for production scenario. Args: - agent_user_id: Agent User ID for the agent. + agent_instance_id: Agent Instance ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the tooling gateway. @@ -309,7 +309,7 @@ async def _load_servers_from_gateway( mcp_servers: List[MCPServerConfig] = [] try: - config_endpoint = get_tooling_gateway_for_digital_worker(agent_user_id) + config_endpoint = get_tooling_gateway_for_digital_worker(agent_instance_id) headers = self._prepare_gateway_headers(auth_token, environment_id) self._logger.info(f"Calling tooling gateway endpoint: {config_endpoint}") @@ -445,21 +445,21 @@ def _parse_gateway_server_config( # -------------------------------------------------------------------------- def _validate_input_parameters( - self, agent_user_id: str, environment_id: str, auth_token: str + self, agent_instance_id: str, environment_id: str, auth_token: str ) -> None: """ Validates input parameters for the main API method. Args: - agent_user_id: Agent User ID to validate. + agent_instance_id: Agent Instance ID to validate. environment_id: Environment ID to validate. auth_token: Authentication token to validate. Raises: ValueError: If any parameter is invalid or empty. """ - if not agent_user_id: - raise ValueError("agent_user_id cannot be empty or None") + if not agent_instance_id: + raise ValueError("agent_instance_id cannot be empty or None") if not environment_id: raise ValueError("environment_id cannot be empty or None") if not auth_token: diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/__init__.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/__init__.py index 168c0883..d157bb1a 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/__init__.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/__init__.py @@ -10,7 +10,7 @@ get_mcp_base_url, build_mcp_server_url, get_tools_mode, - get_ppapi_token_scope, + get_mcp_platform_authentication_scope, ) __all__ = [ @@ -19,5 +19,5 @@ "get_mcp_base_url", "build_mcp_server_url", "get_tools_mode", - "get_ppapi_token_scope", + "get_mcp_platform_authentication_scope", ] diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py index 6a295a4b..538ae411 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py @@ -19,21 +19,20 @@ class ToolsMode(Enum): MCP_PLATFORM_PROD_BASE_URL = "https://agent365.svc.cloud.microsoft" PPAPI_TOKEN_SCOPE = "https://api.powerplatform.com" -PPAPI_TEST_TOKEN_SCOPE = "https://api.test.powerplatform.com" +PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = "ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default" - -def get_tooling_gateway_for_digital_worker(agent_user_id: str) -> str: +def get_tooling_gateway_for_digital_worker(agent_instance_id: str) -> str: """ Gets the tooling gateway URL for the specified digital worker. Args: - agent_user_id: The unique identifier of the digital worker. + agent_instance_id: The unique identifier of the digital worker. Returns: str: The tooling gateway URL for the digital worker. """ # The endpoint needs to be updated based on the environment (prod, dev, etc.) - return f"{_get_mcp_platform_base_url()}/agents/{agent_user_id}/mcpServers" + return f"{_get_mcp_platform_base_url()}/agents/{agent_instance_id}/mcpServers" def get_mcp_base_url() -> str: @@ -127,12 +126,12 @@ def get_tools_mode() -> ToolsMode: return ToolsMode.MCP_PLATFORM -def get_ppapi_token_scope(): +def get_mcp_platform_authentication_scope(): """ - Gets the PPAI token scope based on the current environment. + Gets the MCP platform authentication scope based on the current environment. Returns: - list: A list containing the appropriate PPAI token scope. + list: A list containing the appropriate MCP platform authentication scope. """ environment = _get_current_environment().lower() @@ -141,7 +140,4 @@ def get_ppapi_token_scope(): if envScope: return [envScope] - if environment == "development": - return [PPAPI_TEST_TOKEN_SCOPE + "/.default"] - else: - return [PPAPI_TOKEN_SCOPE + "/.default"] + return [PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE] From bc74bb6cb5932df292c31d341f4e4d56ab9c9abb Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 12:34:06 -0800 Subject: [PATCH 5/8] Fixed formatting issues that cause CI pipeline failures. --- .../extensions/openai/mcp_tool_registration_service.py | 4 +++- .../services/mcp_tool_registration_service.py | 6 +++++- .../services/mcp_tool_server_configuration_service.py | 4 +++- .../microsoft_agents_a365/tooling/utils/utility.py | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py index 1b62f1fb..5d56d7e8 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py @@ -86,7 +86,9 @@ async def add_tool_servers_to_agent( f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" ) mcp_server_configs = await self.config_service.list_tool_servers( - agent_instance_id=agent_instance_id, environment_id=environment_id, auth_token=auth_token + agent_instance_id=agent_instance_id, + environment_id=environment_id, + auth_token=auth_token, ) self._logger.info(f"Loaded {len(mcp_server_configs)} MCP server configurations") diff --git a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py index 3c1db93c..d3e5337b 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py @@ -24,7 +24,11 @@ ) from ...common.models import MCPServerConfig from ...common.utils.constants import Constants -from ...common.utils.utility import get_tools_mode, get_mcp_platform_authentication_scope, get_use_environment_id +from ...common.utils.utility import ( + get_tools_mode, + get_mcp_platform_authentication_scope, + get_use_environment_id, +) from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py index e7657230..d4a263b5 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py @@ -98,7 +98,9 @@ async def list_tool_servers( if self._is_development_scenario(): return self._load_servers_from_manifest(environment_id) else: - return await self._load_servers_from_gateway(agent_instance_id, environment_id, auth_token) + return await self._load_servers_from_gateway( + agent_instance_id, environment_id, auth_token + ) # -------------------------------------------------------------------------- # ENVIRONMENT DETECTION diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py index 538ae411..0dc3aec8 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py @@ -21,6 +21,7 @@ class ToolsMode(Enum): PPAPI_TOKEN_SCOPE = "https://api.powerplatform.com" PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = "ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default" + def get_tooling_gateway_for_digital_worker(agent_instance_id: str) -> str: """ Gets the tooling gateway URL for the specified digital worker. From 088eca30b973b4dbcf73b97452d3afda83e94253 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 16:08:28 -0800 Subject: [PATCH 6/8] Trying to get agent app id from turn_context --- .../services/mcp_tool_registration_service.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py index a64dd928..4c302ba2 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py @@ -68,9 +68,15 @@ async def add_tool_servers_to_agent( f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" ) + agentic_app_id = agent_instance_id + if turn_context and turn_context.activity and turn_context.activity.recipient: + agentic_app_id = getattr( + turn_context.activity.recipient, "agentic_app_id", agent_instance_id + ) + # Get MCP server configurations server_configs = await self._mcp_server_configuration_service.list_tool_servers( - agent_instance_id=agent_instance_id, + agent_instance_id=agentic_app_id, environment_id=environment_id, auth_token=auth_token, ) From c4d0d3b6a4cee5d4d0da7d97c6c1b2541d527d44 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 17:12:55 -0800 Subject: [PATCH 7/8] Rename agent_instance_id to agentic_app_id throughout codebase --- .../README.md | 6 ++--- .../services/mcp_tool_registration_service.py | 14 ++++------- .../services/mcp_tool_registration_service.py | 20 ++++++++-------- .../README.md | 2 +- .../openai/mcp_tool_registration_service.py | 8 +++---- .../README.md | 2 +- .../services/mcp_tool_registration_service.py | 14 +++++------ .../microsoft-agents-a365-tooling/README.md | 2 +- .../mcp_tool_server_configuration_service.py | 24 +++++++++---------- .../tooling/utils/utility.py | 6 ++--- 10 files changed, 46 insertions(+), 52 deletions(-) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md index 5c583876..3c8bc545 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md +++ b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md @@ -82,7 +82,7 @@ async def main(): chat_client=chat_client, agent_instructions="You are a helpful assistant that can provide weather and restaurant information.", initial_tools=[], # Your existing tools - agent_instance_id="user-123", + agentic_app_id="user-123", environment_id="prod", auth_token="your-auth-token" ) @@ -139,7 +139,7 @@ async def main(): loaded from configured servers. Use these tools to enhance your capabilities. """, initial_tools=existing_tools, - agent_instance_id="user-123", + agentic_app_id="user-123", environment_id="production", auth_token="your-auth-token" ) @@ -190,7 +190,7 @@ agent = await service.add_tool_servers_to_agent( chat_client=chat_client, agent_instructions="You are a helpful assistant with access to various tools.", initial_tools=[], # Your existing tools - agent_instance_id="user-123", + agentic_app_id="user-123", environment_id="prod", auth_token="your-token" ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py index 4c302ba2..fb631832 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py @@ -41,7 +41,7 @@ async def add_tool_servers_to_agent( chat_client: Union[OpenAIChatClient, AzureOpenAIChatClient], agent_instructions: str, initial_tools: List[Any], - agent_instance_id: str, + agentic_app_id: str, environment_id: str, auth: Optional[Authorization] = None, auth_token: Optional[str] = None, @@ -54,7 +54,7 @@ async def add_tool_servers_to_agent( chat_client: The chat client instance (Union[OpenAIChatClient, AzureOpenAIChatClient]) agent_instructions: Instructions for the agent behavior initial_tools: List of initial tools to add to the agent - agent_instance_id: Unique identifier for the agent instance + agentic_app_id: Agentic app identifier for the agent environment_id: Environment identifier for MCP server discovery auth: Optional authorization context auth_token: Optional bearer token for authentication @@ -65,18 +65,12 @@ async def add_tool_servers_to_agent( """ try: self._logger.info( - f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" + f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}" ) - agentic_app_id = agent_instance_id - if turn_context and turn_context.activity and turn_context.activity.recipient: - agentic_app_id = getattr( - turn_context.activity.recipient, "agentic_app_id", agent_instance_id - ) - # Get MCP server configurations server_configs = await self._mcp_server_configuration_service.list_tool_servers( - agent_instance_id=agentic_app_id, + agentic_app_id=agentic_app_id, environment_id=environment_id, auth_token=auth_token, ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py index 66571870..97c9e71b 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/microsoft_agents_a365/tooling/extensions/azureaifoundry/services/mcp_tool_registration_service.py @@ -72,7 +72,7 @@ def __init__( async def add_tool_servers_to_agent( self, project_client: "AIProjectClient", - agent_instance_id: str, + agentic_app_id: str, environment_id: str, auth: Authorization, context: TurnContext, @@ -83,7 +83,7 @@ async def add_tool_servers_to_agent( Args: project_client: The Azure Foundry AIProjectClient instance. - agent_instance_id: Agent Instance ID for the agent. + agentic_app_id: Agentic App ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -102,12 +102,12 @@ async def add_tool_servers_to_agent( try: # Get the tool definitions and resources using the async implementation tool_definitions, tool_resources = await self._get_mcp_tool_definitions_and_resources( - agent_instance_id, environment_id, auth_token or "" + agentic_app_id, environment_id, auth_token or "" ) # Update the agent with the tools project_client.agents.update_agent( - agent_instance_id, tools=tool_definitions, tool_resources=tool_resources + agentic_app_id, tools=tool_definitions, tool_resources=tool_resources ) self._logger.info( @@ -116,12 +116,12 @@ async def add_tool_servers_to_agent( except Exception as ex: self._logger.error( - f"Unhandled failure during MCP tool registration workflow for agent user {agent_instance_id}: {ex}" + f"Unhandled failure during MCP tool registration workflow for agent user {agentic_app_id}: {ex}" ) raise async def _get_mcp_tool_definitions_and_resources( - self, agent_instance_id: str, environment_id: str, auth_token: str + self, agentic_app_id: str, environment_id: str, auth_token: str ) -> Tuple[List[McpTool], Optional[ToolResources]]: """ Internal method to get MCP tool definitions and resources. @@ -129,7 +129,7 @@ async def _get_mcp_tool_definitions_and_resources( This implements the core logic equivalent to the C# method of the same name. Args: - agent_instance_id: Agent Instance ID for the agent. + agentic_app_id: Agentic App ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -143,17 +143,17 @@ async def _get_mcp_tool_definitions_and_resources( # Get MCP server configurations try: servers = await self._mcp_server_configuration_service.list_tool_servers( - agent_instance_id, environment_id, auth_token + agentic_app_id, environment_id, auth_token ) except Exception as ex: self._logger.error( - f"Failed to list MCP tool servers for AgentInstanceId={agent_instance_id}: {ex}" + f"Failed to list MCP tool servers for AgenticAppId={agentic_app_id}: {ex}" ) return ([], None) if len(servers) == 0: self._logger.info( - f"No MCP servers configured for AgentInstanceId={agent_instance_id}, EnvironmentId={environment_id}" + f"No MCP servers configured for AgenticAppId={agentic_app_id}, EnvironmentId={environment_id}" ) return ([], None) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md b/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md index 60844226..6206c0fa 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md +++ b/libraries/microsoft-agents-a365-tooling-extensions-openai/README.md @@ -53,7 +53,7 @@ registration_service = McpToolRegistrationService() # Add MCP tool servers to your OpenAI agent await registration_service.add_tool_servers_to_agent( agent=your_openai_agent, - agent_instance_id="user-123", + agentic_app_id="user-123", environment_id="prod", auth=authorization_context, context=turn_context, diff --git a/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py index 5d56d7e8..b09e577d 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py @@ -51,7 +51,7 @@ def __init__(self, logger: Optional[logging.Logger] = None): async def add_tool_servers_to_agent( self, agent: Agent, - agent_instance_id: str, + agentic_app_id: str, environment_id: str, auth: Authorization, context: TurnContext, @@ -66,7 +66,7 @@ async def add_tool_servers_to_agent( Args: agent: The existing agent to add servers to - agent_instance_id: Agent Instance ID for the agent + agentic_app_id: Agentic App ID for the agent environment_id: Environment ID for the environment auth_token: Authentication token to access the MCP servers @@ -83,10 +83,10 @@ async def add_tool_servers_to_agent( # mcp_server_configs = [] # TODO: radevika: Update once the common project is merged. self._logger.info( - f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" + f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}" ) mcp_server_configs = await self.config_service.list_tool_servers( - agent_instance_id=agent_instance_id, + agentic_app_id=agentic_app_id, environment_id=environment_id, auth_token=auth_token, ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md index e6f787b5..5a53a26c 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md +++ b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md @@ -55,7 +55,7 @@ registration_service = McpToolRegistrationService() # Add MCP tool servers to your Semantic Kernel await registration_service.add_tool_servers_to_kernel( kernel=kernel, - agent_instance_id="user-123", + agentic_app_id="user-123", environment_id="prod", auth_token="your-auth-token" ) diff --git a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py index d3e5337b..cde95acc 100644 --- a/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py +++ b/libraries/microsoft-agents-a365-tooling-extensions-semantickernel/microsoft_agents_a365/tooling/extensions/semantickernel/services/mcp_tool_registration_service.py @@ -84,7 +84,7 @@ def __init__( async def add_tool_servers_to_agent( self, kernel: sk.Kernel, - agent_instance_id: str, + agentic_app_id: str, environment_id: str, auth: Authorization, context: TurnContext, @@ -95,7 +95,7 @@ async def add_tool_servers_to_agent( Args: kernel: The Semantic Kernel instance to which the tools will be added. - agent_instance_id: Agent Instance ID for the agent. + agentic_app_id: Agentic App ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -109,11 +109,11 @@ async def add_tool_servers_to_agent( authToken = await auth.exchange_token(context, scopes, "AGENTIC") auth_token = authToken.token - self._validate_inputs(kernel, agent_instance_id, environment_id, auth_token) + self._validate_inputs(kernel, agentic_app_id, environment_id, auth_token) # Get and process servers servers = await self._mcp_server_configuration_service.list_tool_servers( - agent_instance_id, environment_id, auth_token + agentic_app_id, environment_id, auth_token ) self._logger.info(f"🔧 Adding MCP tools from {len(servers)} servers") @@ -178,13 +178,13 @@ async def add_tool_servers_to_agent( # ============================================================================ def _validate_inputs( - self, kernel: Any, agent_instance_id: str, environment_id: str, auth_token: str + self, kernel: Any, agentic_app_id: str, environment_id: str, auth_token: str ) -> None: """Validate all required inputs.""" if kernel is None: raise ValueError("kernel cannot be None") - if not agent_instance_id or not agent_instance_id.strip(): - raise ValueError("agent_instance_id cannot be null or empty") + if not agentic_app_id or not agentic_app_id.strip(): + raise ValueError("agentic_app_id cannot be null or empty") if not environment_id or not environment_id.strip(): raise ValueError("environment_id cannot be null or empty") if not auth_token or not auth_token.strip(): diff --git a/libraries/microsoft-agents-a365-tooling/README.md b/libraries/microsoft-agents-a365-tooling/README.md index 6909b5ea..60e20c44 100644 --- a/libraries/microsoft-agents-a365-tooling/README.md +++ b/libraries/microsoft-agents-a365-tooling/README.md @@ -58,7 +58,7 @@ mcp_config = MCPServerConfig( # Use configuration service to list available MCP servers config_service = McpToolServerConfigurationService() mcp_servers = await config_service.list_tool_servers( - agent_instance_id="agent-123", + agentic_app_id="agent-123", environment_id="prod", auth_token="your-auth-token" ) diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py index d4a263b5..4b919239 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py @@ -70,13 +70,13 @@ def __init__(self, logger: Optional[logging.Logger] = None): # -------------------------------------------------------------------------- async def list_tool_servers( - self, agent_instance_id: str, environment_id: str, auth_token: str + self, agentic_app_id: str, environment_id: str, auth_token: str ) -> List[MCPServerConfig]: """ Gets the list of MCP Servers that are configured for the agent. Args: - agent_instance_id: Agent Instance ID for the agent. + agentic_app_id: Agentic App ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the MCP servers. @@ -88,10 +88,10 @@ async def list_tool_servers( Exception: If there's an error communicating with the tooling gateway. """ # Validate input parameters - self._validate_input_parameters(agent_instance_id, environment_id, auth_token) + self._validate_input_parameters(agentic_app_id, environment_id, auth_token) self._logger.info( - f"Listing MCP tool servers for agent {agent_instance_id} in environment {environment_id}" + f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}" ) # Determine configuration source based on environment @@ -99,7 +99,7 @@ async def list_tool_servers( return self._load_servers_from_manifest(environment_id) else: return await self._load_servers_from_gateway( - agent_instance_id, environment_id, auth_token + agentic_app_id, environment_id, auth_token ) # -------------------------------------------------------------------------- @@ -292,13 +292,13 @@ def _log_manifest_search_failure(self) -> None: # -------------------------------------------------------------------------- async def _load_servers_from_gateway( - self, agent_instance_id: str, environment_id: str, auth_token: str + self, agentic_app_id: str, environment_id: str, auth_token: str ) -> List[MCPServerConfig]: """ Reads MCP server configurations from tooling gateway endpoint for production scenario. Args: - agent_instance_id: Agent Instance ID for the agent. + agentic_app_id: Agentic App ID for the agent. environment_id: Environment ID for the environment. auth_token: Authentication token to access the tooling gateway. @@ -311,7 +311,7 @@ async def _load_servers_from_gateway( mcp_servers: List[MCPServerConfig] = [] try: - config_endpoint = get_tooling_gateway_for_digital_worker(agent_instance_id) + config_endpoint = get_tooling_gateway_for_digital_worker(agentic_app_id) headers = self._prepare_gateway_headers(auth_token, environment_id) self._logger.info(f"Calling tooling gateway endpoint: {config_endpoint}") @@ -447,21 +447,21 @@ def _parse_gateway_server_config( # -------------------------------------------------------------------------- def _validate_input_parameters( - self, agent_instance_id: str, environment_id: str, auth_token: str + self, agentic_app_id: str, environment_id: str, auth_token: str ) -> None: """ Validates input parameters for the main API method. Args: - agent_instance_id: Agent Instance ID to validate. + agentic_app_id: Agentic App ID to validate. environment_id: Environment ID to validate. auth_token: Authentication token to validate. Raises: ValueError: If any parameter is invalid or empty. """ - if not agent_instance_id: - raise ValueError("agent_instance_id cannot be empty or None") + if not agentic_app_id: + raise ValueError("agentic_app_id cannot be empty or None") if not environment_id: raise ValueError("environment_id cannot be empty or None") if not auth_token: diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py index 0dc3aec8..7b5e0e74 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py @@ -22,18 +22,18 @@ class ToolsMode(Enum): PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = "ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default" -def get_tooling_gateway_for_digital_worker(agent_instance_id: str) -> str: +def get_tooling_gateway_for_digital_worker(agentic_app_id: str) -> str: """ Gets the tooling gateway URL for the specified digital worker. Args: - agent_instance_id: The unique identifier of the digital worker. + agentic_app_id: The agentic app identifier of the digital worker. Returns: str: The tooling gateway URL for the digital worker. """ # The endpoint needs to be updated based on the environment (prod, dev, etc.) - return f"{_get_mcp_platform_base_url()}/agents/{agent_instance_id}/mcpServers" + return f"{_get_mcp_platform_base_url()}/agents/{agentic_app_id}/mcpServers" def get_mcp_base_url() -> str: From 7b9bac5a4a8cb8ecb7bca508cfa61a16b78f03f9 Mon Sep 17 00:00:00 2001 From: Sellakumaran Kanagarathnam Date: Mon, 3 Nov 2025 17:16:59 -0800 Subject: [PATCH 8/8] fixed formatting issue --- .../tooling/services/mcp_tool_server_configuration_service.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py index 4b919239..bc1de97b 100644 --- a/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py +++ b/libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py @@ -98,9 +98,7 @@ async def list_tool_servers( if self._is_development_scenario(): return self._load_servers_from_manifest(environment_id) else: - return await self._load_servers_from_gateway( - agentic_app_id, environment_id, auth_token - ) + return await self._load_servers_from_gateway(agentic_app_id, environment_id, auth_token) # -------------------------------------------------------------------------- # ENVIRONMENT DETECTION