@memberjunction/core-actions 3.3.0 → 3.4.0
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/custom/mcp/execute-mcp-tool.action.d.ts +50 -0
- package/dist/custom/mcp/execute-mcp-tool.action.d.ts.map +1 -0
- package/dist/custom/mcp/execute-mcp-tool.action.js +174 -0
- package/dist/custom/mcp/execute-mcp-tool.action.js.map +1 -0
- package/dist/custom/mcp/index.d.ts +20 -0
- package/dist/custom/mcp/index.d.ts.map +1 -0
- package/dist/custom/mcp/index.js +48 -0
- package/dist/custom/mcp/index.js.map +1 -0
- package/dist/custom/mcp/list-mcp-tools.action.d.ts +43 -0
- package/dist/custom/mcp/list-mcp-tools.action.d.ts.map +1 -0
- package/dist/custom/mcp/list-mcp-tools.action.js +135 -0
- package/dist/custom/mcp/list-mcp-tools.action.js.map +1 -0
- package/dist/custom/mcp/mcp-tool.action.d.ts +71 -0
- package/dist/custom/mcp/mcp-tool.action.d.ts.map +1 -0
- package/dist/custom/mcp/mcp-tool.action.js +230 -0
- package/dist/custom/mcp/mcp-tool.action.js.map +1 -0
- package/dist/custom/mcp/sync-mcp-tools.action.d.ts +44 -0
- package/dist/custom/mcp/sync-mcp-tools.action.d.ts.map +1 -0
- package/dist/custom/mcp/sync-mcp-tools.action.js +130 -0
- package/dist/custom/mcp/sync-mcp-tools.action.js.map +1 -0
- package/dist/custom/mcp/test-mcp-connection.action.d.ts +43 -0
- package/dist/custom/mcp/test-mcp-connection.action.d.ts.map +1 -0
- package/dist/custom/mcp/test-mcp-connection.action.js +125 -0
- package/dist/custom/mcp/test-mcp-connection.action.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Action to execute a tool on an MCP server
|
|
3
|
+
*
|
|
4
|
+
* This action provides a workflow/agent interface for invoking tools
|
|
5
|
+
* on external MCP servers via MCPClientManager.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/actions/mcp/execute-mcp-tool
|
|
8
|
+
*/
|
|
9
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
10
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
11
|
+
/**
|
|
12
|
+
* Action to execute a tool on an MCP server.
|
|
13
|
+
*
|
|
14
|
+
* This action connects to an MCP server (if not already connected),
|
|
15
|
+
* calls the specified tool with provided arguments, and returns the result.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* await runAction({
|
|
20
|
+
* ActionName: 'Execute MCP Tool',
|
|
21
|
+
* Params: [
|
|
22
|
+
* { Name: 'ConnectionID', Value: 'connection-uuid' },
|
|
23
|
+
* { Name: 'ToolName', Value: 'search_documents' },
|
|
24
|
+
* { Name: 'Arguments', Value: { query: 'MJ documentation', maxResults: 10 } }
|
|
25
|
+
* ]
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* **Parameters:**
|
|
30
|
+
* - `ConnectionID` (required): UUID of the MCP Server Connection to use
|
|
31
|
+
* - `ToolName` (required): Name of the tool to execute
|
|
32
|
+
* - `Arguments` (optional): Object with tool input parameters
|
|
33
|
+
* - `Timeout` (optional): Request timeout in milliseconds (default: 60000)
|
|
34
|
+
*
|
|
35
|
+
* **Result:**
|
|
36
|
+
* - Success: Tool output in Message as JSON
|
|
37
|
+
* - Output params include: `ToolOutput`, `DurationMs`, `IsToolError`
|
|
38
|
+
*/
|
|
39
|
+
export declare class ExecuteMCPToolAction extends BaseAction {
|
|
40
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
41
|
+
private getStringParam;
|
|
42
|
+
private getNumericParam;
|
|
43
|
+
private getObjectParam;
|
|
44
|
+
private addOutputParam;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Loader function to prevent tree-shaking
|
|
48
|
+
*/
|
|
49
|
+
export declare function LoadExecuteMCPToolAction(): void;
|
|
50
|
+
//# sourceMappingURL=execute-mcp-tool.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-mcp-tool.action.d.ts","sourceRoot":"","sources":["../../../src/custom/mcp/execute-mcp-tool.action.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,oBAAqB,SAAQ,UAAU;cAEhC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqFvF,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,cAAc;CAOzB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Action to execute a tool on an MCP server
|
|
4
|
+
*
|
|
5
|
+
* This action provides a workflow/agent interface for invoking tools
|
|
6
|
+
* on external MCP servers via MCPClientManager.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/actions/mcp/execute-mcp-tool
|
|
9
|
+
*/
|
|
10
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.LoadExecuteMCPToolAction = exports.ExecuteMCPToolAction = void 0;
|
|
18
|
+
const global_1 = require("@memberjunction/global");
|
|
19
|
+
const actions_1 = require("@memberjunction/actions");
|
|
20
|
+
const core_1 = require("@memberjunction/core");
|
|
21
|
+
const ai_mcp_client_1 = require("@memberjunction/ai-mcp-client");
|
|
22
|
+
/**
|
|
23
|
+
* Action to execute a tool on an MCP server.
|
|
24
|
+
*
|
|
25
|
+
* This action connects to an MCP server (if not already connected),
|
|
26
|
+
* calls the specified tool with provided arguments, and returns the result.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* await runAction({
|
|
31
|
+
* ActionName: 'Execute MCP Tool',
|
|
32
|
+
* Params: [
|
|
33
|
+
* { Name: 'ConnectionID', Value: 'connection-uuid' },
|
|
34
|
+
* { Name: 'ToolName', Value: 'search_documents' },
|
|
35
|
+
* { Name: 'Arguments', Value: { query: 'MJ documentation', maxResults: 10 } }
|
|
36
|
+
* ]
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* **Parameters:**
|
|
41
|
+
* - `ConnectionID` (required): UUID of the MCP Server Connection to use
|
|
42
|
+
* - `ToolName` (required): Name of the tool to execute
|
|
43
|
+
* - `Arguments` (optional): Object with tool input parameters
|
|
44
|
+
* - `Timeout` (optional): Request timeout in milliseconds (default: 60000)
|
|
45
|
+
*
|
|
46
|
+
* **Result:**
|
|
47
|
+
* - Success: Tool output in Message as JSON
|
|
48
|
+
* - Output params include: `ToolOutput`, `DurationMs`, `IsToolError`
|
|
49
|
+
*/
|
|
50
|
+
let ExecuteMCPToolAction = class ExecuteMCPToolAction extends actions_1.BaseAction {
|
|
51
|
+
async InternalRunAction(params) {
|
|
52
|
+
try {
|
|
53
|
+
// Extract parameters
|
|
54
|
+
const connectionId = this.getStringParam(params, 'ConnectionID');
|
|
55
|
+
const toolName = this.getStringParam(params, 'ToolName');
|
|
56
|
+
const arguments_ = this.getObjectParam(params, 'Arguments') ?? {};
|
|
57
|
+
const timeout = this.getNumericParam(params, 'Timeout', 60000);
|
|
58
|
+
// Validate required parameters
|
|
59
|
+
if (!connectionId) {
|
|
60
|
+
return {
|
|
61
|
+
Success: false,
|
|
62
|
+
ResultCode: 'MISSING_PARAMETER',
|
|
63
|
+
Message: "Parameter 'ConnectionID' is required"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (!toolName) {
|
|
67
|
+
return {
|
|
68
|
+
Success: false,
|
|
69
|
+
ResultCode: 'MISSING_PARAMETER',
|
|
70
|
+
Message: "Parameter 'ToolName' is required"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Get the MCP Client Manager
|
|
74
|
+
const manager = ai_mcp_client_1.MCPClientManager.Instance;
|
|
75
|
+
// Ensure we're connected (will connect if not already)
|
|
76
|
+
if (!manager.isConnected(connectionId)) {
|
|
77
|
+
await manager.connect(connectionId, {
|
|
78
|
+
contextUser: params.ContextUser,
|
|
79
|
+
skipAutoSync: true // Don't auto-sync when just calling tools
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// Call the tool
|
|
83
|
+
const result = await manager.callTool(connectionId, toolName, {
|
|
84
|
+
arguments: arguments_,
|
|
85
|
+
timeout
|
|
86
|
+
}, { contextUser: params.ContextUser });
|
|
87
|
+
// Add output parameters
|
|
88
|
+
this.addOutputParam(params, 'ToolOutput', result.content);
|
|
89
|
+
this.addOutputParam(params, 'StructuredOutput', result.structuredContent);
|
|
90
|
+
this.addOutputParam(params, 'DurationMs', result.durationMs);
|
|
91
|
+
this.addOutputParam(params, 'IsToolError', result.isToolError);
|
|
92
|
+
if (!result.success) {
|
|
93
|
+
return {
|
|
94
|
+
Success: false,
|
|
95
|
+
ResultCode: result.isToolError ? 'TOOL_ERROR' : 'EXECUTION_FAILED',
|
|
96
|
+
Message: result.error ?? 'Tool execution failed',
|
|
97
|
+
Params: params.Params
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Format output message
|
|
101
|
+
const output = result.structuredContent ?? result.content;
|
|
102
|
+
const message = typeof output === 'string' ? output : JSON.stringify(output, null, 2);
|
|
103
|
+
return {
|
|
104
|
+
Success: true,
|
|
105
|
+
ResultCode: 'SUCCESS',
|
|
106
|
+
Message: message,
|
|
107
|
+
Params: params.Params
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
(0, core_1.LogError)(`[ExecuteMCPToolAction] Error: ${error}`);
|
|
112
|
+
return {
|
|
113
|
+
Success: false,
|
|
114
|
+
ResultCode: 'UNEXPECTED_ERROR',
|
|
115
|
+
Message: error instanceof Error ? error.message : String(error)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Helper methods for parameter extraction
|
|
120
|
+
getStringParam(params, name) {
|
|
121
|
+
const param = params.Params.find(p => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
122
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
const value = String(param.Value).trim();
|
|
126
|
+
return value.length > 0 ? value : undefined;
|
|
127
|
+
}
|
|
128
|
+
getNumericParam(params, name, defaultValue) {
|
|
129
|
+
const param = params.Params.find(p => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
130
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
131
|
+
return defaultValue;
|
|
132
|
+
}
|
|
133
|
+
const parsed = Number(param.Value);
|
|
134
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
135
|
+
}
|
|
136
|
+
getObjectParam(params, name) {
|
|
137
|
+
const param = params.Params.find(p => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
138
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
// Handle both JSON string and object input
|
|
142
|
+
if (typeof param.Value === 'string') {
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(param.Value);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (typeof param.Value === 'object') {
|
|
151
|
+
return param.Value;
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
addOutputParam(params, name, value) {
|
|
156
|
+
params.Params.push({
|
|
157
|
+
Name: name,
|
|
158
|
+
Type: 'Output',
|
|
159
|
+
Value: value
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
exports.ExecuteMCPToolAction = ExecuteMCPToolAction;
|
|
164
|
+
exports.ExecuteMCPToolAction = ExecuteMCPToolAction = __decorate([
|
|
165
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "Execute MCP Tool")
|
|
166
|
+
], ExecuteMCPToolAction);
|
|
167
|
+
/**
|
|
168
|
+
* Loader function to prevent tree-shaking
|
|
169
|
+
*/
|
|
170
|
+
function LoadExecuteMCPToolAction() {
|
|
171
|
+
// Intentionally empty - ensures decorator executes
|
|
172
|
+
}
|
|
173
|
+
exports.LoadExecuteMCPToolAction = LoadExecuteMCPToolAction;
|
|
174
|
+
//# sourceMappingURL=execute-mcp-tool.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-mcp-tool.action.js","sourceRoot":"","sources":["../../../src/custom/mcp/execute-mcp-tool.action.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;AAGH,mDAAuD;AACvD,qDAAqD;AACrD,+CAAgD;AAChD,iEAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEI,IAAM,oB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Model Context Protocol) Actions for MemberJunction
|
|
3
|
+
*
|
|
4
|
+
* This module provides Actions for interacting with external MCP servers,
|
|
5
|
+
* enabling workflow and agent integration with MCP tool capabilities.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/actions/mcp
|
|
8
|
+
*/
|
|
9
|
+
export { ExecuteMCPToolAction, LoadExecuteMCPToolAction } from './execute-mcp-tool.action.js';
|
|
10
|
+
export { SyncMCPToolsAction, LoadSyncMCPToolsAction } from './sync-mcp-tools.action.js';
|
|
11
|
+
export { TestMCPConnectionAction, LoadTestMCPConnectionAction } from './test-mcp-connection.action.js';
|
|
12
|
+
export { ListMCPToolsAction, LoadListMCPToolsAction } from './list-mcp-tools.action.js';
|
|
13
|
+
export { MCPToolAction, LoadMCPToolAction } from './mcp-tool.action.js';
|
|
14
|
+
/**
|
|
15
|
+
* Loads all MCP actions to prevent tree-shaking.
|
|
16
|
+
* Call this function at application startup to ensure
|
|
17
|
+
* all MCP actions are registered with the class factory.
|
|
18
|
+
*/
|
|
19
|
+
export declare function LoadAllMCPActions(): void;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAOxC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview MCP (Model Context Protocol) Actions for MemberJunction
|
|
4
|
+
*
|
|
5
|
+
* This module provides Actions for interacting with external MCP servers,
|
|
6
|
+
* enabling workflow and agent integration with MCP tool capabilities.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/actions/mcp
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.LoadAllMCPActions = exports.LoadMCPToolAction = exports.MCPToolAction = exports.LoadListMCPToolsAction = exports.ListMCPToolsAction = exports.LoadTestMCPConnectionAction = exports.TestMCPConnectionAction = exports.LoadSyncMCPToolsAction = exports.SyncMCPToolsAction = exports.LoadExecuteMCPToolAction = exports.ExecuteMCPToolAction = void 0;
|
|
12
|
+
// Action exports
|
|
13
|
+
var execute_mcp_tool_action_js_1 = require("./execute-mcp-tool.action.js");
|
|
14
|
+
Object.defineProperty(exports, "ExecuteMCPToolAction", { enumerable: true, get: function () { return execute_mcp_tool_action_js_1.ExecuteMCPToolAction; } });
|
|
15
|
+
Object.defineProperty(exports, "LoadExecuteMCPToolAction", { enumerable: true, get: function () { return execute_mcp_tool_action_js_1.LoadExecuteMCPToolAction; } });
|
|
16
|
+
var sync_mcp_tools_action_js_1 = require("./sync-mcp-tools.action.js");
|
|
17
|
+
Object.defineProperty(exports, "SyncMCPToolsAction", { enumerable: true, get: function () { return sync_mcp_tools_action_js_1.SyncMCPToolsAction; } });
|
|
18
|
+
Object.defineProperty(exports, "LoadSyncMCPToolsAction", { enumerable: true, get: function () { return sync_mcp_tools_action_js_1.LoadSyncMCPToolsAction; } });
|
|
19
|
+
var test_mcp_connection_action_js_1 = require("./test-mcp-connection.action.js");
|
|
20
|
+
Object.defineProperty(exports, "TestMCPConnectionAction", { enumerable: true, get: function () { return test_mcp_connection_action_js_1.TestMCPConnectionAction; } });
|
|
21
|
+
Object.defineProperty(exports, "LoadTestMCPConnectionAction", { enumerable: true, get: function () { return test_mcp_connection_action_js_1.LoadTestMCPConnectionAction; } });
|
|
22
|
+
var list_mcp_tools_action_js_1 = require("./list-mcp-tools.action.js");
|
|
23
|
+
Object.defineProperty(exports, "ListMCPToolsAction", { enumerable: true, get: function () { return list_mcp_tools_action_js_1.ListMCPToolsAction; } });
|
|
24
|
+
Object.defineProperty(exports, "LoadListMCPToolsAction", { enumerable: true, get: function () { return list_mcp_tools_action_js_1.LoadListMCPToolsAction; } });
|
|
25
|
+
var mcp_tool_action_js_1 = require("./mcp-tool.action.js");
|
|
26
|
+
Object.defineProperty(exports, "MCPToolAction", { enumerable: true, get: function () { return mcp_tool_action_js_1.MCPToolAction; } });
|
|
27
|
+
Object.defineProperty(exports, "LoadMCPToolAction", { enumerable: true, get: function () { return mcp_tool_action_js_1.LoadMCPToolAction; } });
|
|
28
|
+
/**
|
|
29
|
+
* Loads all MCP actions to prevent tree-shaking.
|
|
30
|
+
* Call this function at application startup to ensure
|
|
31
|
+
* all MCP actions are registered with the class factory.
|
|
32
|
+
*/
|
|
33
|
+
function LoadAllMCPActions() {
|
|
34
|
+
// Importing the loader functions ensures decorators execute
|
|
35
|
+
(0, execute_mcp_tool_action_js_2.LoadExecuteMCPToolAction)();
|
|
36
|
+
(0, sync_mcp_tools_action_js_2.LoadSyncMCPToolsAction)();
|
|
37
|
+
(0, test_mcp_connection_action_js_2.LoadTestMCPConnectionAction)();
|
|
38
|
+
(0, list_mcp_tools_action_js_2.LoadListMCPToolsAction)();
|
|
39
|
+
(0, mcp_tool_action_js_2.LoadMCPToolAction)();
|
|
40
|
+
}
|
|
41
|
+
exports.LoadAllMCPActions = LoadAllMCPActions;
|
|
42
|
+
// Re-export loader functions
|
|
43
|
+
const execute_mcp_tool_action_js_2 = require("./execute-mcp-tool.action.js");
|
|
44
|
+
const sync_mcp_tools_action_js_2 = require("./sync-mcp-tools.action.js");
|
|
45
|
+
const test_mcp_connection_action_js_2 = require("./test-mcp-connection.action.js");
|
|
46
|
+
const list_mcp_tools_action_js_2 = require("./list-mcp-tools.action.js");
|
|
47
|
+
const mcp_tool_action_js_2 = require("./mcp-tool.action.js");
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/custom/mcp/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,iBAAiB;AACjB,2EAA8F;AAArF,kIAAA,oBAAoB,OAAA;AAAE,sIAAA,wBAAwB,OAAA;AACvD,uEAAwF;AAA/E,8HAAA,kBAAkB,OAAA;AAAE,kIAAA,sBAAsB,OAAA;AACnD,iFAAuG;AAA9F,wIAAA,uBAAuB,OAAA;AAAE,4IAAA,2BAA2B,OAAA;AAC7D,uEAAwF;AAA/E,8HAAA,kBAAkB,OAAA;AAAE,kIAAA,sBAAsB,OAAA;AACnD,2DAAwE;AAA/D,mHAAA,aAAa,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAEzC;;;;GAIG;AACH,SAAgB,iBAAiB;IAC7B,4DAA4D;IAC5D,IAAA,qDAAwB,GAAE,CAAC;IAC3B,IAAA,iDAAsB,GAAE,CAAC;IACzB,IAAA,2DAA2B,GAAE,CAAC;IAC9B,IAAA,iDAAsB,GAAE,CAAC;IACzB,IAAA,sCAAiB,GAAE,CAAC;AACxB,CAAC;AAPD,8CAOC;AAED,6BAA6B;AAC7B,6EAAwE;AACxE,yEAAoE;AACpE,mFAA8E;AAC9E,yEAAoE;AACpE,6DAAyD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Action to list available tools from an MCP server
|
|
3
|
+
*
|
|
4
|
+
* This action retrieves the list of tools available from an MCP server
|
|
5
|
+
* connection, useful for discovery and documentation purposes.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/actions/mcp/list-mcp-tools
|
|
8
|
+
*/
|
|
9
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
10
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
11
|
+
/**
|
|
12
|
+
* Action to list available tools from an MCP server.
|
|
13
|
+
*
|
|
14
|
+
* This action connects to an MCP server and retrieves the list of
|
|
15
|
+
* available tools with their names, descriptions, and input schemas.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* await runAction({
|
|
20
|
+
* ActionName: 'List MCP Tools',
|
|
21
|
+
* Params: [
|
|
22
|
+
* { Name: 'ConnectionID', Value: 'connection-uuid' }
|
|
23
|
+
* ]
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* **Parameters:**
|
|
28
|
+
* - `ConnectionID` (required): UUID of the MCP Server Connection to query
|
|
29
|
+
*
|
|
30
|
+
* **Result:**
|
|
31
|
+
* - Success: Tool list in Message as JSON
|
|
32
|
+
* - Output params include: `Tools`, `ToolCount`
|
|
33
|
+
*/
|
|
34
|
+
export declare class ListMCPToolsAction extends BaseAction {
|
|
35
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
36
|
+
private getStringParam;
|
|
37
|
+
private addOutputParam;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loader function to prevent tree-shaking
|
|
41
|
+
*/
|
|
42
|
+
export declare function LoadListMCPToolsAction(): void;
|
|
43
|
+
//# sourceMappingURL=list-mcp-tools.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-mcp-tools.action.d.ts","sourceRoot":"","sources":["../../../src/custom/mcp/list-mcp-tools.action.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,kBAAmB,SAAQ,UAAU;cAE9B,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAyEvF,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,cAAc;CAOzB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Action to list available tools from an MCP server
|
|
4
|
+
*
|
|
5
|
+
* This action retrieves the list of tools available from an MCP server
|
|
6
|
+
* connection, useful for discovery and documentation purposes.
|
|
7
|
+
*
|
|
8
|
+
* @module @memberjunction/actions/mcp/list-mcp-tools
|
|
9
|
+
*/
|
|
10
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.LoadListMCPToolsAction = exports.ListMCPToolsAction = void 0;
|
|
18
|
+
const global_1 = require("@memberjunction/global");
|
|
19
|
+
const actions_1 = require("@memberjunction/actions");
|
|
20
|
+
const core_1 = require("@memberjunction/core");
|
|
21
|
+
const ai_mcp_client_1 = require("@memberjunction/ai-mcp-client");
|
|
22
|
+
/**
|
|
23
|
+
* Action to list available tools from an MCP server.
|
|
24
|
+
*
|
|
25
|
+
* This action connects to an MCP server and retrieves the list of
|
|
26
|
+
* available tools with their names, descriptions, and input schemas.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* await runAction({
|
|
31
|
+
* ActionName: 'List MCP Tools',
|
|
32
|
+
* Params: [
|
|
33
|
+
* { Name: 'ConnectionID', Value: 'connection-uuid' }
|
|
34
|
+
* ]
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* **Parameters:**
|
|
39
|
+
* - `ConnectionID` (required): UUID of the MCP Server Connection to query
|
|
40
|
+
*
|
|
41
|
+
* **Result:**
|
|
42
|
+
* - Success: Tool list in Message as JSON
|
|
43
|
+
* - Output params include: `Tools`, `ToolCount`
|
|
44
|
+
*/
|
|
45
|
+
let ListMCPToolsAction = class ListMCPToolsAction extends actions_1.BaseAction {
|
|
46
|
+
async InternalRunAction(params) {
|
|
47
|
+
try {
|
|
48
|
+
// Extract parameters
|
|
49
|
+
const connectionId = this.getStringParam(params, 'ConnectionID');
|
|
50
|
+
// Validate required parameters
|
|
51
|
+
if (!connectionId) {
|
|
52
|
+
return {
|
|
53
|
+
Success: false,
|
|
54
|
+
ResultCode: 'MISSING_PARAMETER',
|
|
55
|
+
Message: "Parameter 'ConnectionID' is required"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Get the MCP Client Manager
|
|
59
|
+
const manager = ai_mcp_client_1.MCPClientManager.Instance;
|
|
60
|
+
// Ensure we're connected
|
|
61
|
+
if (!manager.isConnected(connectionId)) {
|
|
62
|
+
await manager.connect(connectionId, {
|
|
63
|
+
contextUser: params.ContextUser,
|
|
64
|
+
skipAutoSync: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// List tools
|
|
68
|
+
const result = await manager.listTools(connectionId, {
|
|
69
|
+
contextUser: params.ContextUser
|
|
70
|
+
});
|
|
71
|
+
// Add output parameters
|
|
72
|
+
this.addOutputParam(params, 'Tools', result.tools);
|
|
73
|
+
this.addOutputParam(params, 'ToolCount', result.tools.length);
|
|
74
|
+
if (!result.success) {
|
|
75
|
+
return {
|
|
76
|
+
Success: false,
|
|
77
|
+
ResultCode: 'LIST_FAILED',
|
|
78
|
+
Message: result.error ?? 'Failed to list tools',
|
|
79
|
+
Params: params.Params
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Format output message with tool summary
|
|
83
|
+
const toolSummary = result.tools.map(t => ({
|
|
84
|
+
name: t.name,
|
|
85
|
+
description: t.description ?? '(No description)'
|
|
86
|
+
}));
|
|
87
|
+
const message = JSON.stringify({
|
|
88
|
+
count: result.tools.length,
|
|
89
|
+
tools: toolSummary
|
|
90
|
+
}, null, 2);
|
|
91
|
+
return {
|
|
92
|
+
Success: true,
|
|
93
|
+
ResultCode: 'SUCCESS',
|
|
94
|
+
Message: message,
|
|
95
|
+
Params: params.Params
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
(0, core_1.LogError)(`[ListMCPToolsAction] Error: ${error}`);
|
|
100
|
+
return {
|
|
101
|
+
Success: false,
|
|
102
|
+
ResultCode: 'UNEXPECTED_ERROR',
|
|
103
|
+
Message: error instanceof Error ? error.message : String(error)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Helper methods for parameter extraction
|
|
108
|
+
getStringParam(params, name) {
|
|
109
|
+
const param = params.Params.find(p => p.Name.trim().toLowerCase() === name.toLowerCase());
|
|
110
|
+
if (!param || param.Value === undefined || param.Value === null) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
const value = String(param.Value).trim();
|
|
114
|
+
return value.length > 0 ? value : undefined;
|
|
115
|
+
}
|
|
116
|
+
addOutputParam(params, name, value) {
|
|
117
|
+
params.Params.push({
|
|
118
|
+
Name: name,
|
|
119
|
+
Type: 'Output',
|
|
120
|
+
Value: value
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.ListMCPToolsAction = ListMCPToolsAction;
|
|
125
|
+
exports.ListMCPToolsAction = ListMCPToolsAction = __decorate([
|
|
126
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, "List MCP Tools")
|
|
127
|
+
], ListMCPToolsAction);
|
|
128
|
+
/**
|
|
129
|
+
* Loader function to prevent tree-shaking
|
|
130
|
+
*/
|
|
131
|
+
function LoadListMCPToolsAction() {
|
|
132
|
+
// Intentionally empty - ensures decorator executes
|
|
133
|
+
}
|
|
134
|
+
exports.LoadListMCPToolsAction = LoadListMCPToolsAction;
|
|
135
|
+
//# sourceMappingURL=list-mcp-tools.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-mcp-tools.action.js","sourceRoot":"","sources":["../../../src/custom/mcp/list-mcp-tools.action.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;AAGH,mDAAuD;AACvD,qDAAqD;AACrD,+CAAgD;AAChD,iEAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,oBAAU;IAEpC,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,qBAAqB;YACrB,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;YAEjE,+BAA+B;YAC/B,IAAI,CAAC,YAAY,EAAE,CAAC;gBAChB,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,mBAAmB;oBAC/B,OAAO,EAAE,sCAAsC;iBAClD,CAAC;YACN,CAAC;YAED,6BAA6B;YAC7B,MAAM,OAAO,GAAG,gCAAgB,CAAC,QAAQ,CAAC;YAE1C,yBAAyB;YACzB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC;gBACrC,MAAM,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE;oBAChC,WAAW,EAAE,MAAM,CAAC,WAAW;oBAC/B,YAAY,EAAE,IAAI;iBACrB,CAAC,CAAC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class handles execution of auto-generated Actions that are linked to
|
|
5
|
+
* MCP Server Tools via the GeneratedActionID field. When an MCP tool is synced
|
|
6
|
+
* to an Action (under System/AI/MCP/{ServerName}), this driver class is used
|
|
7
|
+
* to execute it.
|
|
8
|
+
*
|
|
9
|
+
* The class:
|
|
10
|
+
* 1. Looks up the MCPServerTool using params.Action.ID (matching GeneratedActionID)
|
|
11
|
+
* 2. Finds an active connection for the tool's server
|
|
12
|
+
* 3. Maps Action parameters to tool arguments
|
|
13
|
+
* 4. Calls the tool via MCPClientManager
|
|
14
|
+
*
|
|
15
|
+
* @module @memberjunction/actions/mcp/mcp-tool
|
|
16
|
+
*/
|
|
17
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
18
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
19
|
+
/**
|
|
20
|
+
* Generic driver class for all auto-generated MCP Tool Actions.
|
|
21
|
+
*
|
|
22
|
+
* When an MCP Server Tool is synced to an Action (via syncActionsForServer),
|
|
23
|
+
* the Action's DriverClass is set to 'MCPToolAction'. This class handles
|
|
24
|
+
* execution of all such actions by:
|
|
25
|
+
*
|
|
26
|
+
* 1. Looking up the MCPServerTool entity that has GeneratedActionID = Action.ID
|
|
27
|
+
* 2. Finding an active connection for the tool's server
|
|
28
|
+
* 3. Mapping ActionParams to tool arguments (using param Name as key)
|
|
29
|
+
* 4. Calling the MCP tool and returning the result
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // An Action with DriverClass='MCPToolAction' will be handled by this class
|
|
33
|
+
* // The tool is identified by looking up MCPServerTool.GeneratedActionID = Action.ID
|
|
34
|
+
*
|
|
35
|
+
* await runAction({
|
|
36
|
+
* ActionName: 'search_documentation', // Name matches ToolName from MCP Server
|
|
37
|
+
* Params: [
|
|
38
|
+
* { Name: 'query', Value: 'MemberJunction API' },
|
|
39
|
+
* { Name: 'maxResults', Value: 10 }
|
|
40
|
+
* ]
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* **Optional Parameter:**
|
|
44
|
+
* - `ConnectionID` (optional): Specific connection to use. If not provided,
|
|
45
|
+
* an active connection for the server will be automatically selected.
|
|
46
|
+
*/
|
|
47
|
+
export declare class MCPToolAction extends BaseAction {
|
|
48
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
49
|
+
/**
|
|
50
|
+
* Looks up the MCPServerTool entity that has GeneratedActionID matching the action ID.
|
|
51
|
+
*/
|
|
52
|
+
private lookupMCPServerTool;
|
|
53
|
+
/**
|
|
54
|
+
* Resolves the connection ID to use for the tool execution.
|
|
55
|
+
* First checks for an explicit ConnectionID parameter, then finds an active connection.
|
|
56
|
+
*/
|
|
57
|
+
private resolveConnectionId;
|
|
58
|
+
/**
|
|
59
|
+
* Builds the tool arguments object from ActionParams.
|
|
60
|
+
* Excludes system parameters like ConnectionID and Timeout.
|
|
61
|
+
*/
|
|
62
|
+
private buildToolArguments;
|
|
63
|
+
private getStringParam;
|
|
64
|
+
private getNumericParam;
|
|
65
|
+
private addOutputParam;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Loader function to prevent tree-shaking
|
|
69
|
+
*/
|
|
70
|
+
export declare function LoadMCPToolAction(): void;
|
|
71
|
+
//# sourceMappingURL=mcp-tool.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool.action.d.ts","sourceRoot":"","sources":["../../../src/custom/mcp/mcp-tool.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,aAAc,SAAQ,UAAU;cAEzB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgGvF;;OAEG;YACW,mBAAmB;IAmBjC;;;OAGG;YACW,mBAAmB;IA4BjC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,cAAc;CAOzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|