@microsoft/agents-a365-tooling-extensions-langchain 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.
- package/LICENSE.md +21 -0
- package/README.md +33 -0
- package/dist/cjs/McpToolRegistrationService.d.ts +172 -0
- package/dist/cjs/McpToolRegistrationService.d.ts.map +1 -0
- package/dist/cjs/McpToolRegistrationService.js +358 -0
- package/dist/cjs/McpToolRegistrationService.js.map +1 -0
- package/dist/cjs/configuration/LangChainToolingConfiguration.d.ts +42 -0
- package/dist/cjs/configuration/LangChainToolingConfiguration.d.ts.map +1 -0
- package/dist/cjs/configuration/LangChainToolingConfiguration.js +49 -0
- package/dist/cjs/configuration/LangChainToolingConfiguration.js.map +1 -0
- package/dist/cjs/configuration/LangChainToolingConfigurationOptions.d.ts +9 -0
- package/dist/cjs/configuration/LangChainToolingConfigurationOptions.d.ts.map +1 -0
- package/dist/cjs/configuration/LangChainToolingConfigurationOptions.js +5 -0
- package/dist/cjs/configuration/LangChainToolingConfigurationOptions.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/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/McpToolRegistrationService.d.ts +172 -0
- package/dist/esm/McpToolRegistrationService.d.ts.map +1 -0
- package/dist/esm/McpToolRegistrationService.js +358 -0
- package/dist/esm/McpToolRegistrationService.js.map +1 -0
- package/dist/esm/configuration/LangChainToolingConfiguration.d.ts +42 -0
- package/dist/esm/configuration/LangChainToolingConfiguration.d.ts.map +1 -0
- package/dist/esm/configuration/LangChainToolingConfiguration.js +49 -0
- package/dist/esm/configuration/LangChainToolingConfiguration.js.map +1 -0
- package/dist/esm/configuration/LangChainToolingConfigurationOptions.d.ts +9 -0
- package/dist/esm/configuration/LangChainToolingConfigurationOptions.d.ts.map +1 -0
- package/dist/esm/configuration/LangChainToolingConfigurationOptions.js +5 -0
- package/dist/esm/configuration/LangChainToolingConfigurationOptions.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 +28 -0
- package/dist/esm/configuration/index.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +76 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Microsoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @microsoft/agents-a365-tooling-extensions-langchain
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@microsoft/agents-a365-tooling-extensions-langchain)
|
|
4
|
+
[](https://www.npmjs.com/package/@microsoft/agents-a365-tooling-extensions-langchain)
|
|
5
|
+
|
|
6
|
+
LangChain integration for the Microsoft Agent 365 Tooling SDK. This package enables seamless integration of MCP (Model Context Protocol) tool servers with LangChain agents, providing automatic tool discovery and registration as DynamicStructuredTool instances.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @microsoft/agents-a365-tooling-extensions-langchain
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
For detailed usage examples and implementation guidance, see the [Microsoft Agent 365 Tooling Documentation](https://learn.microsoft.com/microsoft-agent-365/developer/tooling?tabs=nodejs).
|
|
17
|
+
|
|
18
|
+
## Support
|
|
19
|
+
|
|
20
|
+
For issues, questions, or feedback:
|
|
21
|
+
|
|
22
|
+
- File issues in the [GitHub Issues](https://github.com/microsoft/Agent365-nodejs/issues) section
|
|
23
|
+
- See the [main documentation](../../README.md) for more information
|
|
24
|
+
|
|
25
|
+
## Trademarks
|
|
26
|
+
|
|
27
|
+
*Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.*
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
32
|
+
|
|
33
|
+
Licensed under the MIT License - see the [LICENSE](../../LICENSE.md) file for details
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ToolOptions } from '@microsoft/agents-a365-tooling';
|
|
2
|
+
import { OperationResult, IConfigurationProvider } from '@microsoft/agents-a365-runtime';
|
|
3
|
+
import { LangChainToolingConfiguration } from './configuration';
|
|
4
|
+
import { TurnContext, Authorization } from '@microsoft/agents-hosting';
|
|
5
|
+
import { ReactAgent } from 'langchain';
|
|
6
|
+
import { BaseMessage } from '@langchain/core/messages';
|
|
7
|
+
import { BaseChatMessageHistory } from '@langchain/core/chat_history';
|
|
8
|
+
import { RunnableConfig } from '@langchain/core/runnables';
|
|
9
|
+
import type { CompiledStateGraph, StateSnapshot } from '@langchain/langgraph';
|
|
10
|
+
/**
|
|
11
|
+
* Discover MCP servers and list tools formatted for the LangChain Orchestrator.
|
|
12
|
+
* Uses listToolServers to fetch server configs and getTools to enumerate tools.
|
|
13
|
+
*
|
|
14
|
+
* Also provides methods to send chat history to the MCP platform for
|
|
15
|
+
* real-time threat protection (RTP) analysis.
|
|
16
|
+
*/
|
|
17
|
+
export declare class McpToolRegistrationService {
|
|
18
|
+
private readonly configService;
|
|
19
|
+
private readonly configProvider;
|
|
20
|
+
private readonly orchestratorName;
|
|
21
|
+
/**
|
|
22
|
+
* Construct a McpToolRegistrationService.
|
|
23
|
+
* @param configProvider Optional configuration provider. Defaults to defaultLangChainToolingConfigurationProvider if not specified.
|
|
24
|
+
*/
|
|
25
|
+
constructor(configProvider?: IConfigurationProvider<LangChainToolingConfiguration>);
|
|
26
|
+
/**
|
|
27
|
+
* Registers MCP tool servers and updates agent options with discovered tools and server configs.
|
|
28
|
+
* Call this to enable dynamic LangChain tool access based on the current MCP environment.
|
|
29
|
+
* @param agent The LangChain Agent instance to which MCP servers will be added.
|
|
30
|
+
* @param authorization Authorization object for token exchange.
|
|
31
|
+
* @param authHandlerName The name of the auth handler to use for token exchange.
|
|
32
|
+
* @param turnContext The TurnContext of the current request.
|
|
33
|
+
* @param authToken Optional bearer token for MCP server access.
|
|
34
|
+
* @returns The updated Agent instance with registered MCP servers.
|
|
35
|
+
*/
|
|
36
|
+
addToolServersToAgent(agent: ReactAgent, authorization: Authorization, authHandlerName: string, turnContext: TurnContext, authToken: string): Promise<ReactAgent>;
|
|
37
|
+
/**
|
|
38
|
+
* Sends chat history from a LangGraph CompiledStateGraph to the MCP platform.
|
|
39
|
+
*
|
|
40
|
+
* This is the highest-level and easiest-to-use API. It retrieves the current state
|
|
41
|
+
* from the graph, extracts messages, converts them to ChatHistoryMessage format,
|
|
42
|
+
* and sends them to the MCP platform for real-time threat protection.
|
|
43
|
+
*
|
|
44
|
+
* @param turnContext - The turn context containing conversation information.
|
|
45
|
+
* @param graph - The LangGraph CompiledStateGraph instance. The graph state must contain a 'messages' array.
|
|
46
|
+
* @param config - The RunnableConfig containing thread_id and other configuration.
|
|
47
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
48
|
+
* @param toolOptions - Optional tool options for customization.
|
|
49
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
50
|
+
* @throws Error if turnContext is null/undefined.
|
|
51
|
+
* @throws Error if graph is null/undefined.
|
|
52
|
+
* @throws Error if config is null/undefined.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const config = { configurable: { thread_id: '1' } };
|
|
57
|
+
* const result = await service.sendChatHistoryAsync(turnContext, graph, config);
|
|
58
|
+
* if (result.succeeded) {
|
|
59
|
+
* console.log('Chat history sent successfully');
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
sendChatHistoryAsync(turnContext: TurnContext, graph: CompiledStateGraph<unknown, unknown, string>, config: RunnableConfig, limit?: number, toolOptions?: ToolOptions): Promise<OperationResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Extracts messages from a LangGraph StateSnapshot and sends them to the MCP platform.
|
|
66
|
+
*
|
|
67
|
+
* Use this API when you already have a StateSnapshot (e.g., from a previous
|
|
68
|
+
* `graph.getState()` call) and want to avoid fetching state again.
|
|
69
|
+
*
|
|
70
|
+
* @param turnContext - The turn context containing conversation information.
|
|
71
|
+
* @param stateSnapshot - The LangGraph StateSnapshot containing message state.
|
|
72
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
73
|
+
* @param toolOptions - Optional tool options for customization.
|
|
74
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
75
|
+
* @throws Error if turnContext is null/undefined.
|
|
76
|
+
* @throws Error if stateSnapshot is null/undefined.
|
|
77
|
+
* @throws Error if stateSnapshot does not contain a messages array.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const config = { configurable: { thread_id: '1' } };
|
|
82
|
+
* const stateSnapshot = await graph.getState(config);
|
|
83
|
+
* const result = await service.sendChatHistoryFromStateAsync(turnContext, stateSnapshot);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
sendChatHistoryFromStateAsync(turnContext: TurnContext, stateSnapshot: StateSnapshot, limit?: number, toolOptions?: ToolOptions): Promise<OperationResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves messages from a BaseChatMessageHistory instance and sends them to the MCP platform.
|
|
89
|
+
*
|
|
90
|
+
* Use this API when working with LangChain's memory abstractions (e.g., InMemoryChatMessageHistory,
|
|
91
|
+
* RedisChatMessageHistory, etc.).
|
|
92
|
+
*
|
|
93
|
+
* @param turnContext - The turn context containing conversation information.
|
|
94
|
+
* @param chatHistory - The BaseChatMessageHistory instance to retrieve messages from.
|
|
95
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
96
|
+
* @param toolOptions - Optional tool options for customization.
|
|
97
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
98
|
+
* @throws Error if turnContext is null/undefined.
|
|
99
|
+
* @throws Error if chatHistory is null/undefined.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const chatHistory = new InMemoryChatMessageHistory();
|
|
104
|
+
* // ... add messages to history ...
|
|
105
|
+
* const result = await service.sendChatHistoryFromChatHistoryAsync(turnContext, chatHistory);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
sendChatHistoryFromChatHistoryAsync(turnContext: TurnContext, chatHistory: BaseChatMessageHistory, limit?: number, toolOptions?: ToolOptions): Promise<OperationResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Sends an array of LangChain messages to the MCP platform for real-time threat protection.
|
|
111
|
+
*
|
|
112
|
+
* This is the lowest-level API that accepts raw BaseMessage arrays. Use this when you
|
|
113
|
+
* have already extracted messages or have a custom message source not covered by the
|
|
114
|
+
* higher-level APIs.
|
|
115
|
+
*
|
|
116
|
+
* This method converts the provided BaseMessage array to ChatHistoryMessage format
|
|
117
|
+
* and sends them to the MCP platform. Empty arrays are sent as-is to register the
|
|
118
|
+
* user message with the platform.
|
|
119
|
+
*
|
|
120
|
+
* @param turnContext - The turn context containing conversation information.
|
|
121
|
+
* @param messages - Array of LangChain BaseMessage objects to send.
|
|
122
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
123
|
+
* @param toolOptions - Optional tool options for customization.
|
|
124
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
125
|
+
* @throws Error if turnContext is null/undefined.
|
|
126
|
+
* @throws Error if messages is null/undefined.
|
|
127
|
+
* @throws Error if required turn context properties are missing.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const messages = await messageHistory.getMessages();
|
|
132
|
+
* const result = await service.sendChatHistoryFromMessagesAsync(turnContext, messages, 50);
|
|
133
|
+
* if (result.succeeded) {
|
|
134
|
+
* console.log('Chat history sent successfully');
|
|
135
|
+
* } else {
|
|
136
|
+
* console.error('Failed to send chat history:', result.errors);
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
sendChatHistoryFromMessagesAsync(turnContext: TurnContext, messages: BaseMessage[], limit?: number, toolOptions?: ToolOptions): Promise<OperationResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Converts an array of BaseMessage to ChatHistoryMessage format.
|
|
143
|
+
* Messages that fail conversion are silently skipped.
|
|
144
|
+
*
|
|
145
|
+
* @param messages - Array of LangChain BaseMessage objects to convert.
|
|
146
|
+
* @returns Array of ChatHistoryMessage objects.
|
|
147
|
+
*/
|
|
148
|
+
private convertToChatHistoryMessages;
|
|
149
|
+
/**
|
|
150
|
+
* Converts a single BaseMessage to ChatHistoryMessage format.
|
|
151
|
+
*
|
|
152
|
+
* @param message - The LangChain BaseMessage to convert.
|
|
153
|
+
* @returns ChatHistoryMessage or null if conversion fails.
|
|
154
|
+
*/
|
|
155
|
+
private convertSingleMessage;
|
|
156
|
+
/**
|
|
157
|
+
* Maps a LangChain message type to a standard role string.
|
|
158
|
+
*
|
|
159
|
+
* @param message - The LangChain BaseMessage to map.
|
|
160
|
+
* @returns The mapped role string.
|
|
161
|
+
*/
|
|
162
|
+
private mapRole;
|
|
163
|
+
/**
|
|
164
|
+
* Extracts text content from a LangChain message.
|
|
165
|
+
* Handles both string content and ContentPart arrays.
|
|
166
|
+
*
|
|
167
|
+
* @param message - The LangChain BaseMessage to extract content from.
|
|
168
|
+
* @returns The extracted text content as a string.
|
|
169
|
+
*/
|
|
170
|
+
private extractContent;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=McpToolRegistrationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpToolRegistrationService.d.ts","sourceRoot":"","sources":["../../src/McpToolRegistrationService.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8C,WAAW,EAAsB,MAAM,gCAAgC,CAAC;AAC7H,OAAO,EAAgC,eAAe,EAAkB,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACvI,OAAO,EAAE,6BAA6B,EAAgD,MAAM,iBAAiB,CAAC;AAG9G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,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,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,sBAAsB,EACnC,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,eAAe,CAAC;IAoB3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,gCAAgC,CACpC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,eAAe,CAAC;IAmC3B;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAMpC;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAkB5B;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAuBf;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CAgCvB"}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.McpToolRegistrationService = void 0;
|
|
6
|
+
// Microsoft Agent 365 SDK
|
|
7
|
+
const agents_a365_tooling_1 = require("@microsoft/agents-a365-tooling");
|
|
8
|
+
const agents_a365_runtime_1 = require("@microsoft/agents-a365-runtime");
|
|
9
|
+
const configuration_1 = require("./configuration");
|
|
10
|
+
// LangChain SDKs
|
|
11
|
+
const langchain_1 = require("langchain");
|
|
12
|
+
const mcp_adapters_1 = require("@langchain/mcp-adapters");
|
|
13
|
+
// UUID for generating message IDs
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
15
|
+
/**
|
|
16
|
+
* Discover MCP servers and list tools formatted for the LangChain Orchestrator.
|
|
17
|
+
* Uses listToolServers to fetch server configs and getTools to enumerate tools.
|
|
18
|
+
*
|
|
19
|
+
* Also provides methods to send chat history to the MCP platform for
|
|
20
|
+
* real-time threat protection (RTP) analysis.
|
|
21
|
+
*/
|
|
22
|
+
class McpToolRegistrationService {
|
|
23
|
+
/**
|
|
24
|
+
* Construct a McpToolRegistrationService.
|
|
25
|
+
* @param configProvider Optional configuration provider. Defaults to defaultLangChainToolingConfigurationProvider if not specified.
|
|
26
|
+
*/
|
|
27
|
+
constructor(configProvider) {
|
|
28
|
+
this.orchestratorName = "LangChain";
|
|
29
|
+
this.configProvider = configProvider ?? configuration_1.defaultLangChainToolingConfigurationProvider;
|
|
30
|
+
this.configService = new agents_a365_tooling_1.McpToolServerConfigurationService(this.configProvider);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registers MCP tool servers and updates agent options with discovered tools and server configs.
|
|
34
|
+
* Call this to enable dynamic LangChain tool access based on the current MCP environment.
|
|
35
|
+
* @param agent The LangChain Agent instance to which MCP servers will be added.
|
|
36
|
+
* @param authorization Authorization object for token exchange.
|
|
37
|
+
* @param authHandlerName The name of the auth handler to use for token exchange.
|
|
38
|
+
* @param turnContext The TurnContext of the current request.
|
|
39
|
+
* @param authToken Optional bearer token for MCP server access.
|
|
40
|
+
* @returns The updated Agent instance with registered MCP servers.
|
|
41
|
+
*/
|
|
42
|
+
async addToolServersToAgent(agent, authorization, authHandlerName, turnContext, authToken) {
|
|
43
|
+
if (!agent) {
|
|
44
|
+
throw new Error('Langchain Agent is Required');
|
|
45
|
+
}
|
|
46
|
+
if (!authToken) {
|
|
47
|
+
const scope = this.configProvider.getConfiguration().mcpPlatformAuthenticationScope;
|
|
48
|
+
authToken = await agents_a365_runtime_1.AgenticAuthenticationService.GetAgenticUserToken(authorization, authHandlerName, turnContext, [scope]);
|
|
49
|
+
}
|
|
50
|
+
// Validate the authentication token
|
|
51
|
+
agents_a365_tooling_1.Utility.ValidateAuthToken(authToken);
|
|
52
|
+
const options = { orchestratorName: this.orchestratorName };
|
|
53
|
+
const servers = await this.configService.listToolServers(turnContext, authorization, authHandlerName, authToken, options);
|
|
54
|
+
const mcpServers = {};
|
|
55
|
+
for (const server of servers) {
|
|
56
|
+
// Compose headers if values are available
|
|
57
|
+
const headers = agents_a365_tooling_1.Utility.GetToolRequestHeaders(authToken, turnContext, options);
|
|
58
|
+
// Create Connection instance for LangChain agents
|
|
59
|
+
mcpServers[server.mcpServerName] = {
|
|
60
|
+
type: 'http',
|
|
61
|
+
url: server.url,
|
|
62
|
+
headers: headers
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const mcpClientConfig = {};
|
|
66
|
+
mcpClientConfig.mcpServers = Object.assign(mcpClientConfig.mcpServers ?? {}, mcpServers);
|
|
67
|
+
const multiServerMcpClient = new mcp_adapters_1.MultiServerMCPClient(mcpClientConfig);
|
|
68
|
+
const mcpTools = await multiServerMcpClient.getTools();
|
|
69
|
+
// Merge existing agent tools with MCP tools
|
|
70
|
+
const existingTools = agent.options.tools ?? [];
|
|
71
|
+
const allTools = [...existingTools, ...mcpTools];
|
|
72
|
+
// Create the agent with existing options and combined tools
|
|
73
|
+
return (0, langchain_1.createAgent)({
|
|
74
|
+
...agent.options,
|
|
75
|
+
tools: allTools,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Send Chat History API Methods
|
|
80
|
+
// ============================================================================
|
|
81
|
+
/**
|
|
82
|
+
* Sends chat history from a LangGraph CompiledStateGraph to the MCP platform.
|
|
83
|
+
*
|
|
84
|
+
* This is the highest-level and easiest-to-use API. It retrieves the current state
|
|
85
|
+
* from the graph, extracts messages, converts them to ChatHistoryMessage format,
|
|
86
|
+
* and sends them to the MCP platform for real-time threat protection.
|
|
87
|
+
*
|
|
88
|
+
* @param turnContext - The turn context containing conversation information.
|
|
89
|
+
* @param graph - The LangGraph CompiledStateGraph instance. The graph state must contain a 'messages' array.
|
|
90
|
+
* @param config - The RunnableConfig containing thread_id and other configuration.
|
|
91
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
92
|
+
* @param toolOptions - Optional tool options for customization.
|
|
93
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
94
|
+
* @throws Error if turnContext is null/undefined.
|
|
95
|
+
* @throws Error if graph is null/undefined.
|
|
96
|
+
* @throws Error if config is null/undefined.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const config = { configurable: { thread_id: '1' } };
|
|
101
|
+
* const result = await service.sendChatHistoryAsync(turnContext, graph, config);
|
|
102
|
+
* if (result.succeeded) {
|
|
103
|
+
* console.log('Chat history sent successfully');
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
async sendChatHistoryAsync(turnContext, graph, config, limit, toolOptions) {
|
|
108
|
+
// Validate inputs
|
|
109
|
+
if (!turnContext) {
|
|
110
|
+
throw new Error('turnContext is required');
|
|
111
|
+
}
|
|
112
|
+
if (!graph) {
|
|
113
|
+
throw new Error('graph is required');
|
|
114
|
+
}
|
|
115
|
+
if (!config) {
|
|
116
|
+
throw new Error('config is required');
|
|
117
|
+
}
|
|
118
|
+
// Get state from graph - wrap in try-catch as this is an external call
|
|
119
|
+
let stateSnapshot;
|
|
120
|
+
try {
|
|
121
|
+
stateSnapshot = await graph.getState(config);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
return agents_a365_runtime_1.OperationResult.failed(new agents_a365_runtime_1.OperationError(err));
|
|
125
|
+
}
|
|
126
|
+
// Delegate to state-based method
|
|
127
|
+
return this.sendChatHistoryFromStateAsync(turnContext, stateSnapshot, limit, toolOptions);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Extracts messages from a LangGraph StateSnapshot and sends them to the MCP platform.
|
|
131
|
+
*
|
|
132
|
+
* Use this API when you already have a StateSnapshot (e.g., from a previous
|
|
133
|
+
* `graph.getState()` call) and want to avoid fetching state again.
|
|
134
|
+
*
|
|
135
|
+
* @param turnContext - The turn context containing conversation information.
|
|
136
|
+
* @param stateSnapshot - The LangGraph StateSnapshot containing message state.
|
|
137
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
138
|
+
* @param toolOptions - Optional tool options for customization.
|
|
139
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
140
|
+
* @throws Error if turnContext is null/undefined.
|
|
141
|
+
* @throws Error if stateSnapshot is null/undefined.
|
|
142
|
+
* @throws Error if stateSnapshot does not contain a messages array.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const config = { configurable: { thread_id: '1' } };
|
|
147
|
+
* const stateSnapshot = await graph.getState(config);
|
|
148
|
+
* const result = await service.sendChatHistoryFromStateAsync(turnContext, stateSnapshot);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
async sendChatHistoryFromStateAsync(turnContext, stateSnapshot, limit, toolOptions) {
|
|
152
|
+
if (!turnContext) {
|
|
153
|
+
throw new Error('turnContext is required');
|
|
154
|
+
}
|
|
155
|
+
if (!stateSnapshot) {
|
|
156
|
+
throw new Error('stateSnapshot is required');
|
|
157
|
+
}
|
|
158
|
+
const values = stateSnapshot.values;
|
|
159
|
+
const messages = values?.messages;
|
|
160
|
+
if (!messages || !Array.isArray(messages)) {
|
|
161
|
+
throw new Error('stateSnapshot must contain messages array in values');
|
|
162
|
+
}
|
|
163
|
+
return this.sendChatHistoryFromMessagesAsync(turnContext, messages, limit, toolOptions);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Retrieves messages from a BaseChatMessageHistory instance and sends them to the MCP platform.
|
|
167
|
+
*
|
|
168
|
+
* Use this API when working with LangChain's memory abstractions (e.g., InMemoryChatMessageHistory,
|
|
169
|
+
* RedisChatMessageHistory, etc.).
|
|
170
|
+
*
|
|
171
|
+
* @param turnContext - The turn context containing conversation information.
|
|
172
|
+
* @param chatHistory - The BaseChatMessageHistory instance to retrieve messages from.
|
|
173
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
174
|
+
* @param toolOptions - Optional tool options for customization.
|
|
175
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
176
|
+
* @throws Error if turnContext is null/undefined.
|
|
177
|
+
* @throws Error if chatHistory is null/undefined.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const chatHistory = new InMemoryChatMessageHistory();
|
|
182
|
+
* // ... add messages to history ...
|
|
183
|
+
* const result = await service.sendChatHistoryFromChatHistoryAsync(turnContext, chatHistory);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
async sendChatHistoryFromChatHistoryAsync(turnContext, chatHistory, limit, toolOptions) {
|
|
187
|
+
if (!turnContext) {
|
|
188
|
+
throw new Error('turnContext is required');
|
|
189
|
+
}
|
|
190
|
+
if (!chatHistory) {
|
|
191
|
+
throw new Error('chatHistory is required');
|
|
192
|
+
}
|
|
193
|
+
// Retrieve messages from the chat history - wrap in try-catch as this is an external call
|
|
194
|
+
let messages;
|
|
195
|
+
try {
|
|
196
|
+
messages = await chatHistory.getMessages();
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
return agents_a365_runtime_1.OperationResult.failed(new agents_a365_runtime_1.OperationError(err));
|
|
200
|
+
}
|
|
201
|
+
// Delegate to messages-based method
|
|
202
|
+
return this.sendChatHistoryFromMessagesAsync(turnContext, messages, limit, toolOptions);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Sends an array of LangChain messages to the MCP platform for real-time threat protection.
|
|
206
|
+
*
|
|
207
|
+
* This is the lowest-level API that accepts raw BaseMessage arrays. Use this when you
|
|
208
|
+
* have already extracted messages or have a custom message source not covered by the
|
|
209
|
+
* higher-level APIs.
|
|
210
|
+
*
|
|
211
|
+
* This method converts the provided BaseMessage array to ChatHistoryMessage format
|
|
212
|
+
* and sends them to the MCP platform. Empty arrays are sent as-is to register the
|
|
213
|
+
* user message with the platform.
|
|
214
|
+
*
|
|
215
|
+
* @param turnContext - The turn context containing conversation information.
|
|
216
|
+
* @param messages - Array of LangChain BaseMessage objects to send.
|
|
217
|
+
* @param limit - Optional limit on the number of messages to send.
|
|
218
|
+
* @param toolOptions - Optional tool options for customization.
|
|
219
|
+
* @returns A Promise resolving to an OperationResult indicating success or failure.
|
|
220
|
+
* @throws Error if turnContext is null/undefined.
|
|
221
|
+
* @throws Error if messages is null/undefined.
|
|
222
|
+
* @throws Error if required turn context properties are missing.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const messages = await messageHistory.getMessages();
|
|
227
|
+
* const result = await service.sendChatHistoryFromMessagesAsync(turnContext, messages, 50);
|
|
228
|
+
* if (result.succeeded) {
|
|
229
|
+
* console.log('Chat history sent successfully');
|
|
230
|
+
* } else {
|
|
231
|
+
* console.error('Failed to send chat history:', result.errors);
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
async sendChatHistoryFromMessagesAsync(turnContext, messages, limit, toolOptions) {
|
|
236
|
+
// Validate inputs
|
|
237
|
+
if (!turnContext) {
|
|
238
|
+
throw new Error('turnContext is required');
|
|
239
|
+
}
|
|
240
|
+
if (!messages) {
|
|
241
|
+
throw new Error('messages is required');
|
|
242
|
+
}
|
|
243
|
+
// Apply limit if specified
|
|
244
|
+
const messagesToProcess = limit !== undefined && limit >= 0 ? messages.slice(0, limit) : messages;
|
|
245
|
+
// Set default options, preserving any additional properties from toolOptions
|
|
246
|
+
const effectiveOptions = {
|
|
247
|
+
orchestratorName: this.orchestratorName,
|
|
248
|
+
...toolOptions
|
|
249
|
+
};
|
|
250
|
+
// Convert messages (may result in empty array - that's OK)
|
|
251
|
+
// convertToChatHistoryMessages handles errors internally and never throws
|
|
252
|
+
const chatHistoryMessages = this.convertToChatHistoryMessages(messagesToProcess);
|
|
253
|
+
// IMPORTANT: Always send to API, even if empty array
|
|
254
|
+
// Empty array is required to register the user message with RTP
|
|
255
|
+
return this.configService.sendChatHistory(turnContext, chatHistoryMessages, effectiveOptions);
|
|
256
|
+
}
|
|
257
|
+
// ============================================================================
|
|
258
|
+
// Private Helper Methods
|
|
259
|
+
// ============================================================================
|
|
260
|
+
/**
|
|
261
|
+
* Converts an array of BaseMessage to ChatHistoryMessage format.
|
|
262
|
+
* Messages that fail conversion are silently skipped.
|
|
263
|
+
*
|
|
264
|
+
* @param messages - Array of LangChain BaseMessage objects to convert.
|
|
265
|
+
* @returns Array of ChatHistoryMessage objects.
|
|
266
|
+
*/
|
|
267
|
+
convertToChatHistoryMessages(messages) {
|
|
268
|
+
return messages
|
|
269
|
+
.map(msg => this.convertSingleMessage(msg))
|
|
270
|
+
.filter((msg) => msg !== null);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Converts a single BaseMessage to ChatHistoryMessage format.
|
|
274
|
+
*
|
|
275
|
+
* @param message - The LangChain BaseMessage to convert.
|
|
276
|
+
* @returns ChatHistoryMessage or null if conversion fails.
|
|
277
|
+
*/
|
|
278
|
+
convertSingleMessage(message) {
|
|
279
|
+
try {
|
|
280
|
+
const content = this.extractContent(message);
|
|
281
|
+
if (!content || content.trim().length === 0) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
id: message.id ?? (0, uuid_1.v4)(),
|
|
286
|
+
role: this.mapRole(message),
|
|
287
|
+
content: content,
|
|
288
|
+
timestamp: new Date()
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Maps a LangChain message type to a standard role string.
|
|
297
|
+
*
|
|
298
|
+
* @param message - The LangChain BaseMessage to map.
|
|
299
|
+
* @returns The mapped role string.
|
|
300
|
+
*/
|
|
301
|
+
mapRole(message) {
|
|
302
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- LangChain API deprecation, not our code
|
|
303
|
+
const type = message.getType();
|
|
304
|
+
switch (type) {
|
|
305
|
+
case 'human':
|
|
306
|
+
return 'user';
|
|
307
|
+
case 'ai':
|
|
308
|
+
return 'assistant';
|
|
309
|
+
case 'system':
|
|
310
|
+
return 'system';
|
|
311
|
+
case 'tool':
|
|
312
|
+
return 'tool';
|
|
313
|
+
case 'function':
|
|
314
|
+
return 'function';
|
|
315
|
+
case 'chat':
|
|
316
|
+
// ChatMessage has a role property
|
|
317
|
+
return message.role ?? 'user';
|
|
318
|
+
default:
|
|
319
|
+
return 'user';
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Extracts text content from a LangChain message.
|
|
324
|
+
* Handles both string content and ContentPart arrays.
|
|
325
|
+
*
|
|
326
|
+
* @param message - The LangChain BaseMessage to extract content from.
|
|
327
|
+
* @returns The extracted text content as a string.
|
|
328
|
+
*/
|
|
329
|
+
extractContent(message) {
|
|
330
|
+
// Try the text accessor first (handles ContentPart arrays)
|
|
331
|
+
try {
|
|
332
|
+
const text = message.text;
|
|
333
|
+
if (text && text.trim().length > 0) {
|
|
334
|
+
return text;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
// text accessor might throw for non-text content
|
|
339
|
+
}
|
|
340
|
+
// Fallback to content property
|
|
341
|
+
if (typeof message.content === 'string') {
|
|
342
|
+
return message.content;
|
|
343
|
+
}
|
|
344
|
+
// Handle ContentPart array
|
|
345
|
+
if (Array.isArray(message.content)) {
|
|
346
|
+
const textParts = message.content
|
|
347
|
+
.filter((part) => typeof part === 'object' && part !== null && 'text' in part)
|
|
348
|
+
.map(part => part.text)
|
|
349
|
+
.filter(text => text && text.length > 0);
|
|
350
|
+
if (textParts.length > 0) {
|
|
351
|
+
return textParts.join(' ');
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return '';
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
exports.McpToolRegistrationService = McpToolRegistrationService;
|
|
358
|
+
//# sourceMappingURL=McpToolRegistrationService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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,CAAC,CAAC,CAAC;YAE3C,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzB,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAlZD,gEAkZC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ToolingConfiguration } from '@microsoft/agents-a365-tooling';
|
|
2
|
+
import { LangChainToolingConfigurationOptions } from './LangChainToolingConfigurationOptions';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for LangChain tooling extension package.
|
|
5
|
+
* Inherits all tooling and runtime settings.
|
|
6
|
+
*
|
|
7
|
+
* ## Why This Class Exists
|
|
8
|
+
*
|
|
9
|
+
* Although this class currently adds no new settings beyond what ToolingConfiguration
|
|
10
|
+
* provides, it exists for several important reasons:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Type Safety**: Allows LangChain-specific services to declare their dependency on
|
|
13
|
+
* `IConfigurationProvider<LangChainToolingConfiguration>`, making the configuration
|
|
14
|
+
* contract explicit and enabling compile-time checking.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Extension Point**: Provides a clear place to add LangChain-specific settings
|
|
17
|
+
* (e.g., graph execution timeouts, checkpoint intervals, memory limits) without
|
|
18
|
+
* breaking existing code when those needs arise.
|
|
19
|
+
*
|
|
20
|
+
* 3. **Consistent Pattern**: Maintains symmetry with other extension packages
|
|
21
|
+
* (Claude, OpenAI), making the SDK easier to understand and navigate.
|
|
22
|
+
*
|
|
23
|
+
* 4. **Dependency Injection**: Services can be designed to accept this specific
|
|
24
|
+
* configuration type, enabling proper IoC patterns and testability.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Service declares explicit dependency on LangChain configuration
|
|
29
|
+
* class LangChainService {
|
|
30
|
+
* constructor(private configProvider: IConfigurationProvider<LangChainToolingConfiguration>) {}
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* // Future: Add LangChain-specific settings without breaking changes
|
|
34
|
+
* class LangChainToolingConfiguration extends ToolingConfiguration {
|
|
35
|
+
* get graphExecutionTimeout(): number { ... }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class LangChainToolingConfiguration extends ToolingConfiguration {
|
|
40
|
+
constructor(overrides?: LangChainToolingConfigurationOptions);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=LangChainToolingConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LangChainToolingConfiguration.d.ts","sourceRoot":"","sources":["../../../src/configuration/LangChainToolingConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,6BAA8B,SAAQ,oBAAoB;gBACzD,SAAS,CAAC,EAAE,oCAAoC;CAK7D"}
|