Skip to content

Commit c8cb233

Browse files
committed
Remove environment id from all APIs
1 parent c07a8cd commit c8cb233

12 files changed

Lines changed: 29 additions & 141 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ async def main():
8383
agent_instructions="You are a helpful assistant that can provide weather and restaurant information.",
8484
initial_tools=[], # Your existing tools
8585
agentic_app_id="user-123",
86-
environment_id="prod",
8786
auth_token="your-auth-token"
8887
)
8988

@@ -140,7 +139,6 @@ async def main():
140139
""",
141140
initial_tools=existing_tools,
142141
agentic_app_id="user-123",
143-
environment_id="production",
144142
auth_token="your-auth-token"
145143
)
146144

@@ -191,7 +189,6 @@ agent = await service.add_tool_servers_to_agent(
191189
agent_instructions="You are a helpful assistant with access to various tools.",
192190
initial_tools=[], # Your existing tools
193191
agentic_app_id="user-123",
194-
environment_id="prod",
195192
auth_token="your-token"
196193
)
197194
```

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from microsoft_agents_a365.tooling.utils.utility import (
1818
get_mcp_platform_authentication_scope,
19-
get_use_environment_id,
2019
)
2120

2221

@@ -47,7 +46,6 @@ async def add_tool_servers_to_agent(
4746
agent_instructions: str,
4847
initial_tools: List[Any],
4948
agentic_app_id: str,
50-
environment_id: str,
5149
auth: Authorization,
5250
turn_context: TurnContext,
5351
auth_token: Optional[str] = None,
@@ -60,7 +58,6 @@ async def add_tool_servers_to_agent(
6058
agent_instructions: Instructions for the agent behavior
6159
initial_tools: List of initial tools to add to the agent
6260
agentic_app_id: Agentic app identifier for the agent
63-
environment_id: Environment identifier for MCP server discovery
6461
auth: Authorization context for token exchange
6562
turn_context: Turn context for the operation
6663
auth_token: Optional bearer token for authentication
@@ -75,17 +72,11 @@ async def add_tool_servers_to_agent(
7572
authToken = await auth.exchange_token(turn_context, scopes, "AGENTIC")
7673
auth_token = authToken.token
7774

78-
if get_use_environment_id():
79-
self._logger.info(
80-
f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}"
81-
)
82-
else:
83-
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")
75+
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")
8476

8577
# Get MCP server configurations
8678
server_configs = await self._mcp_server_configuration_service.list_tool_servers(
8779
agentic_app_id=agentic_app_id,
88-
environment_id=environment_id,
8980
auth_token=auth_token,
9081
)
9182

@@ -110,8 +101,6 @@ async def add_tool_servers_to_agent(
110101
headers[Constants.Headers.AUTHORIZATION] = (
111102
f"{Constants.Headers.BEARER_PREFIX} {auth_token}"
112103
)
113-
if get_use_environment_id() and environment_id:
114-
headers[Constants.Headers.ENVIRONMENT_ID] = environment_id
115104

116105
server_name = getattr(config, "mcp_server_name", "Unknown")
117106

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ registration_service = McpToolRegistrationService()
6464
await registration_service.add_tool_servers_to_agent(
6565
project_client=project_client,
6666
agent_id="your-agent-id",
67-
environment_id="prod",
6867
auth_token="your-auth-token"
6968
)
7069
```

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

Lines changed: 5 additions & 17 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_mcp_platform_authentication_scope, get_use_environment_id
21+
from ...common.utils.utility import get_mcp_platform_authentication_scope
2222

2323
# Local imports
2424
from microsoft_kairo.tooling.common.services.mcp_tool_server_configuration_service import (
@@ -73,7 +73,6 @@ async def add_tool_servers_to_agent(
7373
self,
7474
project_client: "AIProjectClient",
7575
agentic_app_id: str,
76-
environment_id: str,
7776
auth: Authorization,
7877
context: TurnContext,
7978
auth_token: Optional[str] = None,
@@ -84,7 +83,6 @@ async def add_tool_servers_to_agent(
8483
Args:
8584
project_client: The Azure Foundry AIProjectClient instance.
8685
agentic_app_id: Agentic App ID for the agent.
87-
environment_id: Environment ID for the environment.
8886
auth_token: Authentication token to access the MCP servers.
8987
9088
Raises:
@@ -102,7 +100,7 @@ async def add_tool_servers_to_agent(
102100
try:
103101
# Get the tool definitions and resources using the async implementation
104102
tool_definitions, tool_resources = await self._get_mcp_tool_definitions_and_resources(
105-
agentic_app_id, environment_id, auth_token or ""
103+
agentic_app_id, auth_token or ""
106104
)
107105

108106
# Update the agent with the tools
@@ -121,7 +119,7 @@ async def add_tool_servers_to_agent(
121119
raise
122120

123121
async def _get_mcp_tool_definitions_and_resources(
124-
self, agentic_app_id: str, environment_id: str, auth_token: str
122+
self, agentic_app_id: str, auth_token: str
125123
) -> Tuple[List[McpTool], Optional[ToolResources]]:
126124
"""
127125
Internal method to get MCP tool definitions and resources.
@@ -130,7 +128,6 @@ async def _get_mcp_tool_definitions_and_resources(
130128
131129
Args:
132130
agentic_app_id: Agentic App ID for the agent.
133-
environment_id: Environment ID for the environment.
134131
auth_token: Authentication token to access the MCP servers.
135132
136133
Returns:
@@ -143,7 +140,7 @@ async def _get_mcp_tool_definitions_and_resources(
143140
# Get MCP server configurations
144141
try:
145142
servers = await self._mcp_server_configuration_service.list_tool_servers(
146-
agentic_app_id, environment_id, auth_token
143+
agentic_app_id, auth_token
147144
)
148145
except Exception as ex:
149146
self._logger.error(
@@ -152,12 +149,7 @@ async def _get_mcp_tool_definitions_and_resources(
152149
return ([], None)
153150

154151
if len(servers) == 0:
155-
if get_use_environment_id():
156-
self._logger.info(
157-
f"No MCP servers configured for AgenticAppId={agentic_app_id}, EnvironmentId={environment_id}"
158-
)
159-
else:
160-
self._logger.info(f"No MCP servers configured for AgenticAppId={agentic_app_id}")
152+
self._logger.info(f"No MCP servers configured for AgenticAppId={agentic_app_id}")
161153
return ([], None)
162154

163155
# Collections to build for the return value
@@ -196,10 +188,6 @@ async def _get_mcp_tool_definitions_and_resources(
196188
)
197189
mcp_tool.update_headers(Constants.Headers.AUTHORIZATION, header_value)
198190

199-
# Set environment ID header
200-
if get_use_environment_id() and environment_id:
201-
mcp_tool.update_headers(Constants.Headers.ENVIRONMENT_ID, environment_id)
202-
203191
# Add to collections
204192
tool_definitions.extend(mcp_tool.definitions)
205193
if mcp_tool.resources and mcp_tool.resources.mcp:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ registration_service = McpToolRegistrationService()
5454
await registration_service.add_tool_servers_to_agent(
5555
agent=your_openai_agent,
5656
agentic_app_id="user-123",
57-
environment_id="prod",
5857
auth=authorization_context,
5958
context=turn_context,
6059
auth_token="your-auth-token"

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from microsoft_agents_a365.tooling.utils.utility import (
2020
get_mcp_platform_authentication_scope,
21-
get_use_environment_id,
2221
)
2322

2423

@@ -52,7 +51,6 @@ async def add_tool_servers_to_agent(
5251
self,
5352
agent: Agent,
5453
agentic_app_id: str,
55-
environment_id: str,
5654
auth: Authorization,
5755
context: TurnContext,
5856
auth_token: Optional[str] = None,
@@ -67,7 +65,6 @@ async def add_tool_servers_to_agent(
6765
Args:
6866
agent: The existing agent to add servers to
6967
agentic_app_id: Agentic App ID for the agent
70-
environment_id: Environment ID for the environment
7168
auth_token: Authentication token to access the MCP servers
7269
7370
Returns:
@@ -83,15 +80,9 @@ async def add_tool_servers_to_agent(
8380
# mcp_server_configs = []
8481
# TODO: radevika: Update once the common project is merged.
8582

86-
if get_use_environment_id():
87-
self._logger.info(
88-
f"Listing MCP tool servers for agent {agentic_app_id} in environment {environment_id}"
89-
)
90-
else:
91-
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")
83+
self._logger.info(f"Listing MCP tool servers for agent {agentic_app_id}")
9284
mcp_server_configs = await self.config_service.list_tool_servers(
9385
agentic_app_id=agentic_app_id,
94-
environment_id=environment_id,
9586
auth_token=auth_token,
9687
)
9788

@@ -138,8 +129,6 @@ async def add_tool_servers_to_agent(
138129
headers = si.headers or {}
139130
if auth_token:
140131
headers["Authorization"] = f"Bearer {auth_token}"
141-
if get_use_environment_id() and environment_id:
142-
headers["x-ms-environment-id"] = environment_id
143132

144133
# Create MCPServerStreamableHttpParams with proper configuration
145134
params = MCPServerStreamableHttpParams(url=si.url, headers=headers)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ registration_service = McpToolRegistrationService()
5656
await registration_service.add_tool_servers_to_kernel(
5757
kernel=kernel,
5858
agentic_app_id="user-123",
59-
environment_id="prod",
6059
auth_token="your-auth-token"
6160
)
6261
```

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from ...common.utils.utility import (
2828
get_tools_mode,
2929
get_mcp_platform_authentication_scope,
30-
get_use_environment_id,
3130
)
3231

3332

@@ -85,7 +84,6 @@ async def add_tool_servers_to_agent(
8584
self,
8685
kernel: sk.Kernel,
8786
agentic_app_id: str,
88-
environment_id: str,
8987
auth: Authorization,
9088
context: TurnContext,
9189
auth_token: Optional[str] = None,
@@ -96,7 +94,6 @@ async def add_tool_servers_to_agent(
9694
Args:
9795
kernel: The Semantic Kernel instance to which the tools will be added.
9896
agentic_app_id: Agentic App ID for the agent.
99-
environment_id: Environment ID for the environment.
10097
auth_token: Authentication token to access the MCP servers.
10198
10299
Raises:
@@ -109,11 +106,11 @@ async def add_tool_servers_to_agent(
109106
authToken = await auth.exchange_token(context, scopes, "AGENTIC")
110107
auth_token = authToken.token
111108

112-
self._validate_inputs(kernel, agentic_app_id, environment_id, auth_token)
109+
self._validate_inputs(kernel, agentic_app_id, auth_token)
113110

114111
# Get and process servers
115112
servers = await self._mcp_server_configuration_service.list_tool_servers(
116-
agentic_app_id, environment_id, auth_token
113+
agentic_app_id, auth_token
117114
)
118115
self._logger.info(f"🔧 Adding MCP tools from {len(servers)} servers")
119116

@@ -130,17 +127,8 @@ async def add_tool_servers_to_agent(
130127
headers = {}
131128

132129
if tools_mode == "MockMCPServer":
133-
# Mock server does not require bearer auth, but still forward environment id if available.
134-
if get_use_environment_id() and environment_id:
135-
headers[Constants.Headers.ENVIRONMENT_ID] = environment_id
136-
137130
if mock_auth_header := os.getenv("MOCK_MCP_AUTHORIZATION"):
138131
headers[Constants.Headers.AUTHORIZATION] = mock_auth_header
139-
elif get_use_environment_id():
140-
headers = {
141-
Constants.Headers.AUTHORIZATION: f"{Constants.Headers.BEARER_PREFIX} {auth_token}",
142-
Constants.Headers.ENVIRONMENT_ID: environment_id,
143-
}
144132
else:
145133
headers = {
146134
Constants.Headers.AUTHORIZATION: f"{Constants.Headers.BEARER_PREFIX} {auth_token}",
@@ -177,16 +165,12 @@ async def add_tool_servers_to_agent(
177165
# Private Methods - Input Validation & Processing
178166
# ============================================================================
179167

180-
def _validate_inputs(
181-
self, kernel: Any, agentic_app_id: str, environment_id: str, auth_token: str
182-
) -> None:
168+
def _validate_inputs(self, kernel: Any, agentic_app_id: str, auth_token: str) -> None:
183169
"""Validate all required inputs."""
184170
if kernel is None:
185171
raise ValueError("kernel cannot be None")
186172
if not agentic_app_id or not agentic_app_id.strip():
187173
raise ValueError("agentic_app_id cannot be null or empty")
188-
if get_use_environment_id() and (not environment_id or not environment_id.strip()):
189-
raise ValueError("environment_id cannot be null or empty")
190174
if not auth_token or not auth_token.strip():
191175
raise ValueError("auth_token cannot be null or empty")
192176

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ mcp_config = MCPServerConfig(
5959
config_service = McpToolServerConfigurationService()
6060
mcp_servers = await config_service.list_tool_servers(
6161
agentic_app_id="agent-123",
62-
environment_id="prod",
6362
auth_token="your-auth-token"
6463
)
6564
```

0 commit comments

Comments
 (0)