@microsoft/agents-a365-tooling 0.1.0-preview.103

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.
Files changed (83) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +33 -0
  3. package/dist/cjs/McpToolServerConfigurationService.d.ts +143 -0
  4. package/dist/cjs/McpToolServerConfigurationService.d.ts.map +1 -0
  5. package/dist/cjs/McpToolServerConfigurationService.js +277 -0
  6. package/dist/cjs/McpToolServerConfigurationService.js.map +1 -0
  7. package/dist/cjs/Utility.d.ts +106 -0
  8. package/dist/cjs/Utility.d.ts.map +1 -0
  9. package/dist/cjs/Utility.js +192 -0
  10. package/dist/cjs/Utility.js.map +1 -0
  11. package/dist/cjs/configuration/ToolingConfiguration.d.ts +24 -0
  12. package/dist/cjs/configuration/ToolingConfiguration.d.ts.map +1 -0
  13. package/dist/cjs/configuration/ToolingConfiguration.js +66 -0
  14. package/dist/cjs/configuration/ToolingConfiguration.js.map +1 -0
  15. package/dist/cjs/configuration/ToolingConfigurationOptions.d.ts +23 -0
  16. package/dist/cjs/configuration/ToolingConfigurationOptions.d.ts.map +1 -0
  17. package/dist/cjs/configuration/ToolingConfigurationOptions.js +5 -0
  18. package/dist/cjs/configuration/ToolingConfigurationOptions.js.map +1 -0
  19. package/dist/cjs/configuration/index.d.ts +9 -0
  20. package/dist/cjs/configuration/index.d.ts.map +1 -0
  21. package/dist/cjs/configuration/index.js +28 -0
  22. package/dist/cjs/configuration/index.js.map +1 -0
  23. package/dist/cjs/contracts.d.ts +30 -0
  24. package/dist/cjs/contracts.d.ts.map +1 -0
  25. package/dist/cjs/contracts.js +5 -0
  26. package/dist/cjs/contracts.js.map +1 -0
  27. package/dist/cjs/index.d.ts +6 -0
  28. package/dist/cjs/index.d.ts.map +1 -0
  29. package/dist/cjs/index.js +24 -0
  30. package/dist/cjs/index.js.map +1 -0
  31. package/dist/cjs/models/ChatHistoryMessage.d.ts +22 -0
  32. package/dist/cjs/models/ChatHistoryMessage.d.ts.map +1 -0
  33. package/dist/cjs/models/ChatHistoryMessage.js +5 -0
  34. package/dist/cjs/models/ChatHistoryMessage.js.map +1 -0
  35. package/dist/cjs/models/ChatMessageRequest.d.ts +23 -0
  36. package/dist/cjs/models/ChatMessageRequest.d.ts.map +1 -0
  37. package/dist/cjs/models/ChatMessageRequest.js +5 -0
  38. package/dist/cjs/models/ChatMessageRequest.js.map +1 -0
  39. package/dist/cjs/models/index.d.ts +3 -0
  40. package/dist/cjs/models/index.d.ts.map +1 -0
  41. package/dist/cjs/models/index.js +21 -0
  42. package/dist/cjs/models/index.js.map +1 -0
  43. package/dist/esm/McpToolServerConfigurationService.d.ts +143 -0
  44. package/dist/esm/McpToolServerConfigurationService.d.ts.map +1 -0
  45. package/dist/esm/McpToolServerConfigurationService.js +270 -0
  46. package/dist/esm/McpToolServerConfigurationService.js.map +1 -0
  47. package/dist/esm/Utility.d.ts +106 -0
  48. package/dist/esm/Utility.d.ts.map +1 -0
  49. package/dist/esm/Utility.js +188 -0
  50. package/dist/esm/Utility.js.map +1 -0
  51. package/dist/esm/configuration/ToolingConfiguration.d.ts +24 -0
  52. package/dist/esm/configuration/ToolingConfiguration.d.ts.map +1 -0
  53. package/dist/esm/configuration/ToolingConfiguration.js +62 -0
  54. package/dist/esm/configuration/ToolingConfiguration.js.map +1 -0
  55. package/dist/esm/configuration/ToolingConfigurationOptions.d.ts +23 -0
  56. package/dist/esm/configuration/ToolingConfigurationOptions.d.ts.map +1 -0
  57. package/dist/esm/configuration/ToolingConfigurationOptions.js +4 -0
  58. package/dist/esm/configuration/ToolingConfigurationOptions.js.map +1 -0
  59. package/dist/esm/configuration/index.d.ts +9 -0
  60. package/dist/esm/configuration/index.d.ts.map +1 -0
  61. package/dist/esm/configuration/index.js +11 -0
  62. package/dist/esm/configuration/index.js.map +1 -0
  63. package/dist/esm/contracts.d.ts +30 -0
  64. package/dist/esm/contracts.d.ts.map +1 -0
  65. package/dist/esm/contracts.js +4 -0
  66. package/dist/esm/contracts.js.map +1 -0
  67. package/dist/esm/index.d.ts +6 -0
  68. package/dist/esm/index.d.ts.map +1 -0
  69. package/dist/esm/index.js +8 -0
  70. package/dist/esm/index.js.map +1 -0
  71. package/dist/esm/models/ChatHistoryMessage.d.ts +22 -0
  72. package/dist/esm/models/ChatHistoryMessage.d.ts.map +1 -0
  73. package/dist/esm/models/ChatHistoryMessage.js +4 -0
  74. package/dist/esm/models/ChatHistoryMessage.js.map +1 -0
  75. package/dist/esm/models/ChatMessageRequest.d.ts +23 -0
  76. package/dist/esm/models/ChatMessageRequest.d.ts.map +1 -0
  77. package/dist/esm/models/ChatMessageRequest.js +4 -0
  78. package/dist/esm/models/ChatMessageRequest.js.map +1 -0
  79. package/dist/esm/models/index.d.ts +3 -0
  80. package/dist/esm/models/index.d.ts.map +1 -0
  81. package/dist/esm/models/index.js +5 -0
  82. package/dist/esm/models/index.js.map +1 -0
  83. package/package.json +63 -0
@@ -0,0 +1,143 @@
1
+ import { TurnContext, Authorization } from '@microsoft/agents-hosting';
2
+ import { OperationResult, IConfigurationProvider } from '@microsoft/agents-a365-runtime';
3
+ import { MCPServerConfig, McpClientTool, ToolOptions } from './contracts';
4
+ import { ChatHistoryMessage } from './models/index';
5
+ import { ToolingConfiguration } from './configuration';
6
+ /**
7
+ * Service responsible for discovering and normalizing MCP (Model Context Protocol)
8
+ * tool servers and producing configuration objects consumable by the Claude SDK.
9
+ */
10
+ export declare class McpToolServerConfigurationService {
11
+ private readonly logger;
12
+ private readonly configProvider;
13
+ /**
14
+ * Construct a McpToolServerConfigurationService.
15
+ * @param configProvider Optional configuration provider. Defaults to defaultToolingConfigurationProvider if not specified.
16
+ */
17
+ constructor(configProvider?: IConfigurationProvider<ToolingConfiguration>);
18
+ /**
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.
20
+ *
21
+ * @deprecated Use the overload with TurnContext and Authorization parameters instead to enable x-ms-agentid header support and automatic token generation.
22
+ * @param agenticAppId The agentic app id for which to discover servers.
23
+ * @param authToken Bearer token used when querying the remote tooling gateway.
24
+ * @returns A promise resolving to an array of normalized MCP server configuration objects.
25
+ */
26
+ listToolServers(agenticAppId: string, authToken: string): Promise<MCPServerConfig[]>;
27
+ /**
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.
29
+ *
30
+ * @deprecated Use the overload with TurnContext and Authorization parameters instead to enable x-ms-agentid header support and automatic token generation.
31
+ * @param agenticAppId The agentic app id for which to discover servers.
32
+ * @param authToken Bearer token used when querying the remote tooling gateway.
33
+ * @param options Optional tool options when calling the gateway.
34
+ * @returns A promise resolving to an array of normalized MCP server configuration objects.
35
+ */
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
+ * Connect to the MCP server and return tools with names prefixed by the server name.
51
+ * Throws if the server URL is missing or the client fails to list tools.
52
+ */
53
+ getMcpClientTools(mcpServerName: string, mcpServerConfig: MCPServerConfig): Promise<McpClientTool[]>;
54
+ /**
55
+ * Sends chat history to the MCP platform for real-time threat protection.
56
+ *
57
+ * @param turnContext The turn context containing conversation information.
58
+ * @param chatHistoryMessages The chat history messages to send.
59
+ * @returns A Promise that resolves to an OperationResult indicating success or failure.
60
+ * @throws Error if turnContext or chatHistoryMessages is null/undefined.
61
+ * @throws Error if required turn context properties (Conversation.Id, Activity.Id, or Activity.Text) are null.
62
+ * @remarks
63
+ * HTTP exceptions (network errors, timeouts) are caught and logged but not rethrown.
64
+ * Instead, the method returns an OperationResult indicating whether the operation succeeded or failed.
65
+ * Callers can choose to inspect the result for error handling or ignore it if error details are not needed.
66
+ */
67
+ sendChatHistory(turnContext: TurnContext, chatHistoryMessages: ChatHistoryMessage[]): Promise<OperationResult>;
68
+ /**
69
+ * Sends chat history to the MCP platform for real-time threat protection.
70
+ *
71
+ * @param turnContext The turn context containing conversation information.
72
+ * @param chatHistoryMessages The chat history messages to send.
73
+ * @param options Optional tool options for sending chat history.
74
+ * @returns A Promise that resolves to an OperationResult indicating success or failure.
75
+ * @throws Error if turnContext or chatHistoryMessages is null/undefined.
76
+ * @throws Error if required turn context properties (Conversation.Id, Activity.Id, or Activity.Text) are null.
77
+ * @remarks
78
+ * HTTP exceptions (network errors, timeouts) are caught and logged but not rethrown.
79
+ * Instead, the method returns an OperationResult indicating whether the operation succeeded or failed.
80
+ * Callers can choose to inspect the result for error handling or ignore it if error details are not needed.
81
+ */
82
+ sendChatHistory(turnContext: TurnContext, chatHistoryMessages: ChatHistoryMessage[], options?: ToolOptions): Promise<OperationResult>;
83
+ /**
84
+ * Query the tooling gateway for MCP servers for the specified agent and normalize each entry's mcpServerUniqueName into a full URL using Utility.BuildMcpServerUrl.
85
+ * Throws an error if the gateway call fails.
86
+ *
87
+ * @param agenticAppId The agentic app id used by the tooling gateway to scope results.
88
+ * @param authToken Optional Bearer token to include in the Authorization header when calling the gateway.
89
+ * @param turnContext Optional TurnContext for extracting agent blueprint ID for request headers.
90
+ * @param options Optional tool options when calling the gateway.
91
+ * @throws Error when the gateway call fails or returns an unexpected payload.
92
+ */
93
+ private getMCPServerConfigsFromToolingGateway;
94
+ /**
95
+ * Read MCP servers from a local ToolingManifest.json file (development only).
96
+ * Searches process.cwd() and process.argv[1] for the manifest file.
97
+ *
98
+ * Reads MCP server configurations from ToolingManifest.json in the application's content root.
99
+ * The file should be located at: [ProjectRoot]/ToolingManifest.json
100
+ *
101
+ * Example ToolingManifest.json:
102
+ * {
103
+ * "mcpServers": [
104
+ * {
105
+ * "mcpServerName": "mailMCPServerConfig",
106
+ * "mcpServerUniqueName": "mcp_MailTools"
107
+ * },
108
+ * {
109
+ * "mcpServerName": "sharePointMCPServerConfig",
110
+ * "mcpServerUniqueName": "mcp_SharePointTools"
111
+ * }
112
+ * ]
113
+ * }
114
+ *
115
+ * Each server entry can optionally include a "url" field to specify a custom MCP server URL.
116
+ * If the "url" field is not provided, the URL will be automatically constructed using the server name.
117
+ * The server name is determined by using "mcpServerName" if present, otherwise "mcpServerUniqueName".
118
+ */
119
+ private getMCPServerConfigsFromManifest;
120
+ /**
121
+ * Detect if the process is running in a development scenario based on configuration.
122
+ *
123
+ * @returns {boolean} True when running in a development environment (NODE_ENV=Development).
124
+ */
125
+ private isDevScenario;
126
+ /**
127
+ * Gets the base URL for MCP platform from configuration.
128
+ */
129
+ private getMcpPlatformBaseUrl;
130
+ /**
131
+ * Construct the tooling gateway URL for a given agent identity.
132
+ */
133
+ private getToolingGatewayUrl;
134
+ /**
135
+ * Build the full URL for accessing a specific MCP server.
136
+ */
137
+ private buildMcpServerUrl;
138
+ /**
139
+ * Constructs the endpoint URL for sending chat history.
140
+ */
141
+ private getChatHistoryEndpoint;
142
+ }
143
+ //# sourceMappingURL=McpToolServerConfigurationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolServerConfigurationService.d.ts","sourceRoot":"","sources":["../../src/McpToolServerConfigurationService.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAkB,sBAAsB,EAA2D,MAAM,gCAAgC,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C,eAAe,CAAC;IAyE3I;;;;;;;;;OASG;YACW,qCAAqC;IAsBnD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;YACW,+BAA+B;IAoC7C;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAI7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAG/B"}
@@ -0,0 +1,270 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import axios from 'axios';
6
+ import { OperationResult, OperationError, AgenticAuthenticationService, Utility as RuntimeUtility } from '@microsoft/agents-a365-runtime';
7
+ import { Utility } from './Utility';
8
+ import { defaultToolingConfigurationProvider } from './configuration';
9
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
10
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
11
+ /**
12
+ * Service responsible for discovering and normalizing MCP (Model Context Protocol)
13
+ * tool servers and producing configuration objects consumable by the Claude SDK.
14
+ */
15
+ export class McpToolServerConfigurationService {
16
+ /**
17
+ * Construct a McpToolServerConfigurationService.
18
+ * @param configProvider Optional configuration provider. Defaults to defaultToolingConfigurationProvider if not specified.
19
+ */
20
+ constructor(configProvider) {
21
+ this.logger = console;
22
+ this.configProvider = configProvider ?? defaultToolingConfigurationProvider;
23
+ }
24
+ async listToolServers(agenticAppIdOrTurnContext, authTokenOrAuthorization, optionsOrAuthHandlerName, authTokenOrOptions, options) {
25
+ // Detect which signature is being used based on the type of the first parameter
26
+ if (typeof agenticAppIdOrTurnContext === 'string') {
27
+ // LEGACY PATH: listToolServers(agenticAppId, authToken, options?)
28
+ const agenticAppId = agenticAppIdOrTurnContext;
29
+ // Runtime validation for legacy signature parameters
30
+ if (typeof authTokenOrAuthorization !== 'string') {
31
+ throw new Error('authToken must be a string when using the legacy listToolServers(agenticAppId, authToken) signature');
32
+ }
33
+ const authToken = authTokenOrAuthorization;
34
+ const toolOptions = optionsOrAuthHandlerName;
35
+ return await (this.isDevScenario()
36
+ ? this.getMCPServerConfigsFromManifest()
37
+ : this.getMCPServerConfigsFromToolingGateway(agenticAppId, authToken, undefined, toolOptions));
38
+ }
39
+ else {
40
+ // NEW PATH: listToolServers(turnContext, authorization, authHandlerName, authToken?, options?)
41
+ const turnContext = agenticAppIdOrTurnContext;
42
+ // Runtime validation for new signature parameters
43
+ if (typeof authTokenOrAuthorization === 'string') {
44
+ throw new Error('authorization must be an Authorization object when using the new listToolServers(turnContext, authorization, authHandlerName) signature');
45
+ }
46
+ if (typeof optionsOrAuthHandlerName !== 'string') {
47
+ throw new Error('authHandlerName must be a string when using the new listToolServers(turnContext, authorization, authHandlerName) signature');
48
+ }
49
+ const authorization = authTokenOrAuthorization;
50
+ const authHandlerName = optionsOrAuthHandlerName;
51
+ let authToken = authTokenOrOptions;
52
+ const toolOptions = options;
53
+ // Auto-generate token if not provided
54
+ if (!authToken) {
55
+ const scopes = [this.configProvider.getConfiguration().mcpPlatformAuthenticationScope];
56
+ authToken = await AgenticAuthenticationService.GetAgenticUserToken(authorization, authHandlerName, turnContext, scopes);
57
+ if (!authToken) {
58
+ throw new Error('Failed to obtain authentication token from token exchange');
59
+ }
60
+ }
61
+ // Note: Token validation (format/expiration) is performed inside getMCPServerConfigsFromToolingGateway()
62
+ // to avoid duplicate validation (it's also called by the legacy path)
63
+ // Resolve agenticAppId from TurnContext
64
+ const agenticAppId = RuntimeUtility.ResolveAgentIdentity(turnContext, authToken);
65
+ return await (this.isDevScenario()
66
+ ? this.getMCPServerConfigsFromManifest()
67
+ : this.getMCPServerConfigsFromToolingGateway(agenticAppId, authToken, turnContext, toolOptions));
68
+ }
69
+ }
70
+ /**
71
+ * Connect to the MCP server and return tools with names prefixed by the server name.
72
+ * Throws if the server URL is missing or the client fails to list tools.
73
+ */
74
+ async getMcpClientTools(mcpServerName, mcpServerConfig) {
75
+ if (!mcpServerConfig) {
76
+ throw new Error('Invalid MCP Server Configuration');
77
+ }
78
+ if (!mcpServerConfig.url) {
79
+ throw new Error('MCP Server URL cannot be null or empty');
80
+ }
81
+ const transport = new StreamableHTTPClientTransport(new URL(mcpServerConfig.url), {
82
+ requestInit: {
83
+ headers: mcpServerConfig.headers
84
+ }
85
+ });
86
+ const mcpClient = new Client({
87
+ name: mcpServerName + ' Client',
88
+ version: '1.0',
89
+ });
90
+ await mcpClient.connect(transport);
91
+ const toolsObj = await mcpClient.listTools();
92
+ await mcpClient.close();
93
+ return toolsObj.tools;
94
+ }
95
+ async sendChatHistory(turnContext, chatHistoryMessages, options) {
96
+ if (!turnContext) {
97
+ throw new Error('turnContext is required');
98
+ }
99
+ if (!chatHistoryMessages) {
100
+ throw new Error('chatHistoryMessages is required');
101
+ }
102
+ // Extract required information from turn context
103
+ const conversationId = turnContext.activity?.conversation?.id;
104
+ if (!conversationId) {
105
+ throw new Error('Conversation ID is required but not found in turn context');
106
+ }
107
+ const messageId = turnContext.activity?.id;
108
+ if (!messageId) {
109
+ throw new Error('Message ID is required but not found in turn context');
110
+ }
111
+ const userMessage = turnContext.activity?.text;
112
+ if (!userMessage) {
113
+ throw new Error('User message is required but not found in turn context');
114
+ }
115
+ // Get the endpoint URL
116
+ const endpoint = this.getChatHistoryEndpoint();
117
+ this.logger.info(`Sending chat history to endpoint: ${endpoint}`);
118
+ // Create the request payload
119
+ const request = {
120
+ conversationId,
121
+ messageId,
122
+ userMessage,
123
+ chatHistory: chatHistoryMessages
124
+ };
125
+ try {
126
+ const headers = Utility.GetToolRequestHeaders(undefined, turnContext, options);
127
+ await axios.post(endpoint, request, {
128
+ headers: {
129
+ ...headers,
130
+ 'Content-Type': 'application/json'
131
+ },
132
+ timeout: 10000 // 10 seconds timeout
133
+ });
134
+ this.logger.info('Successfully sent chat history to MCP platform');
135
+ return OperationResult.success;
136
+ }
137
+ catch (err) {
138
+ const error = err;
139
+ if (axios.isAxiosError(err)) {
140
+ if (err.code === 'ECONNABORTED' || err.code === 'ETIMEDOUT') {
141
+ this.logger.error(`Request timeout sending chat history to '${endpoint}': ${error.message}`);
142
+ }
143
+ else {
144
+ this.logger.error(`HTTP error sending chat history to '${endpoint}': ${error.message}`);
145
+ }
146
+ }
147
+ else {
148
+ this.logger.error(`Failed to send chat history to '${endpoint}': ${error.message}`);
149
+ }
150
+ return OperationResult.failed(new OperationError(error));
151
+ }
152
+ }
153
+ /**
154
+ * Query the tooling gateway for MCP servers for the specified agent and normalize each entry's mcpServerUniqueName into a full URL using Utility.BuildMcpServerUrl.
155
+ * Throws an error if the gateway call fails.
156
+ *
157
+ * @param agenticAppId The agentic app id used by the tooling gateway to scope results.
158
+ * @param authToken Optional Bearer token to include in the Authorization header when calling the gateway.
159
+ * @param turnContext Optional TurnContext for extracting agent blueprint ID for request headers.
160
+ * @param options Optional tool options when calling the gateway.
161
+ * @throws Error when the gateway call fails or returns an unexpected payload.
162
+ */
163
+ async getMCPServerConfigsFromToolingGateway(agenticAppId, authToken, turnContext, options) {
164
+ // Validate the authentication token
165
+ Utility.ValidateAuthToken(authToken);
166
+ const configEndpoint = this.getToolingGatewayUrl(agenticAppId);
167
+ try {
168
+ const response = await axios.get(configEndpoint, {
169
+ headers: Utility.GetToolRequestHeaders(authToken, turnContext, options),
170
+ timeout: 10000 // 10 seconds timeout
171
+ });
172
+ return (response.data) || [];
173
+ }
174
+ catch (err) {
175
+ const error = err;
176
+ throw new Error(`Failed to read MCP servers from endpoint: ${error.code || 'UNKNOWN'} ${error.message || 'Unknown error'}`);
177
+ }
178
+ }
179
+ /**
180
+ * Read MCP servers from a local ToolingManifest.json file (development only).
181
+ * Searches process.cwd() and process.argv[1] for the manifest file.
182
+ *
183
+ * Reads MCP server configurations from ToolingManifest.json in the application's content root.
184
+ * The file should be located at: [ProjectRoot]/ToolingManifest.json
185
+ *
186
+ * Example ToolingManifest.json:
187
+ * {
188
+ * "mcpServers": [
189
+ * {
190
+ * "mcpServerName": "mailMCPServerConfig",
191
+ * "mcpServerUniqueName": "mcp_MailTools"
192
+ * },
193
+ * {
194
+ * "mcpServerName": "sharePointMCPServerConfig",
195
+ * "mcpServerUniqueName": "mcp_SharePointTools"
196
+ * }
197
+ * ]
198
+ * }
199
+ *
200
+ * Each server entry can optionally include a "url" field to specify a custom MCP server URL.
201
+ * If the "url" field is not provided, the URL will be automatically constructed using the server name.
202
+ * The server name is determined by using "mcpServerName" if present, otherwise "mcpServerUniqueName".
203
+ */
204
+ async getMCPServerConfigsFromManifest() {
205
+ let manifestPath = path.join(process.cwd(), 'ToolingManifest.json');
206
+ if (!fs.existsSync(manifestPath)) {
207
+ this.logger.warn(`ToolingManifest.json not found at ${manifestPath}, checking argv[1] location.`);
208
+ manifestPath = path.join(path.dirname(process.argv[1] || ''), 'ToolingManifest.json');
209
+ }
210
+ if (!fs.existsSync(manifestPath)) {
211
+ this.logger.warn(`ToolingManifest.json not found at ${manifestPath}`);
212
+ return [];
213
+ }
214
+ try {
215
+ const jsonContent = fs.readFileSync(manifestPath, 'utf-8');
216
+ const manifestData = JSON.parse(jsonContent);
217
+ const mcpServers = manifestData.mcpServers || [];
218
+ return mcpServers.map((s) => {
219
+ // Use mcpServerName if available, otherwise fall back to mcpServerUniqueName
220
+ const serverName = s.mcpServerName || s.mcpServerUniqueName;
221
+ if (!serverName) {
222
+ throw new Error('Either mcpServerName or mcpServerUniqueName must be provided in manifest entry');
223
+ }
224
+ return {
225
+ mcpServerName: serverName,
226
+ url: s.url || this.buildMcpServerUrl(serverName),
227
+ headers: s.headers
228
+ };
229
+ });
230
+ }
231
+ catch (err) {
232
+ const error = err;
233
+ this.logger.error(`Error reading or parsing ToolingManifest.json: ${error.message || 'Unknown error'}`);
234
+ return [];
235
+ }
236
+ }
237
+ /**
238
+ * Detect if the process is running in a development scenario based on configuration.
239
+ *
240
+ * @returns {boolean} True when running in a development environment (NODE_ENV=Development).
241
+ */
242
+ isDevScenario() {
243
+ return this.configProvider.getConfiguration().useToolingManifest;
244
+ }
245
+ /**
246
+ * Gets the base URL for MCP platform from configuration.
247
+ */
248
+ getMcpPlatformBaseUrl() {
249
+ return this.configProvider.getConfiguration().mcpPlatformEndpoint;
250
+ }
251
+ /**
252
+ * Construct the tooling gateway URL for a given agent identity.
253
+ */
254
+ getToolingGatewayUrl(agenticAppId) {
255
+ return `${this.getMcpPlatformBaseUrl()}/agents/${agenticAppId}/mcpServers`;
256
+ }
257
+ /**
258
+ * Build the full URL for accessing a specific MCP server.
259
+ */
260
+ buildMcpServerUrl(serverName) {
261
+ return `${this.getMcpPlatformBaseUrl()}/agents/servers/${serverName}/`;
262
+ }
263
+ /**
264
+ * Constructs the endpoint URL for sending chat history.
265
+ */
266
+ getChatHistoryEndpoint() {
267
+ return `${this.getMcpPlatformBaseUrl()}/agents/real-time-threat-protection/chat-message`;
268
+ }
269
+ }
270
+ //# sourceMappingURL=McpToolServerConfigurationService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolServerConfigurationService.js","sourceRoot":"","sources":["../../src/McpToolServerConfigurationService.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,cAAc,EAA0B,4BAA4B,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGlK,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAwB,mCAAmC,EAAE,MAAM,iBAAiB,CAAC;AAE5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE;;;GAGG;AACH,MAAM,OAAO,iCAAiC;IAI5C;;;OAGG;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B;QAC/C,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE,WAAW,YAAY,aAAa,CAAC;IAC7E,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,UAAkB;QAC1C,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE,mBAAmB,UAAU,GAAG,CAAC;IACzE,CAAC;IAED;;OAEG;IACK,sBAAsB;QAC5B,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE,kDAAkD,CAAC;IAC3F,CAAC;CACF"}
@@ -0,0 +1,106 @@
1
+ import { TurnContext } from '@microsoft/agents-hosting';
2
+ import { IConfigurationProvider } from '@microsoft/agents-a365-runtime';
3
+ import { ToolOptions } from './contracts';
4
+ import { ToolingConfiguration } from './configuration';
5
+ export declare class Utility {
6
+ static readonly HEADER_CHANNEL_ID = "x-ms-channel-id";
7
+ static readonly HEADER_SUBCHANNEL_ID = "x-ms-subchannel-id";
8
+ static readonly HEADER_USER_AGENT = "User-Agent";
9
+ /** Header name for sending the agent identifier to MCP platform for logging/analytics. */
10
+ static readonly HEADER_AGENT_ID = "x-ms-agentid";
11
+ /**
12
+ * Compose standard headers for MCP tooling requests.
13
+ * Includes Authorization bearer token when provided, and optionally includes channel and subchannel identifiers for routing.
14
+ *
15
+ * @param authToken Bearer token for Authorization header.
16
+ * @param turnContext Optional TurnContext object from which channel and subchannel IDs are extracted.
17
+ * @param options Optional ToolOptions object for additional request configuration.
18
+ * @returns A headers record suitable for HTTP requests.
19
+ */
20
+ static GetToolRequestHeaders(authToken?: string, turnContext?: TurnContext, options?: ToolOptions): Record<string, string>;
21
+ /**
22
+ * Resolves the best available agent identifier for the x-ms-agentid header.
23
+ * Priority: TurnContext.agenticAppBlueprintId > token claims (xms_par_app_azp > appid > azp) > application name
24
+ *
25
+ * Note: This differs from RuntimeUtility.ResolveAgentIdentity() which resolves the agenticAppId
26
+ * for URL construction. This method resolves the identifier specifically for the x-ms-agentid header.
27
+ *
28
+ * @param authToken The authentication token to extract claims from.
29
+ * @param turnContext Optional TurnContext to extract agent blueprint ID from.
30
+ * @returns Agent ID string or undefined if not available.
31
+ */
32
+ private static resolveAgentIdForHeader;
33
+ /**
34
+ * Validates a JWT authentication token.
35
+ * Checks that the token is a valid JWT and is not expired.
36
+ *
37
+ * @param authToken - The JWT token to validate.
38
+ * @throws Error if the token is invalid or expired.
39
+ */
40
+ static ValidateAuthToken(authToken: string | undefined): void;
41
+ /**
42
+ * Private helper to validate a JWT authentication token.
43
+ * Checks that the token is a valid JWT and is not expired.
44
+ *
45
+ * @param authToken - The JWT token to validate.
46
+ * @throws Error if the token is invalid or expired.
47
+ */
48
+ private static validateAuthToken;
49
+ /**
50
+ * Construct the tooling gateway URL for a given agent identity.
51
+ * This endpoint is used to discover MCP servers associated with the specified agent identity.
52
+ *
53
+ * Example:
54
+ * Utility.GetToolingGatewayForDigitalWorker(agenticAppId)
55
+ * // => "https://agent365.svc.cloud.microsoft/agents/{agenticAppId}/mcpServers"
56
+ *
57
+ * @param agenticAppId - The unique identifier for the agent identity.
58
+ * @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
59
+ * @returns A fully-qualified URL pointing at the tooling gateway for the agent.
60
+ * @deprecated This method is for internal use only. Use McpToolServerConfigurationService.listToolServers() instead.
61
+ */
62
+ static GetToolingGatewayForDigitalWorker(agenticAppId: string, configProvider?: IConfigurationProvider<ToolingConfiguration>): string;
63
+ /**
64
+ * Get the base URL used to query MCP environments.
65
+ *
66
+ * @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
67
+ * @returns The base MCP environments URL.
68
+ * @deprecated This method is for internal use only. Use McpToolServerConfigurationService instead.
69
+ */
70
+ static GetMcpBaseUrl(configProvider?: IConfigurationProvider<ToolingConfiguration>): string;
71
+ /**
72
+ * Build the full URL for accessing a specific MCP server.
73
+ *
74
+ * Example:
75
+ * Utility.BuildMcpServerUrl('MyServer')
76
+ * // => "https://agent365.svc.cloud.microsoft/agents/servers/MyServer/"
77
+ *
78
+ * @param serverName - The MCP server resource name.
79
+ * @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
80
+ * @returns The fully-qualified MCP server URL including trailing slash.
81
+ * @deprecated This method is for internal use only. Use McpToolServerConfigurationService instead.
82
+ */
83
+ static BuildMcpServerUrl(serverName: string, configProvider?: IConfigurationProvider<ToolingConfiguration>): string;
84
+ /**
85
+ * Gets the base URL for MCP platform from configuration.
86
+ *
87
+ * @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
88
+ * @returns The base URL for MCP platform.
89
+ * @deprecated This method is for internal use only. Use ToolingConfiguration.mcpPlatformEndpoint instead.
90
+ */
91
+ private static getMcpPlatformBaseUrl;
92
+ /**
93
+ * Constructs the endpoint URL for sending chat history to the MCP platform for real-time threat protection.
94
+ *
95
+ * @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
96
+ * @returns An absolute URL that tooling components can use to send or retrieve chat messages for
97
+ * real-time threat protection scenarios.
98
+ * @remarks
99
+ * Call this method when constructing HTTP requests that need to access the chat-message history
100
+ * for real-time threat protection. The returned URL already includes the MCP platform base address
101
+ * and the fixed path segment `/agents/real-time-threat-protection/chat-message`.
102
+ * @deprecated This method is for internal use only. Use McpToolServerConfigurationService.sendChatHistory() instead.
103
+ */
104
+ static GetChatHistoryEndpoint(configProvider?: IConfigurationProvider<ToolingConfiguration>): string;
105
+ }
106
+ //# sourceMappingURL=Utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utility.d.ts","sourceRoot":"","sources":["../../src/Utility.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAA6B,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAuC,MAAM,iBAAiB,CAAC;AAE5F,qBAAa,OAAO;IAClB,gBAAuB,iBAA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