@axiom-lattice/gateway 2.1.107 → 2.1.108
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/.turbo/turbo-build.log +18 -14
- package/CHANGELOG.md +12 -0
- package/dist/chunk-K4XELOSO.mjs +432 -0
- package/dist/chunk-K4XELOSO.mjs.map +1 -0
- package/dist/index.js +2256 -1698
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +580 -521
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-configs-SHRMQHIL.mjs +29 -0
- package/dist/mcp-configs-SHRMQHIL.mjs.map +1 -0
- package/dist/{resources-HEVGN3JM.mjs → resources-P4XF764M.mjs} +81 -11
- package/dist/resources-P4XF764M.mjs.map +1 -0
- package/package.json +6 -6
- package/src/controllers/collections.ts +176 -0
- package/src/controllers/data-query.ts +5 -5
- package/src/controllers/embeddings.ts +22 -0
- package/src/controllers/entries.ts +167 -0
- package/src/controllers/mcp-configs.ts +16 -42
- package/src/controllers/resources.ts +113 -12
- package/src/controllers/run.ts +1 -1
- package/src/index.ts +56 -1
- package/src/routes/index.ts +54 -0
- package/src/services/collection_service.ts +258 -0
- package/dist/resources-HEVGN3JM.mjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.108 build /home/runner/work/agentic/agentic/packages/gateway
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -11,32 +11,36 @@
|
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[warn] [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m"import.meta" is not available with the "cjs" output format and will be empty[0m [empty-import-meta]
|
|
13
13
|
|
|
14
|
-
src/index.ts:
|
|
15
|
-
[37m
|
|
14
|
+
src/index.ts:196:33:
|
|
15
|
+
[37m 196 │ const __filename = fileURLToPath([32mimport.meta[37m.url);
|
|
16
16
|
╵ [32m~~~~~~~~~~~[0m
|
|
17
17
|
|
|
18
18
|
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
22
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
24
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
25
|
-
[32mESM[39m [1mdist/
|
|
21
|
+
[32mCJS[39m [1mdist/index.js [22m[32m344.93 KB[39m
|
|
22
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m704.14 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 435ms
|
|
24
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m276.41 KB[39m
|
|
25
|
+
[32mESM[39m [1mdist/mcp-configs-SHRMQHIL.mjs [22m[32m685.00 B[39m
|
|
26
|
+
[32mESM[39m [1mdist/chunk-K4XELOSO.mjs [22m[32m12.52 KB[39m
|
|
26
27
|
[32mESM[39m [1mdist/sender-PX32VSHB.mjs [22m[32m873.00 B[39m
|
|
28
|
+
[32mESM[39m [1mdist/WechatChannelAdapter-WSDKR4OA.mjs [22m[32m8.27 KB[39m
|
|
27
29
|
[32mESM[39m [1mdist/chunk-6CUQGDJI.mjs [22m[32m6.42 KB[39m
|
|
28
30
|
[32mESM[39m [1mdist/a2a-ERG5RMUW.mjs [22m[32m15.95 KB[39m
|
|
29
|
-
[32mESM[39m [1mdist/resources-HEVGN3JM.mjs [22m[32m10.92 KB[39m
|
|
30
31
|
[32mESM[39m [1mdist/chunk-LHQY46YB.mjs [22m[32m1.46 KB[39m
|
|
31
|
-
[32mESM[39m [1mdist/
|
|
32
|
+
[32mESM[39m [1mdist/resources-P4XF764M.mjs [22m[32m14.07 KB[39m
|
|
33
|
+
[32mESM[39m [1mdist/chunk-K4XELOSO.mjs.map [22m[32m25.53 KB[39m
|
|
32
34
|
[32mESM[39m [1mdist/sender-PX32VSHB.mjs.map [22m[32m2.07 KB[39m
|
|
35
|
+
[32mESM[39m [1mdist/mcp-configs-SHRMQHIL.mjs.map [22m[32m71.00 B[39m
|
|
36
|
+
[32mESM[39m [1mdist/WechatChannelAdapter-WSDKR4OA.mjs.map [22m[32m16.28 KB[39m
|
|
33
37
|
[32mESM[39m [1mdist/chunk-6CUQGDJI.mjs.map [22m[32m14.04 KB[39m
|
|
34
38
|
[32mESM[39m [1mdist/a2a-ERG5RMUW.mjs.map [22m[32m32.14 KB[39m
|
|
35
|
-
[32mESM[39m [1mdist/resources-HEVGN3JM.mjs.map [22m[32m19.82 KB[39m
|
|
36
39
|
[32mESM[39m [1mdist/chunk-LHQY46YB.mjs.map [22m[32m2.39 KB[39m
|
|
37
|
-
[32mESM[39m [1mdist/
|
|
38
|
-
[32mESM[39m
|
|
40
|
+
[32mESM[39m [1mdist/resources-P4XF764M.mjs.map [22m[32m26.25 KB[39m
|
|
41
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m585.00 KB[39m
|
|
42
|
+
[32mESM[39m ⚡️ Build success in 484ms
|
|
39
43
|
[34mDTS[39m Build start
|
|
40
|
-
[32mDTS[39m ⚡️ Build success in
|
|
44
|
+
[32mDTS[39m ⚡️ Build success in 20637ms
|
|
41
45
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.57 KB[39m
|
|
42
46
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.57 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.108
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f3bb4f1: huge update
|
|
8
|
+
- Updated dependencies [f3bb4f1]
|
|
9
|
+
- @axiom-lattice/core@2.1.95
|
|
10
|
+
- @axiom-lattice/pg-stores@1.0.86
|
|
11
|
+
- @axiom-lattice/protocols@2.1.49
|
|
12
|
+
- @axiom-lattice/agent-eval@2.1.89
|
|
13
|
+
- @axiom-lattice/queue-redis@1.0.48
|
|
14
|
+
|
|
3
15
|
## 2.1.107
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
// src/controllers/mcp-configs.ts
|
|
2
|
+
import {
|
|
3
|
+
getStoreLattice,
|
|
4
|
+
mcpManager,
|
|
5
|
+
McpLatticeManager
|
|
6
|
+
} from "@axiom-lattice/core";
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
function getTenantId(request) {
|
|
9
|
+
const userTenantId = request.user?.tenantId;
|
|
10
|
+
if (userTenantId) {
|
|
11
|
+
return userTenantId;
|
|
12
|
+
}
|
|
13
|
+
return request.headers["x-tenant-id"] || "default";
|
|
14
|
+
}
|
|
15
|
+
async function getMcpServerConfigList(request, reply) {
|
|
16
|
+
const tenantId = getTenantId(request);
|
|
17
|
+
try {
|
|
18
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
19
|
+
const store = storeLattice.store;
|
|
20
|
+
const configs = await store.getAllConfigs(tenantId);
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
message: "MCP server configurations retrieved successfully",
|
|
24
|
+
data: {
|
|
25
|
+
records: configs,
|
|
26
|
+
total: configs.length
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error("Failed to get MCP server configs:", error);
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
message: "Failed to retrieve MCP server configurations",
|
|
34
|
+
data: {
|
|
35
|
+
records: [],
|
|
36
|
+
total: 0
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function getMcpServerConfig(request, reply) {
|
|
42
|
+
const tenantId = getTenantId(request);
|
|
43
|
+
const { key } = request.params;
|
|
44
|
+
try {
|
|
45
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
46
|
+
const store = storeLattice.store;
|
|
47
|
+
const config = await store.getConfigByKey(tenantId, key);
|
|
48
|
+
if (!config) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
message: "MCP server configuration not found"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
message: "MCP server configuration retrieved successfully",
|
|
57
|
+
data: config
|
|
58
|
+
};
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("Failed to get MCP server config:", error);
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
message: "Failed to retrieve MCP server configuration"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function createMcpServerConfig(request, reply) {
|
|
68
|
+
const tenantId = getTenantId(request);
|
|
69
|
+
const body = request.body;
|
|
70
|
+
try {
|
|
71
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
72
|
+
const store = storeLattice.store;
|
|
73
|
+
const existing = await store.getConfigByKey(tenantId, body.key);
|
|
74
|
+
if (existing) {
|
|
75
|
+
reply.code(409);
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
message: "MCP server configuration with this key already exists"
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const id = body.id || randomUUID();
|
|
82
|
+
const config = await store.createConfig(tenantId, id, body);
|
|
83
|
+
try {
|
|
84
|
+
await connectAndRegisterTools(config);
|
|
85
|
+
await store.updateConfig(tenantId, id, { status: "connected" });
|
|
86
|
+
config.status = "connected";
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.warn("Failed to auto-connect MCP server:", error);
|
|
89
|
+
await store.updateConfig(tenantId, id, { status: "error" });
|
|
90
|
+
config.status = "error";
|
|
91
|
+
}
|
|
92
|
+
reply.code(201);
|
|
93
|
+
return {
|
|
94
|
+
success: true,
|
|
95
|
+
message: "MCP server configuration created successfully",
|
|
96
|
+
data: config
|
|
97
|
+
};
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error("Failed to create MCP server config:", error);
|
|
100
|
+
return {
|
|
101
|
+
success: false,
|
|
102
|
+
message: "Failed to create MCP server configuration"
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function updateMcpServerConfig(request, reply) {
|
|
107
|
+
const tenantId = getTenantId(request);
|
|
108
|
+
const { key } = request.params;
|
|
109
|
+
const updates = request.body;
|
|
110
|
+
try {
|
|
111
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
112
|
+
const store = storeLattice.store;
|
|
113
|
+
const existing = await store.getConfigByKey(tenantId, key);
|
|
114
|
+
if (!existing) {
|
|
115
|
+
reply.code(404);
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
message: "MCP server configuration not found"
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const shouldReconnect = updates.config !== void 0;
|
|
122
|
+
const updated = await store.updateConfig(tenantId, existing.id, updates);
|
|
123
|
+
if (!updated) {
|
|
124
|
+
return {
|
|
125
|
+
success: false,
|
|
126
|
+
message: "Failed to update MCP server configuration"
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (shouldReconnect) {
|
|
130
|
+
try {
|
|
131
|
+
await mcpManager.reconnectServer(key);
|
|
132
|
+
await mcpManager.registerToolsToToolLattice(key, updated.selectedTools);
|
|
133
|
+
await store.updateConfig(tenantId, existing.id, { status: "connected" });
|
|
134
|
+
updated.status = "connected";
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.warn("Failed to reconnect MCP server:", error);
|
|
137
|
+
await store.updateConfig(tenantId, existing.id, { status: "error" });
|
|
138
|
+
updated.status = "error";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
success: true,
|
|
143
|
+
message: "MCP server configuration updated successfully",
|
|
144
|
+
data: updated
|
|
145
|
+
};
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error("Failed to update MCP server config:", error);
|
|
148
|
+
return {
|
|
149
|
+
success: false,
|
|
150
|
+
message: "Failed to update MCP server configuration"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function deleteMcpServerConfig(request, reply) {
|
|
155
|
+
const tenantId = getTenantId(request);
|
|
156
|
+
const { keyOrId } = request.params;
|
|
157
|
+
try {
|
|
158
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
159
|
+
const store = storeLattice.store;
|
|
160
|
+
let config = await store.getConfigByKey(tenantId, keyOrId);
|
|
161
|
+
let configKey = keyOrId;
|
|
162
|
+
if (!config) {
|
|
163
|
+
config = await store.getConfigById(tenantId, keyOrId);
|
|
164
|
+
if (config) {
|
|
165
|
+
configKey = config.key;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!config) {
|
|
169
|
+
reply.code(404);
|
|
170
|
+
return {
|
|
171
|
+
success: false,
|
|
172
|
+
message: "MCP server configuration not found"
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
if (mcpManager.hasServer(configKey)) {
|
|
177
|
+
await mcpManager.removeServer(configKey);
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.warn("Failed to remove from MCP manager:", error);
|
|
181
|
+
}
|
|
182
|
+
const deleted = await store.deleteConfig(tenantId, config.id);
|
|
183
|
+
if (!deleted) {
|
|
184
|
+
return {
|
|
185
|
+
success: false,
|
|
186
|
+
message: "Failed to delete MCP server configuration"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
success: true,
|
|
191
|
+
message: "MCP server configuration deleted successfully"
|
|
192
|
+
};
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error("Failed to delete MCP server config:", error);
|
|
195
|
+
return {
|
|
196
|
+
success: false,
|
|
197
|
+
message: "Failed to delete MCP server configuration"
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async function testMcpServerConnection(request, reply) {
|
|
202
|
+
const tenantId = getTenantId(request);
|
|
203
|
+
const { key } = request.params;
|
|
204
|
+
try {
|
|
205
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
206
|
+
const store = storeLattice.store;
|
|
207
|
+
const config = await store.getConfigByKey(tenantId, key);
|
|
208
|
+
if (!config) {
|
|
209
|
+
reply.code(404);
|
|
210
|
+
return {
|
|
211
|
+
success: false,
|
|
212
|
+
message: "MCP server configuration not found"
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const testKey = `__test_${key}_${Date.now()}`;
|
|
217
|
+
const connection = convertToConnection(config.config);
|
|
218
|
+
const { latency } = await McpLatticeManager.testConnection(testKey, connection);
|
|
219
|
+
return {
|
|
220
|
+
success: true,
|
|
221
|
+
message: "Connection test successful",
|
|
222
|
+
data: {
|
|
223
|
+
connected: true,
|
|
224
|
+
latency
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return {
|
|
229
|
+
success: true,
|
|
230
|
+
message: "Connection test failed",
|
|
231
|
+
data: {
|
|
232
|
+
connected: false,
|
|
233
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error("Failed to test MCP server connection:", error);
|
|
239
|
+
return {
|
|
240
|
+
success: false,
|
|
241
|
+
message: "Failed to test MCP server connection",
|
|
242
|
+
data: {
|
|
243
|
+
connected: false,
|
|
244
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async function listMcpServerTools(request, reply) {
|
|
250
|
+
const tenantId = getTenantId(request);
|
|
251
|
+
const { key } = request.params;
|
|
252
|
+
try {
|
|
253
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
254
|
+
const store = storeLattice.store;
|
|
255
|
+
const config = await store.getConfigByKey(tenantId, key);
|
|
256
|
+
if (!config) {
|
|
257
|
+
reply.code(404);
|
|
258
|
+
return {
|
|
259
|
+
success: false,
|
|
260
|
+
message: "MCP server configuration not found"
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
if (!mcpManager.hasServer(key)) {
|
|
264
|
+
await connectAndRegisterTools(config);
|
|
265
|
+
}
|
|
266
|
+
const tools = await mcpManager.getServerTools(key);
|
|
267
|
+
return {
|
|
268
|
+
success: true,
|
|
269
|
+
message: "Tools retrieved successfully",
|
|
270
|
+
data: {
|
|
271
|
+
tools
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
} catch (error) {
|
|
275
|
+
console.error("Failed to list MCP tools:", error);
|
|
276
|
+
return {
|
|
277
|
+
success: false,
|
|
278
|
+
message: "Failed to retrieve tools"
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async function connectMcpServer(request, reply) {
|
|
283
|
+
const tenantId = getTenantId(request);
|
|
284
|
+
const { key } = request.params;
|
|
285
|
+
try {
|
|
286
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
287
|
+
const store = storeLattice.store;
|
|
288
|
+
const config = await store.getConfigByKey(tenantId, key);
|
|
289
|
+
if (!config) {
|
|
290
|
+
reply.code(404);
|
|
291
|
+
return {
|
|
292
|
+
success: false,
|
|
293
|
+
message: "MCP server configuration not found"
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
await connectAndRegisterTools(config);
|
|
297
|
+
const updated = await store.updateConfig(tenantId, config.id, {
|
|
298
|
+
status: "connected"
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
success: true,
|
|
302
|
+
message: "MCP server connected successfully",
|
|
303
|
+
data: updated || config
|
|
304
|
+
};
|
|
305
|
+
} catch (error) {
|
|
306
|
+
console.error("Failed to connect MCP server:", error);
|
|
307
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
308
|
+
const store = storeLattice.store;
|
|
309
|
+
const config = await store.getConfigByKey(tenantId, key);
|
|
310
|
+
if (config) {
|
|
311
|
+
await store.updateConfig(tenantId, config.id, { status: "error" });
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
success: false,
|
|
315
|
+
message: `Failed to connect MCP server: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
async function disconnectMcpServer(request, reply) {
|
|
320
|
+
const tenantId = getTenantId(request);
|
|
321
|
+
const { key } = request.params;
|
|
322
|
+
try {
|
|
323
|
+
const storeLattice = getStoreLattice("default", "mcp");
|
|
324
|
+
const store = storeLattice.store;
|
|
325
|
+
const config = await store.getConfigByKey(tenantId, key);
|
|
326
|
+
if (!config) {
|
|
327
|
+
reply.code(404);
|
|
328
|
+
return {
|
|
329
|
+
success: false,
|
|
330
|
+
message: "MCP server configuration not found"
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
if (mcpManager.hasServer(key)) {
|
|
334
|
+
await mcpManager.removeServer(key);
|
|
335
|
+
}
|
|
336
|
+
const updated = await store.updateConfig(tenantId, config.id, {
|
|
337
|
+
status: "disconnected"
|
|
338
|
+
});
|
|
339
|
+
return {
|
|
340
|
+
success: true,
|
|
341
|
+
message: "MCP server disconnected successfully",
|
|
342
|
+
data: updated || config
|
|
343
|
+
};
|
|
344
|
+
} catch (error) {
|
|
345
|
+
console.error("Failed to disconnect MCP server:", error);
|
|
346
|
+
return {
|
|
347
|
+
success: false,
|
|
348
|
+
message: "Failed to disconnect MCP server"
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
async function testMcpServerTools(request, reply) {
|
|
353
|
+
const body = request.body;
|
|
354
|
+
try {
|
|
355
|
+
if (!body.config) {
|
|
356
|
+
reply.code(400);
|
|
357
|
+
return {
|
|
358
|
+
success: false,
|
|
359
|
+
message: "config is required"
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
const testKey = `__test_${Date.now()}`;
|
|
363
|
+
const connection = convertToConnection(body.config);
|
|
364
|
+
const { tools } = await McpLatticeManager.testConnection(testKey, connection);
|
|
365
|
+
return {
|
|
366
|
+
success: true,
|
|
367
|
+
message: "Tools retrieved successfully",
|
|
368
|
+
data: {
|
|
369
|
+
tools
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
} catch (error) {
|
|
373
|
+
console.error("Failed to test MCP server tools:", error);
|
|
374
|
+
return {
|
|
375
|
+
success: false,
|
|
376
|
+
message: `Failed to retrieve tools: ${error instanceof Error ? error.message : String(error)}`
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function convertToConnection(config) {
|
|
381
|
+
const baseConfig = {
|
|
382
|
+
env: config.env
|
|
383
|
+
};
|
|
384
|
+
if (config.transport === "stdio") {
|
|
385
|
+
return {
|
|
386
|
+
...baseConfig,
|
|
387
|
+
transport: "stdio",
|
|
388
|
+
command: config.command,
|
|
389
|
+
args: config.args || []
|
|
390
|
+
};
|
|
391
|
+
} else {
|
|
392
|
+
return {
|
|
393
|
+
...baseConfig,
|
|
394
|
+
transport: config.transport === "streamable_http" ? "http" : config.transport,
|
|
395
|
+
url: config.url
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
async function connectAndRegisterTools(config) {
|
|
400
|
+
const connection = convertToConnection(config.config);
|
|
401
|
+
mcpManager.addServer(config.key, connection);
|
|
402
|
+
await mcpManager.connect();
|
|
403
|
+
await mcpManager.registerToolsToToolLattice(config.key, config.selectedTools);
|
|
404
|
+
}
|
|
405
|
+
function registerMcpServerConfigRoutes(app) {
|
|
406
|
+
app.get("/api/mcp-servers", getMcpServerConfigList);
|
|
407
|
+
app.get("/api/mcp-servers/:key", getMcpServerConfig);
|
|
408
|
+
app.post("/api/mcp-servers", createMcpServerConfig);
|
|
409
|
+
app.put("/api/mcp-servers/:key", updateMcpServerConfig);
|
|
410
|
+
app.delete("/api/mcp-servers/:keyOrId", deleteMcpServerConfig);
|
|
411
|
+
app.post("/api/mcp-servers/:key/test", testMcpServerConnection);
|
|
412
|
+
app.get("/api/mcp-servers/:key/tools", listMcpServerTools);
|
|
413
|
+
app.post("/api/mcp-servers/:key/connect", connectMcpServer);
|
|
414
|
+
app.post("/api/mcp-servers/:key/disconnect", disconnectMcpServer);
|
|
415
|
+
app.post("/api/mcp-servers/test-tools", testMcpServerTools);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export {
|
|
419
|
+
getMcpServerConfigList,
|
|
420
|
+
getMcpServerConfig,
|
|
421
|
+
createMcpServerConfig,
|
|
422
|
+
updateMcpServerConfig,
|
|
423
|
+
deleteMcpServerConfig,
|
|
424
|
+
testMcpServerConnection,
|
|
425
|
+
listMcpServerTools,
|
|
426
|
+
connectMcpServer,
|
|
427
|
+
disconnectMcpServer,
|
|
428
|
+
testMcpServerTools,
|
|
429
|
+
convertToConnection,
|
|
430
|
+
registerMcpServerConfigRoutes
|
|
431
|
+
};
|
|
432
|
+
//# sourceMappingURL=chunk-K4XELOSO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/controllers/mcp-configs.ts"],"sourcesContent":["/**\n * MCP Server Config Controller\n * Handles MCP server configuration CRUD operations with automatic tool registration\n */\n\nimport { FastifyRequest, FastifyReply } from \"fastify\";\nimport {\n getStoreLattice,\n mcpManager,\n McpLatticeManager,\n} from \"@axiom-lattice/core\";\nimport type {\n McpServerConfigStore,\n McpServerConfigEntry,\n CreateMcpServerConfigRequest,\n UpdateMcpServerConfigRequest,\n McpServerConfig,\n McpTool,\n} from \"@axiom-lattice/protocols\";\nimport { randomUUID } from \"crypto\";\n\n/**\n * Get tenant ID from authenticated user context\n * Falls back to request headers for backward compatibility\n */\nfunction getTenantId(request: FastifyRequest): string {\n // First try to get from authenticated user context\n const userTenantId = (request as any).user?.tenantId;\n if (userTenantId) {\n return userTenantId;\n }\n\n // Fallback to request headers for backward compatibility\n return (request.headers[\"x-tenant-id\"] as string) || \"default\";\n}\n\n/**\n * MCP server config list response\n */\ninterface McpServerConfigListResponse {\n success: boolean;\n message: string;\n data: {\n records: McpServerConfigEntry[];\n total: number;\n };\n}\n\n/**\n * MCP server config response\n */\ninterface McpServerConfigResponse {\n success: boolean;\n message: string;\n data?: McpServerConfigEntry;\n}\n\n/**\n * Test connection response\n */\ninterface TestConnectionResponse {\n success: boolean;\n message: string;\n data?: {\n connected: boolean;\n latency?: number;\n error?: string;\n };\n}\n\n/**\n * List tools response\n */\ninterface ListToolsResponse {\n success: boolean;\n message: string;\n data?: {\n tools: McpTool[];\n };\n}\n\n/**\n * Get all MCP server configs for a tenant\n */\nexport async function getMcpServerConfigList(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigListResponse> {\n const tenantId = getTenantId(request);\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const configs = await store.getAllConfigs(tenantId);\n\n return {\n success: true,\n message: \"MCP server configurations retrieved successfully\",\n data: {\n records: configs,\n total: configs.length,\n },\n };\n } catch (error) {\n console.error(\"Failed to get MCP server configs:\", error);\n return {\n success: false,\n message: \"Failed to retrieve MCP server configurations\",\n data: {\n records: [],\n total: 0,\n },\n };\n }\n}\n\n/**\n * Get MCP server config by key\n */\nexport async function getMcpServerConfig(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigResponse> {\n const tenantId = getTenantId(request);\n const { key } = request.params as { key: string };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const config = await store.getConfigByKey(tenantId, key);\n\n if (!config) {\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n return {\n success: true,\n message: \"MCP server configuration retrieved successfully\",\n data: config,\n };\n } catch (error) {\n console.error(\"Failed to get MCP server config:\", error);\n return {\n success: false,\n message: \"Failed to retrieve MCP server configuration\",\n };\n }\n}\n\n/**\n * Create new MCP server config\n */\nexport async function createMcpServerConfig(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigResponse> {\n const tenantId = getTenantId(request);\n const body = request.body as CreateMcpServerConfigRequest & {\n id?: string;\n };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n // Check if key already exists\n const existing = await store.getConfigByKey(tenantId, body.key);\n if (existing) {\n reply.code(409);\n return {\n success: false,\n message: \"MCP server configuration with this key already exists\",\n };\n }\n\n const id = body.id || randomUUID();\n const config = await store.createConfig(tenantId, id, body);\n\n // Auto-connect and register tools\n try {\n await connectAndRegisterTools(config);\n // Update status to connected\n await store.updateConfig(tenantId, id, { status: \"connected\" });\n config.status = \"connected\";\n } catch (error) {\n console.warn(\"Failed to auto-connect MCP server:\", error);\n // Update status to error but don't fail the creation\n await store.updateConfig(tenantId, id, { status: \"error\" });\n config.status = \"error\";\n }\n\n reply.code(201);\n return {\n success: true,\n message: \"MCP server configuration created successfully\",\n data: config,\n };\n } catch (error) {\n console.error(\"Failed to create MCP server config:\", error);\n return {\n success: false,\n message: \"Failed to create MCP server configuration\",\n };\n }\n}\n\n/**\n * Update MCP server config\n */\nexport async function updateMcpServerConfig(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigResponse> {\n const tenantId = getTenantId(request);\n const { key } = request.params as { key: string };\n const updates = request.body as Partial<UpdateMcpServerConfigRequest>;\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const existing = await store.getConfigByKey(tenantId, key);\n if (!existing) {\n reply.code(404);\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n // If config is being updated, we need to reconnect\n const shouldReconnect = updates.config !== undefined;\n\n const updated = await store.updateConfig(tenantId, existing.id, updates);\n\n if (!updated) {\n return {\n success: false,\n message: \"Failed to update MCP server configuration\",\n };\n }\n\n // Reconnect and re-register tools if config changed\n if (shouldReconnect) {\n try {\n // Reconnect single server without affecting others\n await mcpManager.reconnectServer(key);\n\n // Re-register tools with new config\n await mcpManager.registerToolsToToolLattice(key, updated.selectedTools);\n\n await store.updateConfig(tenantId, existing.id, { status: \"connected\" });\n updated.status = \"connected\";\n } catch (error) {\n console.warn(\"Failed to reconnect MCP server:\", error);\n await store.updateConfig(tenantId, existing.id, { status: \"error\" });\n updated.status = \"error\";\n }\n }\n\n return {\n success: true,\n message: \"MCP server configuration updated successfully\",\n data: updated,\n };\n } catch (error) {\n console.error(\"Failed to update MCP server config:\", error);\n return {\n success: false,\n message: \"Failed to update MCP server configuration\",\n };\n }\n}\n\n/**\n * Delete MCP server config by key or id\n */\nexport async function deleteMcpServerConfig(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigResponse> {\n const tenantId = getTenantId(request);\n const { keyOrId } = request.params as { keyOrId: string };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n // Try to find by key first, then by id\n let config = await store.getConfigByKey(tenantId, keyOrId);\n let configKey = keyOrId;\n\n if (!config) {\n // Try to find by id\n config = await store.getConfigById(tenantId, keyOrId);\n if (config) {\n configKey = config.key;\n }\n }\n\n if (!config) {\n reply.code(404);\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n // Disconnect and remove from MCP manager\n try {\n if (mcpManager.hasServer(configKey)) {\n await mcpManager.removeServer(configKey);\n }\n } catch (error) {\n console.warn(\"Failed to remove from MCP manager:\", error);\n }\n\n const deleted = await store.deleteConfig(tenantId, config.id);\n\n if (!deleted) {\n return {\n success: false,\n message: \"Failed to delete MCP server configuration\",\n };\n }\n\n return {\n success: true,\n message: \"MCP server configuration deleted successfully\",\n };\n } catch (error) {\n console.error(\"Failed to delete MCP server config:\", error);\n return {\n success: false,\n message: \"Failed to delete MCP server configuration\",\n };\n }\n}\n\n/**\n * Test MCP server connection\n */\nexport async function testMcpServerConnection(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<TestConnectionResponse> {\n const tenantId = getTenantId(request);\n const { key } = request.params as { key: string };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const config = await store.getConfigByKey(tenantId, key);\n if (!config) {\n reply.code(404);\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n // Test connection by creating a standalone client\n try {\n const testKey = `__test_${key}_${Date.now()}`;\n const connection = convertToConnection(config.config);\n const { latency } = await McpLatticeManager.testConnection(testKey, connection);\n\n return {\n success: true,\n message: \"Connection test successful\",\n data: {\n connected: true,\n latency,\n },\n };\n } catch (error) {\n return {\n success: true,\n message: \"Connection test failed\",\n data: {\n connected: false,\n error: error instanceof Error ? error.message : \"Unknown error\",\n },\n };\n }\n } catch (error) {\n console.error(\"Failed to test MCP server connection:\", error);\n return {\n success: false,\n message: \"Failed to test MCP server connection\",\n data: {\n connected: false,\n error: error instanceof Error ? error.message : \"Unknown error\",\n },\n };\n }\n}\n\n/**\n * List available tools from an MCP server\n */\nexport async function listMcpServerTools(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<ListToolsResponse> {\n const tenantId = getTenantId(request);\n const { key } = request.params as { key: string };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const config = await store.getConfigByKey(tenantId, key);\n if (!config) {\n reply.code(404);\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n // Ensure server is connected\n if (!mcpManager.hasServer(key)) {\n await connectAndRegisterTools(config);\n }\n\n const tools = await mcpManager.getServerTools(key);\n\n return {\n success: true,\n message: \"Tools retrieved successfully\",\n data: {\n tools,\n },\n };\n } catch (error) {\n console.error(\"Failed to list MCP tools:\", error);\n return {\n success: false,\n message: \"Failed to retrieve tools\",\n };\n }\n}\n\n/**\n * Connect to MCP server and register tools\n */\nexport async function connectMcpServer(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigResponse> {\n const tenantId = getTenantId(request);\n const { key } = request.params as { key: string };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const config = await store.getConfigByKey(tenantId, key);\n if (!config) {\n reply.code(404);\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n await connectAndRegisterTools(config);\n\n // Update status\n const updated = await store.updateConfig(tenantId, config.id, {\n status: \"connected\",\n });\n\n return {\n success: true,\n message: \"MCP server connected successfully\",\n data: updated || config,\n };\n } catch (error) {\n console.error(\"Failed to connect MCP server:\", error);\n\n // Update status to error\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n const config = await store.getConfigByKey(tenantId, key);\n if (config) {\n await store.updateConfig(tenantId, config.id, { status: \"error\" });\n }\n\n return {\n success: false,\n message: `Failed to connect MCP server: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`,\n };\n }\n}\n\n/**\n * Disconnect from MCP server\n */\nexport async function disconnectMcpServer(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<McpServerConfigResponse> {\n const tenantId = getTenantId(request);\n const { key } = request.params as { key: string };\n\n try {\n const storeLattice = getStoreLattice(\"default\", \"mcp\");\n const store: McpServerConfigStore = storeLattice.store;\n\n const config = await store.getConfigByKey(tenantId, key);\n if (!config) {\n reply.code(404);\n return {\n success: false,\n message: \"MCP server configuration not found\",\n };\n }\n\n // Disconnect from MCP manager\n if (mcpManager.hasServer(key)) {\n await mcpManager.removeServer(key);\n }\n\n // Update status\n const updated = await store.updateConfig(tenantId, config.id, {\n status: \"disconnected\",\n });\n\n return {\n success: true,\n message: \"MCP server disconnected successfully\",\n data: updated || config,\n };\n } catch (error) {\n console.error(\"Failed to disconnect MCP server:\", error);\n return {\n success: false,\n message: \"Failed to disconnect MCP server\",\n };\n }\n}\n\n/**\n * Test MCP server connection and list tools without saving config\n * Used for multi-step configuration flow\n */\nexport async function testMcpServerTools(\n request: FastifyRequest,\n reply: FastifyReply\n): Promise<ListToolsResponse> {\n const body = request.body as {\n config: McpServerConfig;\n };\n\n try {\n if (!body.config) {\n reply.code(400);\n return {\n success: false,\n message: \"config is required\",\n };\n }\n\n const testKey = `__test_${Date.now()}`;\n\n // Create standalone client for testing — does not affect global mcpManager\n const connection = convertToConnection(body.config);\n const { tools } = await McpLatticeManager.testConnection(testKey, connection);\n\n return {\n success: true,\n message: \"Tools retrieved successfully\",\n data: {\n tools,\n },\n };\n } catch (error) {\n console.error(\"Failed to test MCP server tools:\", error);\n return {\n success: false,\n message: `Failed to retrieve tools: ${\n error instanceof Error ? error.message : String(error)\n }`,\n };\n }\n}\n\n/**\n * Convert McpServerConfig to Connection format compatible with @langchain/mcp-adapters\n */\nexport function convertToConnection(config: McpServerConfig): any {\n const baseConfig = {\n env: config.env,\n };\n\n if (config.transport === \"stdio\") {\n return {\n ...baseConfig,\n transport: \"stdio\" as const,\n command: config.command!,\n args: config.args || [],\n };\n } else {\n // For HTTP/SSE transports\n return {\n ...baseConfig,\n transport: config.transport === \"streamable_http\" ? \"http\" : config.transport,\n url: config.url!,\n };\n }\n}\n\n/**\n * Helper function to connect to MCP server and register selected tools\n */\nasync function connectAndRegisterTools(\n config: McpServerConfigEntry\n): Promise<void> {\n // Add server to MCP manager\n const connection = convertToConnection(config.config);\n mcpManager.addServer(config.key, connection);\n\n // Connect only unconnected servers (new server gets connected)\n await mcpManager.connect();\n\n // Register tools for this server (handles unregister + filter + prefix)\n await mcpManager.registerToolsToToolLattice(config.key, config.selectedTools);\n}\n\n/**\n * Register MCP server config routes\n */\nexport function registerMcpServerConfigRoutes(app: any): void {\n // Get all configs\n app.get(\"/api/mcp-servers\", getMcpServerConfigList);\n\n // Get config by key\n app.get(\"/api/mcp-servers/:key\", getMcpServerConfig);\n\n // Create config\n app.post(\"/api/mcp-servers\", createMcpServerConfig);\n\n // Update config\n app.put(\"/api/mcp-servers/:key\", updateMcpServerConfig);\n\n // Delete config by key or id\n app.delete(\"/api/mcp-servers/:keyOrId\", deleteMcpServerConfig);\n\n // Test connection\n app.post(\"/api/mcp-servers/:key/test\", testMcpServerConnection);\n\n // List available tools\n app.get(\"/api/mcp-servers/:key/tools\", listMcpServerTools);\n\n // Connect to server\n app.post(\"/api/mcp-servers/:key/connect\", connectMcpServer);\n\n // Disconnect from server\n app.post(\"/api/mcp-servers/:key/disconnect\", disconnectMcpServer);\n\n // Test tools without saving config (for multi-step config flow)\n app.post(\"/api/mcp-servers/test-tools\", testMcpServerTools);\n}\n"],"mappings":";AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,kBAAkB;AAM3B,SAAS,YAAY,SAAiC;AAEpD,QAAM,eAAgB,QAAgB,MAAM;AAC5C,MAAI,cAAc;AAChB,WAAO;AAAA,EACT;AAGA,SAAQ,QAAQ,QAAQ,aAAa,KAAgB;AACvD;AAkDA,eAAsB,uBACpB,SACA,OACsC;AACtC,QAAM,WAAW,YAAY,OAAO;AAEpC,MAAI;AACF,UAAM,eAAe,gBAAgB,WAAW,KAAK;AACrD,UAAM,QAA8B,aAAa;AAEjD,UAAM,UAAU,MAAM,MAAM,cAAc,QAAQ;AAElD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,OAAO,QAAQ;AAAA,MACjB;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,qCAAqC,KAAK;AACxD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,MACT,MAAM;AAAA,QACJ,SAAS,CAAC;AAAA,QACV,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAKA,eAAsB,mBACpB,SACA,OACkC;AAClC,QAAM,WAAW,YAA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