@microsoft/agents-a365-tooling 0.1.0-preview.95 → 0.2.0-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/McpToolServerConfigurationService.d.ts +75 -7
- package/dist/cjs/McpToolServerConfigurationService.d.ts.map +1 -1
- package/dist/cjs/McpToolServerConfigurationService.js +193 -15
- package/dist/cjs/McpToolServerConfigurationService.js.map +1 -1
- package/dist/cjs/Utility.d.ts +32 -6
- package/dist/cjs/Utility.d.ts.map +1 -1
- package/dist/cjs/Utility.js +59 -19
- package/dist/cjs/Utility.js.map +1 -1
- package/dist/cjs/configuration/ToolingConfiguration.d.ts +51 -0
- package/dist/cjs/configuration/ToolingConfiguration.d.ts.map +1 -0
- package/dist/cjs/configuration/ToolingConfiguration.js +118 -0
- package/dist/cjs/configuration/ToolingConfiguration.js.map +1 -0
- package/dist/cjs/configuration/ToolingConfigurationOptions.d.ts +23 -0
- package/dist/cjs/configuration/ToolingConfigurationOptions.d.ts.map +1 -0
- package/dist/cjs/configuration/ToolingConfigurationOptions.js +5 -0
- package/dist/cjs/configuration/ToolingConfigurationOptions.js.map +1 -0
- package/dist/cjs/configuration/index.d.ts +9 -0
- package/dist/cjs/configuration/index.d.ts.map +1 -0
- package/dist/cjs/configuration/index.js +28 -0
- package/dist/cjs/configuration/index.js.map +1 -0
- package/dist/cjs/contracts.d.ts +6 -0
- package/dist/cjs/contracts.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/McpToolServerConfigurationService.d.ts +75 -7
- package/dist/esm/McpToolServerConfigurationService.d.ts.map +1 -1
- package/dist/esm/McpToolServerConfigurationService.js +194 -16
- package/dist/esm/McpToolServerConfigurationService.js.map +1 -1
- package/dist/esm/Utility.d.ts +32 -6
- package/dist/esm/Utility.d.ts.map +1 -1
- package/dist/esm/Utility.js +59 -19
- package/dist/esm/Utility.js.map +1 -1
- package/dist/esm/configuration/ToolingConfiguration.d.ts +51 -0
- package/dist/esm/configuration/ToolingConfiguration.d.ts.map +1 -0
- package/dist/esm/configuration/ToolingConfiguration.js +113 -0
- package/dist/esm/configuration/ToolingConfiguration.js.map +1 -0
- package/dist/esm/configuration/ToolingConfigurationOptions.d.ts +23 -0
- package/dist/esm/configuration/ToolingConfigurationOptions.d.ts.map +1 -0
- package/dist/esm/configuration/ToolingConfigurationOptions.js +4 -0
- package/dist/esm/configuration/ToolingConfigurationOptions.js.map +1 -0
- package/dist/esm/configuration/index.d.ts +9 -0
- package/dist/esm/configuration/index.d.ts.map +1 -0
- package/dist/esm/configuration/index.js +11 -0
- package/dist/esm/configuration/index.js.map +1 -0
- package/dist/esm/contracts.d.ts +6 -0
- package/dist/esm/contracts.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/Utility.js
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.Utility = void 0;
|
|
6
6
|
const agents_a365_runtime_1 = require("@microsoft/agents-a365-runtime");
|
|
7
|
-
|
|
8
|
-
const MCP_PLATFORM_PROD_BASE_URL = 'https://agent365.svc.cloud.microsoft';
|
|
7
|
+
const configuration_1 = require("./configuration");
|
|
9
8
|
class Utility {
|
|
10
9
|
/**
|
|
11
10
|
* Compose standard headers for MCP tooling requests.
|
|
@@ -20,6 +19,11 @@ class Utility {
|
|
|
20
19
|
const headers = {};
|
|
21
20
|
if (authToken) {
|
|
22
21
|
headers['Authorization'] = `Bearer ${authToken}`;
|
|
22
|
+
// Add x-ms-agentid header with priority fallback (only when authToken present)
|
|
23
|
+
const agentId = this.resolveAgentIdForHeader(authToken, turnContext);
|
|
24
|
+
if (agentId) {
|
|
25
|
+
headers[Utility.HEADER_AGENT_ID] = agentId;
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
const channelId = turnContext?.activity?.channelId;
|
|
25
29
|
const subChannelId = turnContext?.activity?.channelIdSubChannel;
|
|
@@ -34,6 +38,33 @@ class Utility {
|
|
|
34
38
|
}
|
|
35
39
|
return headers;
|
|
36
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolves the best available agent identifier for the x-ms-agentid header.
|
|
43
|
+
* Priority: TurnContext.agenticAppBlueprintId > token claims (xms_par_app_azp > appid > azp) > application name
|
|
44
|
+
*
|
|
45
|
+
* Note: This differs from RuntimeUtility.ResolveAgentIdentity() which resolves the agenticAppId
|
|
46
|
+
* for URL construction. This method resolves the identifier specifically for the x-ms-agentid header.
|
|
47
|
+
*
|
|
48
|
+
* @param authToken The authentication token to extract claims from.
|
|
49
|
+
* @param turnContext Optional TurnContext to extract agent blueprint ID from.
|
|
50
|
+
* @returns Agent ID string or undefined if not available.
|
|
51
|
+
*/
|
|
52
|
+
static resolveAgentIdForHeader(authToken, turnContext) {
|
|
53
|
+
// Priority 1: Agent Blueprint ID from TurnContext
|
|
54
|
+
// The 'from' property may include agenticAppBlueprintId when the request originates from an agentic app
|
|
55
|
+
const blueprintId = turnContext?.activity?.from?.agenticAppBlueprintId;
|
|
56
|
+
if (blueprintId) {
|
|
57
|
+
return blueprintId;
|
|
58
|
+
}
|
|
59
|
+
// Priority 2 & 3: Agent ID from token (xms_par_app_azp > appid > azp)
|
|
60
|
+
// Single decode, checks claims in priority order
|
|
61
|
+
const agentId = agents_a365_runtime_1.Utility.getAgentIdFromToken(authToken);
|
|
62
|
+
if (agentId) {
|
|
63
|
+
return agentId;
|
|
64
|
+
}
|
|
65
|
+
// Priority 4: Application name from npm_package_name or package.json
|
|
66
|
+
return agents_a365_runtime_1.Utility.getApplicationName();
|
|
67
|
+
}
|
|
37
68
|
/**
|
|
38
69
|
* Validates a JWT authentication token.
|
|
39
70
|
* Checks that the token is a valid JWT and is not expired.
|
|
@@ -89,22 +120,25 @@ class Utility {
|
|
|
89
120
|
*
|
|
90
121
|
* Example:
|
|
91
122
|
* Utility.GetToolingGatewayForDigitalWorker(agenticAppId)
|
|
92
|
-
* // => "https://agent365.svc.cloud.microsoft/agents/{agenticAppId}/mcpServers"
|
|
123
|
+
* // => "https://agent365.svc.cloud.microsoft/agents/v2/{agenticAppId}/mcpServers"
|
|
93
124
|
*
|
|
94
125
|
* @param agenticAppId - The unique identifier for the agent identity.
|
|
126
|
+
* @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
|
|
95
127
|
* @returns A fully-qualified URL pointing at the tooling gateway for the agent.
|
|
128
|
+
* @deprecated This method is for internal use only. Use McpToolServerConfigurationService.listToolServers() instead.
|
|
96
129
|
*/
|
|
97
|
-
static GetToolingGatewayForDigitalWorker(agenticAppId) {
|
|
98
|
-
|
|
99
|
-
return `${this.getMcpPlatformBaseUrl()}/agents/${agenticAppId}/mcpServers`;
|
|
130
|
+
static GetToolingGatewayForDigitalWorker(agenticAppId, configProvider) {
|
|
131
|
+
return `${this.getMcpPlatformBaseUrl(configProvider)}/agents/v2/${agenticAppId}/mcpServers`;
|
|
100
132
|
}
|
|
101
133
|
/**
|
|
102
134
|
* Get the base URL used to query MCP environments.
|
|
103
135
|
*
|
|
136
|
+
* @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
|
|
104
137
|
* @returns The base MCP environments URL.
|
|
138
|
+
* @deprecated This method is for internal use only. Use McpToolServerConfigurationService instead.
|
|
105
139
|
*/
|
|
106
|
-
static GetMcpBaseUrl() {
|
|
107
|
-
return `${this.getMcpPlatformBaseUrl()}/agents/servers`;
|
|
140
|
+
static GetMcpBaseUrl(configProvider) {
|
|
141
|
+
return `${this.getMcpPlatformBaseUrl(configProvider)}/agents/servers`;
|
|
108
142
|
}
|
|
109
143
|
/**
|
|
110
144
|
* Build the full URL for accessing a specific MCP server.
|
|
@@ -114,39 +148,45 @@ class Utility {
|
|
|
114
148
|
* // => "https://agent365.svc.cloud.microsoft/agents/servers/MyServer/"
|
|
115
149
|
*
|
|
116
150
|
* @param serverName - The MCP server resource name.
|
|
151
|
+
* @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
|
|
117
152
|
* @returns The fully-qualified MCP server URL including trailing slash.
|
|
153
|
+
* @deprecated This method is for internal use only. Use McpToolServerConfigurationService instead.
|
|
118
154
|
*/
|
|
119
|
-
static BuildMcpServerUrl(serverName) {
|
|
120
|
-
const baseUrl = this.GetMcpBaseUrl();
|
|
121
|
-
return `${baseUrl}/${serverName}
|
|
155
|
+
static BuildMcpServerUrl(serverName, configProvider) {
|
|
156
|
+
const baseUrl = this.GetMcpBaseUrl(configProvider);
|
|
157
|
+
return `${baseUrl}/${serverName}/`;
|
|
122
158
|
}
|
|
123
159
|
/**
|
|
124
|
-
* Gets the base URL for MCP platform
|
|
160
|
+
* Gets the base URL for MCP platform from configuration.
|
|
125
161
|
*
|
|
162
|
+
* @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
|
|
126
163
|
* @returns The base URL for MCP platform.
|
|
164
|
+
* @deprecated This method is for internal use only. Use ToolingConfiguration.mcpPlatformEndpoint instead.
|
|
127
165
|
*/
|
|
128
|
-
static getMcpPlatformBaseUrl() {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
return MCP_PLATFORM_PROD_BASE_URL;
|
|
166
|
+
static getMcpPlatformBaseUrl(configProvider) {
|
|
167
|
+
const provider = configProvider ?? configuration_1.defaultToolingConfigurationProvider;
|
|
168
|
+
return provider.getConfiguration().mcpPlatformEndpoint;
|
|
133
169
|
}
|
|
134
170
|
/**
|
|
135
171
|
* Constructs the endpoint URL for sending chat history to the MCP platform for real-time threat protection.
|
|
136
172
|
*
|
|
173
|
+
* @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
|
|
137
174
|
* @returns An absolute URL that tooling components can use to send or retrieve chat messages for
|
|
138
175
|
* real-time threat protection scenarios.
|
|
139
176
|
* @remarks
|
|
140
177
|
* Call this method when constructing HTTP requests that need to access the chat-message history
|
|
141
178
|
* for real-time threat protection. The returned URL already includes the MCP platform base address
|
|
142
179
|
* and the fixed path segment `/agents/real-time-threat-protection/chat-message`.
|
|
180
|
+
* @deprecated This method is for internal use only. Use McpToolServerConfigurationService.sendChatHistory() instead.
|
|
143
181
|
*/
|
|
144
|
-
static GetChatHistoryEndpoint() {
|
|
145
|
-
return `${this.getMcpPlatformBaseUrl()}/agents/real-time-threat-protection/chat-message`;
|
|
182
|
+
static GetChatHistoryEndpoint(configProvider) {
|
|
183
|
+
return `${this.getMcpPlatformBaseUrl(configProvider)}/agents/real-time-threat-protection/chat-message`;
|
|
146
184
|
}
|
|
147
185
|
}
|
|
148
186
|
exports.Utility = Utility;
|
|
149
187
|
Utility.HEADER_CHANNEL_ID = 'x-ms-channel-id';
|
|
150
188
|
Utility.HEADER_SUBCHANNEL_ID = 'x-ms-subchannel-id';
|
|
151
189
|
Utility.HEADER_USER_AGENT = 'User-Agent';
|
|
190
|
+
/** Header name for sending the agent identifier to MCP platform for logging/analytics. */
|
|
191
|
+
Utility.HEADER_AGENT_ID = 'x-ms-agentid';
|
|
152
192
|
//# sourceMappingURL=Utility.js.map
|
package/dist/cjs/Utility.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utility.js","sourceRoot":"","sources":["../../src/Utility.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;
|
|
1
|
+
{"version":3,"file":"Utility.js","sourceRoot":"","sources":["../../src/Utility.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC,wEAAmG;AAGnG,mDAA4F;AAE5F,MAAa,OAAO;IAOlB;;;;;;;;OAQG;IACI,MAAM,CAAC,qBAAqB,CACjC,SAAkB,EAClB,WAAyB,EACzB,OAAqB;QAErB,MAAM,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AAxNwB,yBAAiB,GAAG,iBAAiB,CAAC;AACtC,4BAAoB,GAAG,oBAAoB,CAAC;AAC5C,yBAAiB,GAAG,YAAY,CAAC;AACxD,0FAA0F;AACnE,uBAAe,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RuntimeConfiguration } from '@microsoft/agents-a365-runtime';
|
|
2
|
+
import { ToolingConfigurationOptions } from './ToolingConfigurationOptions';
|
|
3
|
+
import { MCPServerConfig } from '../contracts';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the OAuth scope to request for a given MCP server.
|
|
6
|
+
*
|
|
7
|
+
* V2 servers carry their own audience in the `audience` field and get a per-audience token.
|
|
8
|
+
* V1 servers (no `audience`, or audience matching the shared scope's own audience in plain
|
|
9
|
+
* or api:// form) fall back to `sharedScope` — the configured mcpPlatformAuthenticationScope.
|
|
10
|
+
*
|
|
11
|
+
* @param server The MCP server config returned by the gateway or manifest.
|
|
12
|
+
* @param sharedScope The configured shared scope (mcpPlatformAuthenticationScope).
|
|
13
|
+
* Defaults to the prod ATG scope so that external callers without a custom config
|
|
14
|
+
* continue to work without passing the argument.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveTokenScopeForServer(server: MCPServerConfig, sharedScope?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for tooling package.
|
|
19
|
+
* Inherits runtime settings and adds tooling-specific settings.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ToolingConfiguration extends RuntimeConfiguration {
|
|
22
|
+
protected get toolingOverrides(): ToolingConfigurationOptions;
|
|
23
|
+
constructor(overrides?: ToolingConfigurationOptions);
|
|
24
|
+
get mcpPlatformEndpoint(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to use the ToolingManifest.json file instead of gateway discovery.
|
|
27
|
+
* Returns true when NODE_ENV is set to 'development' (case-insensitive), or
|
|
28
|
+
* when explicitly overridden via configuration.
|
|
29
|
+
*/
|
|
30
|
+
get useToolingManifest(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the MCP platform authentication scope.
|
|
33
|
+
* Used by AgenticAuthenticationService for token exchange.
|
|
34
|
+
* Trims whitespace to prevent token exchange failures.
|
|
35
|
+
*/
|
|
36
|
+
get mcpPlatformAuthenticationScope(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the dev-mode bearer token for an MCP server by name.
|
|
39
|
+
* Checks BEARER_TOKEN_<SERVERNAME_UPPER> first, then falls back to BEARER_TOKEN.
|
|
40
|
+
* Returns undefined when the variable is not set (no Authorization header will be attached).
|
|
41
|
+
*/
|
|
42
|
+
getBearerTokenForServer(mcpServerName: string): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Returns true when a per-server bearer token env var (BEARER_TOKEN_<SERVERNAME_UPPER>)
|
|
45
|
+
* is explicitly set for the given server, false when only the shared BEARER_TOKEN fallback
|
|
46
|
+
* would be used. Used to detect V2 servers that are silently falling back to a
|
|
47
|
+
* wrong-audience token in dev mode.
|
|
48
|
+
*/
|
|
49
|
+
hasPerServerBearerToken(mcpServerName: string): boolean;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=ToolingConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolingConfiguration.d.ts","sourceRoot":"","sources":["../../../src/configuration/ToolingConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAM/C;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,eAAe,EACvB,WAAW,GAAE,MAA+C,GAC3D,MAAM,CAoBR;AAUD;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,oBAAoB;IAE5D,SAAS,KAAK,gBAAgB,IAAI,2BAA2B,CAE5D;gBAEW,SAAS,CAAC,EAAE,2BAA2B;IAMnD,IAAI,mBAAmB,IAAI,MAAM,CAQhC;IAED;;;;OAIG;IACH,IAAI,kBAAkB,IAAI,OAAO,CAKhC;IAED;;;;OAIG;IACH,IAAI,8BAA8B,IAAI,MAAM,CAQ3C;IAED;;;;OAIG;IACH,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKlE;;;;;OAKG;IACH,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAIxD"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.ToolingConfiguration = void 0;
|
|
6
|
+
exports.resolveTokenScopeForServer = resolveTokenScopeForServer;
|
|
7
|
+
const agents_a365_runtime_1 = require("@microsoft/agents-a365-runtime");
|
|
8
|
+
// Constants for tooling-specific settings
|
|
9
|
+
const MCP_PLATFORM_PROD_BASE_URL = 'https://agent365.svc.cloud.microsoft';
|
|
10
|
+
const PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = 'ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default';
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the OAuth scope to request for a given MCP server.
|
|
13
|
+
*
|
|
14
|
+
* V2 servers carry their own audience in the `audience` field and get a per-audience token.
|
|
15
|
+
* V1 servers (no `audience`, or audience matching the shared scope's own audience in plain
|
|
16
|
+
* or api:// form) fall back to `sharedScope` — the configured mcpPlatformAuthenticationScope.
|
|
17
|
+
*
|
|
18
|
+
* @param server The MCP server config returned by the gateway or manifest.
|
|
19
|
+
* @param sharedScope The configured shared scope (mcpPlatformAuthenticationScope).
|
|
20
|
+
* Defaults to the prod ATG scope so that external callers without a custom config
|
|
21
|
+
* continue to work without passing the argument.
|
|
22
|
+
*/
|
|
23
|
+
function resolveTokenScopeForServer(server, sharedScope = PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE) {
|
|
24
|
+
if (server.audience) {
|
|
25
|
+
// Extract the audience portion of sharedScope (everything before the last '/').
|
|
26
|
+
// e.g. 'ea9ffc3e-.../.default' → 'ea9ffc3e-...'
|
|
27
|
+
// 'api://ea9ffc3e-.../.default' → 'api://ea9ffc3e-...'
|
|
28
|
+
const sharedAudience = sharedScope.slice(0, sharedScope.lastIndexOf('/'));
|
|
29
|
+
// Build the alternate form so we match both 'guid' and 'api://guid'.
|
|
30
|
+
const sharedAudienceAlt = sharedAudience.startsWith('api://')
|
|
31
|
+
? sharedAudience.slice(6) // 'api://guid' → 'guid'
|
|
32
|
+
: `api://${sharedAudience}`; // 'guid' → 'api://guid'
|
|
33
|
+
if (server.audience !== sharedAudience && server.audience !== sharedAudienceAlt) {
|
|
34
|
+
// V2 server: use its own audience with explicit scope or /.default fallback.
|
|
35
|
+
return server.scope
|
|
36
|
+
? `${server.audience}/${server.scope}`
|
|
37
|
+
: `${server.audience}/.default`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// V1 server: no audience, or audience matches the shared ATG audience.
|
|
41
|
+
return sharedScope;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Normalize URL by trimming whitespace and removing trailing slashes.
|
|
45
|
+
* Prevents double-slash issues in URL construction (e.g., "https://example.com//api").
|
|
46
|
+
*/
|
|
47
|
+
function normalizeUrl(url) {
|
|
48
|
+
return url.trim().replace(/\/+$/, '');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for tooling package.
|
|
52
|
+
* Inherits runtime settings and adds tooling-specific settings.
|
|
53
|
+
*/
|
|
54
|
+
class ToolingConfiguration extends agents_a365_runtime_1.RuntimeConfiguration {
|
|
55
|
+
// Type-safe access to tooling overrides
|
|
56
|
+
get toolingOverrides() {
|
|
57
|
+
return this.overrides;
|
|
58
|
+
}
|
|
59
|
+
constructor(overrides) {
|
|
60
|
+
super(overrides);
|
|
61
|
+
}
|
|
62
|
+
// Inherited: clusterCategory, isDevelopmentEnvironment, isNodeEnvDevelopment
|
|
63
|
+
get mcpPlatformEndpoint() {
|
|
64
|
+
const override = this.toolingOverrides.mcpPlatformEndpoint?.();
|
|
65
|
+
if (override)
|
|
66
|
+
return normalizeUrl(override);
|
|
67
|
+
const envValue = process.env.MCP_PLATFORM_ENDPOINT?.trim();
|
|
68
|
+
if (envValue)
|
|
69
|
+
return normalizeUrl(envValue);
|
|
70
|
+
return MCP_PLATFORM_PROD_BASE_URL;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether to use the ToolingManifest.json file instead of gateway discovery.
|
|
74
|
+
* Returns true when NODE_ENV is set to 'development' (case-insensitive), or
|
|
75
|
+
* when explicitly overridden via configuration.
|
|
76
|
+
*/
|
|
77
|
+
get useToolingManifest() {
|
|
78
|
+
const override = this.toolingOverrides.useToolingManifest?.();
|
|
79
|
+
if (override !== undefined)
|
|
80
|
+
return override;
|
|
81
|
+
return this.isNodeEnvDevelopment;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the MCP platform authentication scope.
|
|
85
|
+
* Used by AgenticAuthenticationService for token exchange.
|
|
86
|
+
* Trims whitespace to prevent token exchange failures.
|
|
87
|
+
*/
|
|
88
|
+
get mcpPlatformAuthenticationScope() {
|
|
89
|
+
const override = this.toolingOverrides.mcpPlatformAuthenticationScope?.()?.trim();
|
|
90
|
+
if (override)
|
|
91
|
+
return override;
|
|
92
|
+
const envValue = process.env.MCP_PLATFORM_AUTHENTICATION_SCOPE?.trim();
|
|
93
|
+
if (envValue)
|
|
94
|
+
return envValue;
|
|
95
|
+
return PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the dev-mode bearer token for an MCP server by name.
|
|
99
|
+
* Checks BEARER_TOKEN_<SERVERNAME_UPPER> first, then falls back to BEARER_TOKEN.
|
|
100
|
+
* Returns undefined when the variable is not set (no Authorization header will be attached).
|
|
101
|
+
*/
|
|
102
|
+
getBearerTokenForServer(mcpServerName) {
|
|
103
|
+
const key = mcpServerName.toUpperCase();
|
|
104
|
+
return process.env[`BEARER_TOKEN_${key}`] ?? process.env['BEARER_TOKEN'];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns true when a per-server bearer token env var (BEARER_TOKEN_<SERVERNAME_UPPER>)
|
|
108
|
+
* is explicitly set for the given server, false when only the shared BEARER_TOKEN fallback
|
|
109
|
+
* would be used. Used to detect V2 servers that are silently falling back to a
|
|
110
|
+
* wrong-audience token in dev mode.
|
|
111
|
+
*/
|
|
112
|
+
hasPerServerBearerToken(mcpServerName) {
|
|
113
|
+
const key = mcpServerName.toUpperCase();
|
|
114
|
+
return !!process.env[`BEARER_TOKEN_${key}`];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.ToolingConfiguration = ToolingConfiguration;
|
|
118
|
+
//# sourceMappingURL=ToolingConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolingConfiguration.js","sourceRoot":"","sources":["../../../src/configuration/ToolingConfiguration.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAsBlC,gEAuBC;AA3CD,wEAAsE;AAItE,0CAA0C;AAC1C,MAAM,0BAA0B,GAAG,sCAAsC,CAAC;AAC1E,MAAM,sCAAsC,GAAG,+CAA+C,CAAC;AAE/F;;;;;;;;;;;GAWG;AACH,SAAgB,0BAA0B,CACxC,MAAuB,EACvB,cAAsB,sCAAsC;IAE5D,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,gFAAgF;QAChF,qDAAqD;QACrD,4DAA4D;QAC5D,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1E,qEAAqE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pC,CAAC;IAED;;;;OAIG;IACH,IAAI,kBAAkB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC9D,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QAE5C,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,IAAI,8BAA8B;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,8BAA8B,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QAClF,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAE9B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,IAAI,EAAE,CAAC;QACvE,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAE9B,OAAO,sCAAsC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,uBAAuB,CAAC,aAAqB;QAC3C,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACH,uBAAuB,CAAC,aAAqB;QAC3C,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACxC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;IAC9C,CAAC;CACF;AArED,oDAqEC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RuntimeConfigurationOptions } from '@microsoft/agents-a365-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Tooling configuration options - extends runtime options.
|
|
4
|
+
* All overrides are functions called on each property access.
|
|
5
|
+
*
|
|
6
|
+
* Inherited from RuntimeConfigurationOptions:
|
|
7
|
+
* - clusterCategory
|
|
8
|
+
* - isNodeEnvDevelopment
|
|
9
|
+
*/
|
|
10
|
+
export type ToolingConfigurationOptions = RuntimeConfigurationOptions & {
|
|
11
|
+
mcpPlatformEndpoint?: () => string;
|
|
12
|
+
/**
|
|
13
|
+
* Override for using ToolingManifest.json vs gateway discovery.
|
|
14
|
+
* Falls back to inherited isNodeEnvDevelopment.
|
|
15
|
+
*/
|
|
16
|
+
useToolingManifest?: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Override for MCP platform authentication scope.
|
|
19
|
+
* Falls back to MCP_PLATFORM_AUTHENTICATION_SCOPE env var, then production default.
|
|
20
|
+
*/
|
|
21
|
+
mcpPlatformAuthenticationScope?: () => string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=ToolingConfigurationOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolingConfigurationOptions.d.ts","sourceRoot":"","sources":["../../../src/configuration/ToolingConfigurationOptions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG,2BAA2B,GAAG;IACtE,mBAAmB,CAAC,EAAE,MAAM,MAAM,CAAC;IACnC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC;IACnC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolingConfigurationOptions.js","sourceRoot":"","sources":["../../../src/configuration/ToolingConfigurationOptions.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DefaultConfigurationProvider } from '@microsoft/agents-a365-runtime';
|
|
2
|
+
import { ToolingConfiguration } from './ToolingConfiguration';
|
|
3
|
+
export * from './ToolingConfigurationOptions';
|
|
4
|
+
export * from './ToolingConfiguration';
|
|
5
|
+
/**
|
|
6
|
+
* Shared default provider for ToolingConfiguration.
|
|
7
|
+
*/
|
|
8
|
+
export declare const defaultToolingConfigurationProvider: DefaultConfigurationProvider<ToolingConfiguration>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/configuration/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,mCAAmC,oDACoB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.defaultToolingConfigurationProvider = void 0;
|
|
20
|
+
const agents_a365_runtime_1 = require("@microsoft/agents-a365-runtime");
|
|
21
|
+
const ToolingConfiguration_1 = require("./ToolingConfiguration");
|
|
22
|
+
__exportStar(require("./ToolingConfigurationOptions"), exports);
|
|
23
|
+
__exportStar(require("./ToolingConfiguration"), exports);
|
|
24
|
+
/**
|
|
25
|
+
* Shared default provider for ToolingConfiguration.
|
|
26
|
+
*/
|
|
27
|
+
exports.defaultToolingConfigurationProvider = new agents_a365_runtime_1.DefaultConfigurationProvider(() => new ToolingConfiguration_1.ToolingConfiguration());
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configuration/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;;AAElC,wEAA8E;AAC9E,iEAA8D;AAE9D,gEAA8C;AAC9C,yDAAuC;AAEvC;;GAEG;AACU,QAAA,mCAAmC,GAC9C,IAAI,kDAA4B,CAAC,GAAG,EAAE,CAAC,IAAI,2CAAoB,EAAE,CAAC,CAAC"}
|
package/dist/cjs/contracts.d.ts
CHANGED
|
@@ -2,10 +2,16 @@ export interface MCPServerConfig {
|
|
|
2
2
|
mcpServerName: string;
|
|
3
3
|
url: string;
|
|
4
4
|
headers?: Record<string, string>;
|
|
5
|
+
audience?: string;
|
|
6
|
+
scope?: string;
|
|
7
|
+
publisher?: string;
|
|
5
8
|
}
|
|
6
9
|
export type MCPServerManifestEntry = {
|
|
7
10
|
url?: string;
|
|
8
11
|
headers?: Record<string, string>;
|
|
12
|
+
audience?: string;
|
|
13
|
+
scope?: string;
|
|
14
|
+
publisher?: string;
|
|
9
15
|
} & ({
|
|
10
16
|
mcpServerName: string;
|
|
11
17
|
mcpServerUniqueName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/contracts.ts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B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,WAAW,CAAC;AAC1B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
2
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
5
|
if (k2 === undefined) k2 = k;
|
|
4
6
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -18,4 +20,5 @@ __exportStar(require("./Utility"), exports);
|
|
|
18
20
|
__exportStar(require("./McpToolServerConfigurationService"), exports);
|
|
19
21
|
__exportStar(require("./contracts"), exports);
|
|
20
22
|
__exportStar(require("./models"), exports);
|
|
23
|
+
__exportStar(require("./configuration"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;AAElC,4CAA0B;AAC1B,sEAAoD;AACpD,8CAA4B;AAC5B,2CAAyB;AACzB,kDAAgC"}
|
|
@@ -1,34 +1,85 @@
|
|
|
1
|
-
import { TurnContext } from '@microsoft/agents-hosting';
|
|
2
|
-
import { OperationResult } from '@microsoft/agents-a365-runtime';
|
|
1
|
+
import { TurnContext, Authorization } from '@microsoft/agents-hosting';
|
|
2
|
+
import { OperationResult, IConfigurationProvider } from '@microsoft/agents-a365-runtime';
|
|
3
3
|
import { MCPServerConfig, McpClientTool, ToolOptions } from './contracts';
|
|
4
4
|
import { ChatHistoryMessage } from './models/index';
|
|
5
|
+
import { ToolingConfiguration } from './configuration';
|
|
5
6
|
/**
|
|
6
7
|
* Service responsible for discovering and normalizing MCP (Model Context Protocol)
|
|
7
8
|
* tool servers and producing configuration objects consumable by the Claude SDK.
|
|
8
9
|
*/
|
|
9
10
|
export declare class McpToolServerConfigurationService {
|
|
10
11
|
private readonly logger;
|
|
12
|
+
private readonly configProvider;
|
|
11
13
|
/**
|
|
12
14
|
* Construct a McpToolServerConfigurationService.
|
|
15
|
+
* @param configProvider Optional configuration provider. Defaults to defaultToolingConfigurationProvider if not specified.
|
|
13
16
|
*/
|
|
14
|
-
constructor();
|
|
17
|
+
constructor(configProvider?: IConfigurationProvider<ToolingConfiguration>);
|
|
15
18
|
/**
|
|
16
19
|
* 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.
|
|
17
20
|
*
|
|
21
|
+
* @deprecated Use the overload with TurnContext and Authorization parameters instead to enable x-ms-agentid header support and automatic token generation.
|
|
18
22
|
* @param agenticAppId The agentic app id for which to discover servers.
|
|
19
|
-
* @param authToken
|
|
23
|
+
* @param authToken Bearer token used when querying the remote tooling gateway.
|
|
20
24
|
* @returns A promise resolving to an array of normalized MCP server configuration objects.
|
|
21
25
|
*/
|
|
22
26
|
listToolServers(agenticAppId: string, authToken: string): Promise<MCPServerConfig[]>;
|
|
23
27
|
/**
|
|
24
28
|
* 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.
|
|
25
29
|
*
|
|
30
|
+
* @deprecated Use the overload with TurnContext and Authorization parameters instead to enable x-ms-agentid header support and automatic token generation.
|
|
26
31
|
* @param agenticAppId The agentic app id for which to discover servers.
|
|
27
|
-
* @param authToken
|
|
32
|
+
* @param authToken Bearer token used when querying the remote tooling gateway.
|
|
28
33
|
* @param options Optional tool options when calling the gateway.
|
|
29
34
|
* @returns A promise resolving to an array of normalized MCP server configuration objects.
|
|
30
35
|
*/
|
|
31
36
|
listToolServers(agenticAppId: string, authToken: string, options?: ToolOptions): Promise<MCPServerConfig[]>;
|
|
37
|
+
/**
|
|
38
|
+
* 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.
|
|
39
|
+
* This overload automatically resolves the agenticAppId from the TurnContext and generates the auth token if not provided.
|
|
40
|
+
*
|
|
41
|
+
* @param turnContext The TurnContext of the current request.
|
|
42
|
+
* @param authorization Authorization object for token exchange.
|
|
43
|
+
* @param authHandlerName The name of the auth handler to use for token exchange.
|
|
44
|
+
* @param authToken Optional bearer token. If not provided, will be auto-generated via token exchange.
|
|
45
|
+
* @param options Optional tool options when calling the gateway.
|
|
46
|
+
* @returns A promise resolving to an array of normalized MCP server configuration objects.
|
|
47
|
+
*/
|
|
48
|
+
listToolServers(turnContext: TurnContext, authorization: Authorization, authHandlerName: string, authToken?: string, options?: ToolOptions): Promise<MCPServerConfig[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Acquire one token per unique audience across the provided server list and attach
|
|
51
|
+
* the correct `Authorization: Bearer` header to each server's headers.
|
|
52
|
+
* V1 servers (no `audience` field, or ATG AppId) all share the same token (one exchange).
|
|
53
|
+
* V2 servers each get a token scoped to their own audience GUID.
|
|
54
|
+
* Token acquisition is delegated to `acquire`, enabling different strategies in dev
|
|
55
|
+
* (env vars via createDevTokenAcquirer) and prod (OBO via createOboTokenAcquirer)
|
|
56
|
+
* while keeping scope resolution, deduplication, and header attachment identical.
|
|
57
|
+
*/
|
|
58
|
+
private attachPerAudienceTokens;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a TokenAcquirer that resolves tokens from environment variables (local dev only).
|
|
61
|
+
* Resolution order per server:
|
|
62
|
+
* 1. BEARER_TOKEN_<MCPSERVERNAME_UPPER> — per-server token (effective for V2 unique audiences)
|
|
63
|
+
* 2. BEARER_TOKEN — shared fallback (V1 servers share one token)
|
|
64
|
+
* Returns null when neither variable is set; no Authorization header is attached.
|
|
65
|
+
* Emits a warning when a V2 server (distinct audience) falls back to the shared BEARER_TOKEN,
|
|
66
|
+
* because that token is scoped to the shared ATG audience and will cause a 401 at the server.
|
|
67
|
+
*/
|
|
68
|
+
private createDevTokenAcquirer;
|
|
69
|
+
/**
|
|
70
|
+
* Returns a TokenAcquirer for the deprecated legacy (agenticAppId, authToken) overload in prod.
|
|
71
|
+
* V1 servers (ATG shared scope) receive the caller-supplied authToken directly.
|
|
72
|
+
* V2 servers (per-audience scope) throw immediately — OBO exchange requires Authorization and
|
|
73
|
+
* authHandlerName which the legacy signature does not provide; callers must migrate to the
|
|
74
|
+
* TurnContext-based overload.
|
|
75
|
+
*/
|
|
76
|
+
private createLegacyProdTokenAcquirer;
|
|
77
|
+
/**
|
|
78
|
+
* Returns a TokenAcquirer that performs OBO token exchange via AgenticAuthenticationService.
|
|
79
|
+
* Throws if the exchange returns null so callers receive an explicit error rather than a
|
|
80
|
+
* silently missing Authorization header.
|
|
81
|
+
*/
|
|
82
|
+
private createOboTokenAcquirer;
|
|
32
83
|
/**
|
|
33
84
|
* Connect to the MCP server and return tools with names prefixed by the server name.
|
|
34
85
|
* Throws if the server URL is missing or the client fails to list tools.
|
|
@@ -69,6 +120,7 @@ export declare class McpToolServerConfigurationService {
|
|
|
69
120
|
*
|
|
70
121
|
* @param agenticAppId The agentic app id used by the tooling gateway to scope results.
|
|
71
122
|
* @param authToken Optional Bearer token to include in the Authorization header when calling the gateway.
|
|
123
|
+
* @param turnContext Optional TurnContext for extracting agent blueprint ID for request headers.
|
|
72
124
|
* @param options Optional tool options when calling the gateway.
|
|
73
125
|
* @throws Error when the gateway call fails or returns an unexpected payload.
|
|
74
126
|
*/
|
|
@@ -100,10 +152,26 @@ export declare class McpToolServerConfigurationService {
|
|
|
100
152
|
*/
|
|
101
153
|
private getMCPServerConfigsFromManifest;
|
|
102
154
|
/**
|
|
103
|
-
* Detect if the process is running in a development scenario based on
|
|
155
|
+
* Detect if the process is running in a development scenario based on configuration.
|
|
104
156
|
*
|
|
105
|
-
* @returns {boolean} True when running in a development environment.
|
|
157
|
+
* @returns {boolean} True when running in a development environment (NODE_ENV=Development).
|
|
106
158
|
*/
|
|
107
159
|
private isDevScenario;
|
|
160
|
+
/**
|
|
161
|
+
* Gets the base URL for MCP platform from configuration.
|
|
162
|
+
*/
|
|
163
|
+
private getMcpPlatformBaseUrl;
|
|
164
|
+
/**
|
|
165
|
+
* Construct the tooling gateway URL for a given agent identity.
|
|
166
|
+
*/
|
|
167
|
+
private getToolingGatewayUrl;
|
|
168
|
+
/**
|
|
169
|
+
* Build the full URL for accessing a specific MCP server.
|
|
170
|
+
*/
|
|
171
|
+
private buildMcpServerUrl;
|
|
172
|
+
/**
|
|
173
|
+
* Constructs the endpoint URL for sending chat history.
|
|
174
|
+
*/
|
|
175
|
+
private getChatHistoryEndpoint;
|
|
108
176
|
}
|
|
109
177
|
//# sourceMappingURL=McpToolServerConfigurationService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpToolServerConfigurationService.d.ts","sourceRoot":"","sources":["../../src/McpToolServerConfigurationService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"McpToolServerConfigurationService.d.ts","sourceRoot":"","sources":["../../src/McpToolServerConfigurationService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,E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