diff --git a/packages/agents-a365-tooling-extensions-claude/README.md b/packages/agents-a365-tooling-extensions-claude/README.md index 8e88bcfc..50a982c2 100644 --- a/packages/agents-a365-tooling-extensions-claude/README.md +++ b/packages/agents-a365-tooling-extensions-claude/README.md @@ -48,7 +48,6 @@ const toolService = new McpToolRegistrationService(); await toolService.addToolServers( agentOptions, process.env.AGENTIC_USER_ID || '', - process.env.MCP_ENVIRONMENT_ID || '', app.authorization, turnContext, process.env.MCP_AUTH_TOKEN || '' @@ -100,7 +99,6 @@ const mcpServerConfig: McpServerConfig = { url: 'https://your-mcp-server.com', headers: { 'Authorization': `Bearer ${authToken}`, - 'x-ms-environment-id': environmentId, } }; @@ -118,7 +116,6 @@ The following environment variables are commonly used: ```bash # Agent365 Authentication AGENTIC_USER_ID=your-user-id -MCP_ENVIRONMENT_ID=your-environment-id MCP_AUTH_TOKEN=your-auth-token # Agent Configuration @@ -135,7 +132,6 @@ The SDK supports multiple authentication methods: await toolService.addToolServers( agentOptions, userId, - environmentId, authorization, turnContext, '' // Empty auth token - will be acquired automatically @@ -148,7 +144,6 @@ The SDK supports multiple authentication methods: await toolService.addToolServers( agentOptions, userId, - environmentId, authorization, turnContext, process.env.MCP_AUTH_TOKEN diff --git a/packages/agents-a365-tooling-extensions-claude/src/McpToolRegistrationService.ts b/packages/agents-a365-tooling-extensions-claude/src/McpToolRegistrationService.ts index 789075a6..b0743f67 100644 --- a/packages/agents-a365-tooling-extensions-claude/src/McpToolRegistrationService.ts +++ b/packages/agents-a365-tooling-extensions-claude/src/McpToolRegistrationService.ts @@ -19,12 +19,11 @@ export class McpToolRegistrationService { /** * Registers MCP tool servers and updates agent options with discovered tools and server configs. - * Call this to enable dynamic Claude tool access based on the current MCP environment. + * Call this to enable dynamic Claude tool access. */ async addToolServersToAgent( agentOptions: Options, agentUserId: string, - environmentId: string, authorization: Authorization, turnContext: TurnContext, authToken: string @@ -41,7 +40,8 @@ export class McpToolRegistrationService { // Validate the authentication token Utility.ValidateAuthToken(authToken); - const servers = await this.configService.listToolServers(agentUserId, environmentId, authToken); + const servers = await this.configService.listToolServers(agentUserId, authToken); + const mcpServers: Record = {}; const tools: McpClientTool[] = []; @@ -52,10 +52,6 @@ export class McpToolRegistrationService { headers['Authorization'] = `Bearer ${authToken}`; } - if (Utility.GetUseEnvironmentId() && environmentId) { - headers['x-ms-environment-id'] = environmentId; - } - // Add each server to the config object mcpServers[server.mcpServerName] = { type: 'http', diff --git a/packages/agents-a365-tooling-extensions-langchain/README.md b/packages/agents-a365-tooling-extensions-langchain/README.md index 8fc82d6b..36e41e37 100644 --- a/packages/agents-a365-tooling-extensions-langchain/README.md +++ b/packages/agents-a365-tooling-extensions-langchain/README.md @@ -46,7 +46,6 @@ const mcpClientConfig = {} as ClientConfig; const tools = await toolService.addMcpToolServers( mcpClientConfig, process.env.AGENTIC_USER_ID || '', - process.env.MCP_ENVIRONMENT_ID || '', authorization, turnContext, process.env.MCP_AUTH_TOKEN || '' @@ -123,7 +122,6 @@ const mcpServerConnection: Connection = { url: 'https://your-mcp-server.com', headers: { 'Authorization': `Bearer ${authToken}`, - 'x-ms-environment-id': environmentId, } }; @@ -141,7 +139,6 @@ The following environment variables are commonly used: ```bash # Agent365 Authentication AGENTIC_USER_ID=your-user-id -MCP_ENVIRONMENT_ID=your-environment-id MCP_AUTH_TOKEN=your-auth-token # Agent Configuration @@ -158,7 +155,6 @@ The SDK supports multiple authentication methods: await toolService.addMcpToolServers( mcpClientConfig, userId, - environmentId, authorization, turnContext, '' // Empty auth token - will be acquired automatically @@ -171,7 +167,6 @@ The SDK supports multiple authentication methods: await toolService.addMcpToolServers( mcpClientConfig, userId, - environmentId, authorization, turnContext, process.env.MCP_AUTH_TOKEN diff --git a/packages/agents-a365-tooling-extensions-langchain/src/McpToolRegistrationService.ts b/packages/agents-a365-tooling-extensions-langchain/src/McpToolRegistrationService.ts index bbdab8c7..6d083bf8 100644 --- a/packages/agents-a365-tooling-extensions-langchain/src/McpToolRegistrationService.ts +++ b/packages/agents-a365-tooling-extensions-langchain/src/McpToolRegistrationService.ts @@ -26,7 +26,6 @@ export class McpToolRegistrationService { async addToolServersToAgent( agent: ReactAgent, agentUserId: string, - environmentId: string, authorization: Authorization, turnContext: TurnContext, authToken: string @@ -43,7 +42,8 @@ export class McpToolRegistrationService { // Validate the authentication token Utility.ValidateAuthToken(authToken); - const servers = await this.configService.listToolServers(agentUserId, environmentId, authToken); + const servers = await this.configService.listToolServers(agentUserId, authToken); + const mcpServers: Record = {}; for (const server of servers) { @@ -52,9 +52,6 @@ export class McpToolRegistrationService { if (authToken) { headers['Authorization'] = `Bearer ${authToken}`; } - if (Utility.GetUseEnvironmentId() && environmentId) { - headers['x-ms-environment-id'] = environmentId; - } // Create Connection instance for LangChain agents mcpServers[server.mcpServerName] = { diff --git a/packages/agents-a365-tooling-extensions-openai/README.md b/packages/agents-a365-tooling-extensions-openai/README.md index 7792d1c6..2bb484d2 100644 --- a/packages/agents-a365-tooling-extensions-openai/README.md +++ b/packages/agents-a365-tooling-extensions-openai/README.md @@ -45,7 +45,6 @@ const toolService = new McpToolRegistrationService(); await toolService.addMcpToolServers( agent, process.env.AGENTIC_USER_ID || '', - process.env.MCP_ENVIRONMENT_ID || '', authorization, turnContext, process.env.MCP_AUTH_TOKEN || '' @@ -109,7 +108,6 @@ const mcpServer = new MCPServerStreamableHttp({ requestInit: { headers: { 'Authorization': `Bearer ${authToken}`, - 'x-ms-environment-id': environmentId, } } }); @@ -128,7 +126,6 @@ The following environment variables are commonly used: ```bash # Agent365 Authentication AGENTIC_USER_ID=your-user-id -MCP_ENVIRONMENT_ID=your-environment-id MCP_AUTH_TOKEN=your-auth-token # Agent Configuration @@ -145,7 +142,6 @@ The SDK supports multiple authentication methods: await toolService.addMcpToolServers( agent, userId, - environmentId, authorization, turnContext, '' // Empty auth token - will be acquired automatically @@ -158,7 +154,6 @@ The SDK supports multiple authentication methods: await toolService.addMcpToolServers( agent, userId, - environmentId, authorization, turnContext, process.env.MCP_AUTH_TOKEN diff --git a/packages/agents-a365-tooling-extensions-openai/src/McpToolRegistrationService.ts b/packages/agents-a365-tooling-extensions-openai/src/McpToolRegistrationService.ts index 60f177dc..9c5d3eaa 100644 --- a/packages/agents-a365-tooling-extensions-openai/src/McpToolRegistrationService.ts +++ b/packages/agents-a365-tooling-extensions-openai/src/McpToolRegistrationService.ts @@ -25,7 +25,6 @@ export class McpToolRegistrationService { async addToolServersToAgent( agent: Agent, agentUserId: string, - environmentId: string, authorization: Authorization, turnContext: TurnContext, authToken: string @@ -42,7 +41,7 @@ export class McpToolRegistrationService { // Validate the authentication token Utility.ValidateAuthToken(authToken); - const servers = await this.configService.listToolServers(agentUserId, environmentId, authToken); + const servers = await this.configService.listToolServers(agentUserId, authToken); const mcpServers: MCPServerStreamableHttp[] = []; for (const server of servers) { @@ -51,9 +50,6 @@ export class McpToolRegistrationService { if (authToken) { headers['Authorization'] = `Bearer ${authToken}`; } - if (Utility.GetUseEnvironmentId() && environmentId) { - headers['x-ms-environment-id'] = environmentId; - } // Create MCPServerStreamableHttp instance for OpenAI agents const mcpServer = new MCPServerStreamableHttp({ diff --git a/packages/agents-a365-tooling/README.md b/packages/agents-a365-tooling/README.md index 51246b1a..e24c130c 100644 --- a/packages/agents-a365-tooling/README.md +++ b/packages/agents-a365-tooling/README.md @@ -9,7 +9,7 @@ The package name is **@microsoft/agents-a365-tooling** - **Automatic Server Discovery**: Discovers MCP tool servers in development and production environments - **Environment-Aware Configuration**: Different behavior for development vs production environments - **Flexible Tool Server Sources**: Supports local manifest files and remote tooling gateway -- **URL Generation**: Automatically builds proper MCP server URLs for different environments +- **URL Generation**: Automatically builds proper MCP server URLs - **Error Handling**: Comprehensive error handling and fallback mechanisms ## Core Components @@ -30,7 +30,7 @@ Helper class for URL construction and environment detection. import { McpToolServerConfigurationService } from '@microsoft/agents-a365-tooling'; const configService = new McpToolServerConfigurationService(); -const servers = await configService.listToolServers(agentUserId, environmentId, authToken); +const servers = await configService.listToolServers(agentUserId, authToken); ``` ### Understanding Tool Server Discovery @@ -109,15 +109,13 @@ Create a `ToolingManifest.json` file in your project root: For production environments, ensure you have: 1. **Valid Agent User ID**: The unique identifier for your digital worker/agent -2. **Environment ID**: Your MCP environment identifier (format: `default-[uuid]` or `uuid`) -3. **Authentication Token**: Bearer token for accessing the tooling gateway. +2. **Authentication Token**: Bearer token for accessing the tooling gateway. ```typescript const agentUserId = process.env.AGENTIC_USER_ID || 'your-agent-user-id'; -const environmentId = process.env.MCP_ENVIRONMENT_ID || 'default-your-env-id'; const authToken = process.env.MCP_AUTH_TOKEN || await getAuthToken(); -const servers = await configService.listToolServers(agentUserId, environmentId, authToken); +const servers = await configService.listToolServers(agentUserId, authToken); ``` ## Troubleshooting Tool Discovery @@ -140,7 +138,7 @@ const configService = new McpToolServerConfigurationService(); console.log('Environment:', process.env.NODE_ENV); console.log('Current working directory:', process.cwd()); -const servers = await configService.listToolServers(agentUserId, environmentId, authToken); +const servers = await configService.listToolServers(agentUserId, authToken); console.log('Discovered servers:', servers); ``` @@ -149,7 +147,6 @@ console.log('Discovered servers:', servers); **Problem**: Generated URLs don't work or return 404 errors. **Solutions:** -- Verify `environmentId` is correct and exists - Check `mcpServerUniqueName` values in your manifest match available servers - Ensure the environment's base URL is accessible diff --git a/packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts b/packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts index efce9cfc..711b7c30 100644 --- a/packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts +++ b/packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts @@ -24,15 +24,14 @@ export class McpToolServerConfigurationService { } /** - * Return MCP server definitions for the given agent and environment. In development (NODE_ENV=Development) this reads the local ToolingManifest.json; otherwise it queries the remote tooling gateway. + * Return MCP server definitions for the given agent. In development (NODE_ENV=Development) this reads the local ToolingManifest.json; otherwise it queries the remote tooling gateway. * * @param agentUserId The unique identifier of the digital worker/agent user for which to discover servers. - * @param environmentId The MCP environment identifier (e.g. 'default-...') used to normalize server URLs. * @param authToken Optional bearer token used when querying the remote tooling gateway. * @returns A promise resolving to an array of normalized MCP server configuration objects. */ - async listToolServers(agentUserId: string, environmentId: string, authToken: string): Promise { - return await (this.isDevScenario() ? this.getMCPServerConfigsFromManifest(environmentId) : this.getMCPServerConfigsFromToolingGateway(agentUserId, environmentId, authToken)); + async listToolServers(agentUserId: string, authToken: string): Promise { + return await (this.isDevScenario() ? this.getMCPServerConfigsFromManifest() : this.getMCPServerConfigsFromToolingGateway(agentUserId, authToken)); } /** @@ -74,11 +73,10 @@ export class McpToolServerConfigurationService { * Throws an error if the gateway call fails. * * @param agentId The digital worker/agent id used by the tooling gateway to scope results. - * @param environmentId The MCP environment id used to build normalized MCP server URLs. * @param authToken Optional Bearer token to include in the Authorization header when calling the gateway. * @throws Error when the gateway call fails or returns an unexpected payload. */ - private async getMCPServerConfigsFromToolingGateway(agentUserId: string, environmentId: string, authToken: string): Promise { + private async getMCPServerConfigsFromToolingGateway(agentUserId: string, authToken: string): Promise { // Validate the authentication token Utility.ValidateAuthToken(authToken); @@ -90,7 +88,6 @@ export class McpToolServerConfigurationService { { headers: { 'Authorization': authToken ? `Bearer ${authToken}` : undefined, - 'x-ms-environment-id': Utility.GetUseEnvironmentId() ? environmentId : undefined, }, timeout: 10000 // 10 seconds timeout } @@ -124,7 +121,7 @@ export class McpToolServerConfigurationService { * ] * } */ - private async getMCPServerConfigsFromManifest(environmentId: string): Promise { + private async getMCPServerConfigsFromManifest(): Promise { let manifestPath = path.join(process.cwd(), 'ToolingManifest.json'); if (!fs.existsSync(manifestPath)) { this.logger.warn(`ToolingManifest.json not found at ${manifestPath}, checking argv[1] location.`); @@ -144,7 +141,7 @@ export class McpToolServerConfigurationService { return mcpServers.map((s: MCPServerConfig) => { return { mcpServerName: s.mcpServerName, - url: Utility.BuildMcpServerUrl(environmentId, s.mcpServerName) + url: Utility.BuildMcpServerUrl(s.mcpServerName) }; }); } catch (err: unknown) { diff --git a/packages/agents-a365-tooling/src/Utility.ts b/packages/agents-a365-tooling/src/Utility.ts index 4bcd63ce..c57d8561 100644 --- a/packages/agents-a365-tooling/src/Utility.ts +++ b/packages/agents-a365-tooling/src/Utility.ts @@ -96,36 +96,22 @@ export class Utility { } } - if (!this.GetUseEnvironmentId()) { - return `${this.getMcpPlatformBaseUrl()}/agents/servers`; - } - - return `${this.getMcpPlatformBaseUrl()}/mcp/environments`; + return `${this.getMcpPlatformBaseUrl()}/agents/servers`; } /** - * Build the full URL for accessing a specific MCP server in a given environment. - * This appends the environment id and server name to the base MCP environments URL. + * Build the full URL for accessing a specific MCP server. * * Example: - * Utility.BuildMcpServerUrl('default-abc', 'MyServer') - * // => "https://agent365.svc.cloud.microsoft/mcp/environments/default-abc/servers/MyServer/" + * Utility.BuildMcpServerUrl('MyServer') + * // => "https://agent365.svc.cloud.microsoft/agents/servers/MyServer/" * - * @param environmentId - The environment identifier (for example 'default-...'). * @param serverName - The MCP server resource name. * @returns The fully-qualified MCP server URL including trailing slash. */ - public static BuildMcpServerUrl(environmentId: string, serverName: string) : string { + public static BuildMcpServerUrl(serverName: string) : string { const baseUrl = this.GetMcpBaseUrl(); - if ( - !this.GetUseEnvironmentId() || - (this.getCurrentEnvironment().toLowerCase() === 'development' && - baseUrl.endsWith('servers')) - ) { - return `${baseUrl}/${serverName}`; - } else { - return `${baseUrl}/${environmentId}/servers/${serverName}`; - } + return `${baseUrl}/${serverName}`; } public static GetToolsMode(): ToolsMode { @@ -164,16 +150,4 @@ export class Utility { return MCP_PLATFORM_PROD_BASE_URL; } - - /** - * Determines whether to use the environment ID in MCP server URLs. - * Reads the USE_ENVIRONMENT_ID environment variable (case-insensitive). - * If not set, defaults to 'true'. - * - * @returns {boolean} True if environment ID should be used in URLs; otherwise, false. - */ - public static GetUseEnvironmentId(): boolean { - const useEnvId = process.env.USE_ENVIRONMENT_ID || 'true'; - return useEnvId.toLowerCase() === 'true'; - } } \ No newline at end of file diff --git a/tests-agent/openai-agent-auto-instrument-sample/.env.example b/tests-agent/openai-agent-auto-instrument-sample/.env.example index e3323e09..2593e73c 100644 --- a/tests-agent/openai-agent-auto-instrument-sample/.env.example +++ b/tests-agent/openai-agent-auto-instrument-sample/.env.example @@ -3,7 +3,6 @@ # Mock MCP Server TOOLS_MODE=MockMCPServer MCP_AUTH_TOKEN= -MCP_ENVIRONMENT_ID= # Agent365 Authentication Configuration AGENT_APPLICATION_ID= diff --git a/tests-agent/openai-agent-auto-instrument-sample/README.md b/tests-agent/openai-agent-auto-instrument-sample/README.md index 72196c9b..7b53ad88 100644 --- a/tests-agent/openai-agent-auto-instrument-sample/README.md +++ b/tests-agent/openai-agent-auto-instrument-sample/README.md @@ -40,10 +40,7 @@ If you'd like to use Agentic authentication, you should set the values under Age Otherwise, you can set the value `MCP_AUTH_TOKEN` to authentication against your MCP servers. `NODE_ENV` should be set to `Development` if you'd like to use your tooling manifest. Otherwise, the tooling sdk will -default to retrieving MCP servers from the agent's tooling gateway, in which case you will need to set `AGENTIC_USER_ID` -and `MCP_ENVIRONMENT_ID`. - -**Note** If you are using servers from the MCPPlatform but don't want to use the tooling gateway, you only need to set `MCP_ENVIRONMENT_ID`. +default to retrieving MCP servers from the agent's tooling gateway, in which case you will need to set `AGENTIC_USER_ID`. ### Interacting with your Agent Start the agent application: diff --git a/tests-agent/openai-agent-auto-instrument-sample/src/LocalMcpToolRegistrationService.ts b/tests-agent/openai-agent-auto-instrument-sample/src/LocalMcpToolRegistrationService.ts index 0b31896c..a7ca789e 100644 --- a/tests-agent/openai-agent-auto-instrument-sample/src/LocalMcpToolRegistrationService.ts +++ b/tests-agent/openai-agent-auto-instrument-sample/src/LocalMcpToolRegistrationService.ts @@ -12,7 +12,6 @@ interface McpServerConfig { serverName: string; serverUrl: string; authToken?: string; - environmentId?: string; } /** @@ -22,12 +21,11 @@ export class LocalMcpToolRegistrationService { async addMcpToolServers( agent: Agent, userId: string, - environmentId: string, _turnContext: TurnContext, authToken: string, ): Promise { try { - const serverConfigs = this.getServerConfigurations(userId, environmentId, authToken); + const serverConfigs = this.getServerConfigurations(userId, authToken); console.log(`🔗 Setting up ${serverConfigs.length} MCP servers...`); for (const config of serverConfigs) { @@ -41,19 +39,17 @@ export class LocalMcpToolRegistrationService { } } - private getServerConfigurations(userId: string, environmentId: string, authToken: string): McpServerConfig[] { + private getServerConfigurations(userId: string, authToken: string): McpServerConfig[] { return [ { serverName: 'mcp_MailTools', serverUrl: 'http://localhost:5309', - authToken, - environmentId + authToken }, { serverName: 'mcp_CalendarTools', serverUrl: 'http://localhost:5309', - authToken, - environmentId + authToken } ]; } diff --git a/tests-agent/openai-agent-auto-instrument-sample/src/OpenAIClient.ts b/tests-agent/openai-agent-auto-instrument-sample/src/OpenAIClient.ts index 6b7812a9..0179be32 100644 --- a/tests-agent/openai-agent-auto-instrument-sample/src/OpenAIClient.ts +++ b/tests-agent/openai-agent-auto-instrument-sample/src/OpenAIClient.ts @@ -30,7 +30,6 @@ export async function getClient(authorization: Authorization | undefined, turnCo await localMcpService.addMcpToolServers( agent, process.env.AGENTIC_USER_ID || 'dev-user-id', - process.env.MCP_ENVIRONMENT_ID || 'dev-environment', turnContext, process.env.MCP_AUTH_TOKEN || 'dev-token', ); @@ -39,7 +38,6 @@ export async function getClient(authorization: Authorization | undefined, turnCo await toolService.addToolServersToAgent( agent, process.env.AGENTIC_USER_ID || '', - process.env.MCP_ENVIRONMENT_ID || '', authorization, turnContext, process.env.MCP_AUTH_TOKEN || '',