Skip to content

Commit f81ec6e

Browse files
authored
Merge pull request #9 from microsoft/users/sellak/entraSDK
Update get_tooling_gateway_for_digital_worker
2 parents 7a19369 + 7b9bac5 commit f81ec6e

11 files changed

Lines changed: 70 additions & 62 deletions

File tree

libraries/microsoft-agents-a365-tooling-extensions-agentframework/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def main():
8282
chat_client=chat_client,
8383
agent_instructions="You are a helpful assistant that can provide weather and restaurant information.",
8484
initial_tools=[], # Your existing tools
85-
agent_user_id="user-123",
85+
agentic_app_id="user-123",
8686
environment_id="prod",
8787
auth_token="your-auth-token"
8888
)
@@ -139,7 +139,7 @@ async def main():
139139
loaded from configured servers. Use these tools to enhance your capabilities.
140140
""",
141141
initial_tools=existing_tools,
142-
agent_user_id="user-123",
142+
agentic_app_id="user-123",
143143
environment_id="production",
144144
auth_token="your-auth-token"
145145
)
@@ -190,7 +190,7 @@ agent = await service.add_tool_servers_to_agent(
190190
chat_client=chat_client,
191191
agent_instructions="You are a helpful assistant with access to various tools.",
192192
initial_tools=[], # Your existing tools
193-
agent_user_id="user-123",
193+
agentic_app_id="user-123",
194194
environment_id="prod",
195195
auth_token="your-token"
196196
)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def add_tool_servers_to_agent(
4141
chat_client: Union[OpenAIChatClient, AzureOpenAIChatClient],
4242
agent_instructions: str,
4343
initial_tools: List[Any],
44-
agent_user_id: str,
44+
agentic_app_id: str,
4545
environment_id: str,
4646
auth: Optional[Authorization] = None,
4747
auth_token: Optional[str] = None,
@@ -54,7 +54,7 @@ async def add_tool_servers_to_agent(
5454
chat_client: The chat client instance (Union[OpenAIChatClient, AzureOpenAIChatClient])
5555
agent_instructions: Instructions for the agent behavior
5656
initial_tools: List of initial tools to add to the agent
57-
agent_user_id: Unique identifier for the agent user
57+
agentic_app_id: Agentic app identifier for the agent
5858
environment_id: Environment identifier for MCP server discovery
5959
auth: Optional authorization context
6060
auth_token: Optional bearer token for authentication
@@ -65,12 +65,12 @@ async def add_tool_servers_to_agent(
6565
"""
6666
try:
6767
self._logger.info(
68-
f"Listing MCP tool servers for agent {agent_user_id} in environment {environment_id}"
68+
f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}"
6969
)
7070

7171
# Get MCP server configurations
7272
server_configs = await self._mcp_server_configuration_service.list_tool_servers(
73-
agent_user_id=agent_user_id,
73+
agentic_app_id=agentic_app_id,
7474
environment_id=environment_id,
7575
auth_token=auth_token,
7676
)

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from azure.ai.agents.models import McpTool, ToolResources
1919
from microsoft_agents.hosting.core import Authorization, TurnContext
2020

21-
from ...common.utils.utility import get_ppapi_token_scope, get_use_environment_id
21+
from ...common.utils.utility import get_mcp_platform_authentication_scope, get_use_environment_id
2222

2323
# Local imports
2424
from microsoft_kairo.tooling.common.services.mcp_tool_server_configuration_service import (
@@ -72,7 +72,7 @@ def __init__(
7272
async def add_tool_servers_to_agent(
7373
self,
7474
project_client: "AIProjectClient",
75-
agent_user_id: str,
75+
agentic_app_id: str,
7676
environment_id: str,
7777
auth: Authorization,
7878
context: TurnContext,
@@ -83,7 +83,7 @@ async def add_tool_servers_to_agent(
8383
8484
Args:
8585
project_client: The Azure Foundry AIProjectClient instance.
86-
agent_user_id: Agent User ID for the agent.
86+
agentic_app_id: Agentic App ID for the agent.
8787
environment_id: Environment ID for the environment.
8888
auth_token: Authentication token to access the MCP servers.
8989
@@ -95,19 +95,19 @@ async def add_tool_servers_to_agent(
9595
raise ValueError("project_client cannot be None")
9696

9797
if not auth_token:
98-
scopes = get_ppapi_token_scope()
98+
scopes = get_mcp_platform_authentication_scope()
9999
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
100100
auth_token = authToken.token
101101

102102
try:
103103
# Get the tool definitions and resources using the async implementation
104104
tool_definitions, tool_resources = await self._get_mcp_tool_definitions_and_resources(
105-
agent_user_id, environment_id, auth_token or ""
105+
agentic_app_id, environment_id, auth_token or ""
106106
)
107107

108108
# Update the agent with the tools
109109
project_client.agents.update_agent(
110-
agent_user_id, tools=tool_definitions, tool_resources=tool_resources
110+
agentic_app_id, tools=tool_definitions, tool_resources=tool_resources
111111
)
112112

113113
self._logger.info(
@@ -116,20 +116,20 @@ async def add_tool_servers_to_agent(
116116

117117
except Exception as ex:
118118
self._logger.error(
119-
f"Unhandled failure during MCP tool registration workflow for agent user {agent_user_id}: {ex}"
119+
f"Unhandled failure during MCP tool registration workflow for agent user {agentic_app_id}: {ex}"
120120
)
121121
raise
122122

123123
async def _get_mcp_tool_definitions_and_resources(
124-
self, agent_user_id: str, environment_id: str, auth_token: str
124+
self, agentic_app_id: str, environment_id: str, auth_token: str
125125
) -> Tuple[List[McpTool], Optional[ToolResources]]:
126126
"""
127127
Internal method to get MCP tool definitions and resources.
128128
129129
This implements the core logic equivalent to the C# method of the same name.
130130
131131
Args:
132-
agent_user_id: Agent User ID for the agent.
132+
agentic_app_id: Agentic App ID for the agent.
133133
environment_id: Environment ID for the environment.
134134
auth_token: Authentication token to access the MCP servers.
135135
@@ -143,17 +143,17 @@ async def _get_mcp_tool_definitions_and_resources(
143143
# Get MCP server configurations
144144
try:
145145
servers = await self._mcp_server_configuration_service.list_tool_servers(
146-
agent_user_id, environment_id, auth_token
146+
agentic_app_id, environment_id, auth_token
147147
)
148148
except Exception as ex:
149149
self._logger.error(
150-
f"Failed to list MCP tool servers for AgentUserId={agent_user_id}: {ex}"
150+
f"Failed to list MCP tool servers for AgenticAppId={agentic_app_id}: {ex}"
151151
)
152152
return ([], None)
153153

154154
if len(servers) == 0:
155155
self._logger.info(
156-
f"No MCP servers configured for AgentUserId={agent_user_id}, EnvironmentId={environment_id}"
156+
f"No MCP servers configured for AgenticAppId={agentic_app_id}, EnvironmentId={environment_id}"
157157
)
158158
return ([], None)
159159

libraries/microsoft-agents-a365-tooling-extensions-openai/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ registration_service = McpToolRegistrationService()
5353
# Add MCP tool servers to your OpenAI agent
5454
await registration_service.add_tool_servers_to_agent(
5555
agent=your_openai_agent,
56-
agent_user_id="user-123",
56+
agentic_app_id="user-123",
5757
environment_id="prod",
5858
auth=authorization_context,
5959
context=turn_context,

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919
from microsoft_agents_a365.tooling.utils.utility import (
20-
get_ppapi_token_scope,
20+
get_mcp_platform_authentication_scope,
2121
get_use_environment_id,
2222
)
2323

@@ -51,7 +51,7 @@ def __init__(self, logger: Optional[logging.Logger] = None):
5151
async def add_tool_servers_to_agent(
5252
self,
5353
agent: Agent,
54-
agent_user_id: str,
54+
agentic_app_id: str,
5555
environment_id: str,
5656
auth: Authorization,
5757
context: TurnContext,
@@ -66,7 +66,7 @@ async def add_tool_servers_to_agent(
6666
6767
Args:
6868
agent: The existing agent to add servers to
69-
agent_user_id: Agent User ID for the agent
69+
agentic_app_id: Agentic App ID for the agent
7070
environment_id: Environment ID for the environment
7171
auth_token: Authentication token to access the MCP servers
7272
@@ -75,18 +75,20 @@ async def add_tool_servers_to_agent(
7575
"""
7676

7777
if not auth_token:
78-
scopes = get_ppapi_token_scope()
78+
scopes = get_mcp_platform_authentication_scope()
7979
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
8080
auth_token = authToken.token
8181

8282
# Get MCP server configurations from the configuration service
8383
# mcp_server_configs = []
8484
# TODO: radevika: Update once the common project is merged.
8585
self._logger.info(
86-
f"Listing MCP tool servers for agent {agent_user_id} in environment {environment_id}"
86+
f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}"
8787
)
8888
mcp_server_configs = await self.config_service.list_tool_servers(
89-
agent_user_id=agent_user_id, environment_id=environment_id, auth_token=auth_token
89+
agentic_app_id=agentic_app_id,
90+
environment_id=environment_id,
91+
auth_token=auth_token,
9092
)
9193

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

libraries/microsoft-agents-a365-tooling-extensions-semantickernel/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ registration_service = McpToolRegistrationService()
5555
# Add MCP tool servers to your Semantic Kernel
5656
await registration_service.add_tool_servers_to_kernel(
5757
kernel=kernel,
58-
agent_user_id="user-123",
58+
agentic_app_id="user-123",
5959
environment_id="prod",
6060
auth_token="your-auth-token"
6161
)

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
)
2525
from ...common.models import MCPServerConfig
2626
from ...common.utils.constants import Constants
27-
from ...common.utils.utility import get_tools_mode, get_ppapi_token_scope, get_use_environment_id
27+
from ...common.utils.utility import (
28+
get_tools_mode,
29+
get_mcp_platform_authentication_scope,
30+
get_use_environment_id,
31+
)
2832

2933

3034
from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin
@@ -80,7 +84,7 @@ def __init__(
8084
async def add_tool_servers_to_agent(
8185
self,
8286
kernel: sk.Kernel,
83-
agent_user_id: str,
87+
agentic_app_id: str,
8488
environment_id: str,
8589
auth: Authorization,
8690
context: TurnContext,
@@ -91,7 +95,7 @@ async def add_tool_servers_to_agent(
9195
9296
Args:
9397
kernel: The Semantic Kernel instance to which the tools will be added.
94-
agent_user_id: Agent User ID for the agent.
98+
agentic_app_id: Agentic App ID for the agent.
9599
environment_id: Environment ID for the environment.
96100
auth_token: Authentication token to access the MCP servers.
97101
@@ -101,15 +105,15 @@ async def add_tool_servers_to_agent(
101105
"""
102106

103107
if not auth_token:
104-
scopes = get_ppapi_token_scope()
108+
scopes = get_mcp_platform_authentication_scope()
105109
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
106110
auth_token = authToken.token
107111

108-
self._validate_inputs(kernel, agent_user_id, environment_id, auth_token)
112+
self._validate_inputs(kernel, agentic_app_id, environment_id, auth_token)
109113

110114
# Get and process servers
111115
servers = await self._mcp_server_configuration_service.list_tool_servers(
112-
agent_user_id, environment_id, auth_token
116+
agentic_app_id, environment_id, auth_token
113117
)
114118
self._logger.info(f"🔧 Adding MCP tools from {len(servers)} servers")
115119

@@ -174,13 +178,13 @@ async def add_tool_servers_to_agent(
174178
# ============================================================================
175179

176180
def _validate_inputs(
177-
self, kernel: Any, agent_user_id: str, environment_id: str, auth_token: str
181+
self, kernel: Any, agentic_app_id: str, environment_id: str, auth_token: str
178182
) -> None:
179183
"""Validate all required inputs."""
180184
if kernel is None:
181185
raise ValueError("kernel cannot be None")
182-
if not agent_user_id or not agent_user_id.strip():
183-
raise ValueError("agent_user_id cannot be null or empty")
186+
if not agentic_app_id or not agentic_app_id.strip():
187+
raise ValueError("agentic_app_id cannot be null or empty")
184188
if not environment_id or not environment_id.strip():
185189
raise ValueError("environment_id cannot be null or empty")
186190
if not auth_token or not auth_token.strip():

libraries/microsoft-agents-a365-tooling/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mcp_config = MCPServerConfig(
5858
# Use configuration service to list available MCP servers
5959
config_service = McpToolServerConfigurationService()
6060
mcp_servers = await config_service.list_tool_servers(
61-
agent_user_id="agent-123",
61+
agentic_app_id="agent-123",
6262
environment_id="prod",
6363
auth_token="your-auth-token"
6464
)

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def __init__(self, logger: Optional[logging.Logger] = None):
7070
# --------------------------------------------------------------------------
7171

7272
async def list_tool_servers(
73-
self, agent_user_id: str, environment_id: str, auth_token: str
73+
self, agentic_app_id: str, environment_id: str, auth_token: str
7474
) -> List[MCPServerConfig]:
7575
"""
7676
Gets the list of MCP Servers that are configured for the agent.
7777
7878
Args:
79-
agent_user_id: Agent User ID for the agent.
79+
agentic_app_id: Agentic App ID for the agent.
8080
environment_id: Environment ID for the environment.
8181
auth_token: Authentication token to access the MCP servers.
8282
@@ -88,17 +88,17 @@ async def list_tool_servers(
8888
Exception: If there's an error communicating with the tooling gateway.
8989
"""
9090
# Validate input parameters
91-
self._validate_input_parameters(agent_user_id, environment_id, auth_token)
91+
self._validate_input_parameters(agentic_app_id, environment_id, auth_token)
9292

9393
self._logger.info(
94-
f"Listing MCP tool servers for agent {agent_user_id} in environment {environment_id}"
94+
f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}"
9595
)
9696

9797
# Determine configuration source based on environment
9898
if self._is_development_scenario():
9999
return self._load_servers_from_manifest(environment_id)
100100
else:
101-
return await self._load_servers_from_gateway(agent_user_id, environment_id, auth_token)
101+
return await self._load_servers_from_gateway(agentic_app_id, environment_id, auth_token)
102102

103103
# --------------------------------------------------------------------------
104104
# ENVIRONMENT DETECTION
@@ -290,13 +290,13 @@ def _log_manifest_search_failure(self) -> None:
290290
# --------------------------------------------------------------------------
291291

292292
async def _load_servers_from_gateway(
293-
self, agent_user_id: str, environment_id: str, auth_token: str
293+
self, agentic_app_id: str, environment_id: str, auth_token: str
294294
) -> List[MCPServerConfig]:
295295
"""
296296
Reads MCP server configurations from tooling gateway endpoint for production scenario.
297297
298298
Args:
299-
agent_user_id: Agent User ID for the agent.
299+
agentic_app_id: Agentic App ID for the agent.
300300
environment_id: Environment ID for the environment.
301301
auth_token: Authentication token to access the tooling gateway.
302302
@@ -309,7 +309,7 @@ async def _load_servers_from_gateway(
309309
mcp_servers: List[MCPServerConfig] = []
310310

311311
try:
312-
config_endpoint = get_tooling_gateway_for_digital_worker(agent_user_id)
312+
config_endpoint = get_tooling_gateway_for_digital_worker(agentic_app_id)
313313
headers = self._prepare_gateway_headers(auth_token, environment_id)
314314

315315
self._logger.info(f"Calling tooling gateway endpoint: {config_endpoint}")
@@ -445,21 +445,21 @@ def _parse_gateway_server_config(
445445
# --------------------------------------------------------------------------
446446

447447
def _validate_input_parameters(
448-
self, agent_user_id: str, environment_id: str, auth_token: str
448+
self, agentic_app_id: str, environment_id: str, auth_token: str
449449
) -> None:
450450
"""
451451
Validates input parameters for the main API method.
452452
453453
Args:
454-
agent_user_id: Agent User ID to validate.
454+
agentic_app_id: Agentic App ID to validate.
455455
environment_id: Environment ID to validate.
456456
auth_token: Authentication token to validate.
457457
458458
Raises:
459459
ValueError: If any parameter is invalid or empty.
460460
"""
461-
if not agent_user_id:
462-
raise ValueError("agent_user_id cannot be empty or None")
461+
if not agentic_app_id:
462+
raise ValueError("agentic_app_id cannot be empty or None")
463463
if not environment_id:
464464
raise ValueError("environment_id cannot be empty or None")
465465
if not auth_token:

0 commit comments

Comments
 (0)