@justanothermldude/mcp-exec 0.1.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/README.md +344 -0
- package/dist/bridge/index.d.ts +3 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +3 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/server.d.ts +84 -0
- package/dist/bridge/server.d.ts.map +1 -0
- package/dist/bridge/server.js +352 -0
- package/dist/bridge/server.js.map +1 -0
- package/dist/codegen/index.d.ts +6 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +6 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/module-resolver.d.ts +95 -0
- package/dist/codegen/module-resolver.d.ts.map +1 -0
- package/dist/codegen/module-resolver.js +152 -0
- package/dist/codegen/module-resolver.js.map +1 -0
- package/dist/codegen/wrapper-generator.d.ts +22 -0
- package/dist/codegen/wrapper-generator.d.ts.map +1 -0
- package/dist/codegen/wrapper-generator.js +282 -0
- package/dist/codegen/wrapper-generator.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/config.d.ts +37 -0
- package/dist/sandbox/config.d.ts.map +1 -0
- package/dist/sandbox/config.js +36 -0
- package/dist/sandbox/config.js.map +1 -0
- package/dist/sandbox/executor.d.ts +63 -0
- package/dist/sandbox/executor.d.ts.map +1 -0
- package/dist/sandbox/executor.js +240 -0
- package/dist/sandbox/executor.js.map +1 -0
- package/dist/sandbox/index.d.ts +8 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +9 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/server.d.ts +110 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +150 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/execute-batch.d.ts +111 -0
- package/dist/tools/execute-batch.d.ts.map +1 -0
- package/dist/tools/execute-batch.js +325 -0
- package/dist/tools/execute-batch.js.map +1 -0
- package/dist/tools/execute-code.d.ts +65 -0
- package/dist/tools/execute-code.d.ts.map +1 -0
- package/dist/tools/execute-code.js +141 -0
- package/dist/tools/execute-code.js.map +1 -0
- package/dist/tools/execute-with-context.d.ts +80 -0
- package/dist/tools/execute-with-context.d.ts.map +1 -0
- package/dist/tools/execute-with-context.js +223 -0
- package/dist/tools/execute-with-context.js.map +1 -0
- package/dist/tools/execute-with-wrappers.d.ts +69 -0
- package/dist/tools/execute-with-wrappers.d.ts.map +1 -0
- package/dist/tools/execute-with-wrappers.js +219 -0
- package/dist/tools/execute-with-wrappers.js.map +1 -0
- package/dist/tools/get-tool-schema.d.ts +59 -0
- package/dist/tools/get-tool-schema.d.ts.map +1 -0
- package/dist/tools/get-tool-schema.js +101 -0
- package/dist/tools/get-tool-schema.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +16 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-servers.d.ts +48 -0
- package/dist/tools/list-servers.d.ts.map +1 -0
- package/dist/tools/list-servers.js +85 -0
- package/dist/tools/list-servers.js.map +1 -0
- package/dist/types/execution.d.ts +25 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/execution.js +5 -0
- package/dist/types/execution.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { createServer } from 'http';
|
|
2
|
+
import { getServerConfig, listServers } from '@justanothermldude/meta-mcp-core';
|
|
3
|
+
const DEFAULT_PORT = 3000;
|
|
4
|
+
const DEFAULT_HOST = '127.0.0.1';
|
|
5
|
+
const MAX_REQUEST_BODY_SIZE = 10 * 1024 * 1024; // 10MB limit
|
|
6
|
+
/**
|
|
7
|
+
* Calculate simple string similarity using common prefix/suffix length
|
|
8
|
+
* Returns a score between 0 and 1
|
|
9
|
+
*/
|
|
10
|
+
function stringSimilarity(a, b) {
|
|
11
|
+
const aLower = a.toLowerCase();
|
|
12
|
+
const bLower = b.toLowerCase();
|
|
13
|
+
// Exact match
|
|
14
|
+
if (aLower === bLower)
|
|
15
|
+
return 1;
|
|
16
|
+
// Check if one contains the other
|
|
17
|
+
if (aLower.includes(bLower) || bLower.includes(aLower)) {
|
|
18
|
+
return 0.8;
|
|
19
|
+
}
|
|
20
|
+
// Calculate common prefix length
|
|
21
|
+
let prefixLen = 0;
|
|
22
|
+
const minLen = Math.min(aLower.length, bLower.length);
|
|
23
|
+
for (let i = 0; i < minLen; i++) {
|
|
24
|
+
if (aLower[i] === bLower[i])
|
|
25
|
+
prefixLen++;
|
|
26
|
+
else
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
// Calculate common suffix length
|
|
30
|
+
let suffixLen = 0;
|
|
31
|
+
for (let i = 0; i < minLen; i++) {
|
|
32
|
+
if (aLower[aLower.length - 1 - i] === bLower[bLower.length - 1 - i])
|
|
33
|
+
suffixLen++;
|
|
34
|
+
else
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
// Normalize by max length
|
|
38
|
+
const maxLen = Math.max(aLower.length, bLower.length);
|
|
39
|
+
return (prefixLen + suffixLen) / (2 * maxLen);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Find the most similar string from a list
|
|
43
|
+
*/
|
|
44
|
+
function findClosestMatch(target, candidates) {
|
|
45
|
+
if (candidates.length === 0)
|
|
46
|
+
return null;
|
|
47
|
+
let bestMatch = null;
|
|
48
|
+
let bestScore = 0;
|
|
49
|
+
const threshold = 0.3; // Minimum similarity to suggest
|
|
50
|
+
for (const candidate of candidates) {
|
|
51
|
+
const score = stringSimilarity(target, candidate);
|
|
52
|
+
if (score > bestScore && score >= threshold) {
|
|
53
|
+
bestScore = score;
|
|
54
|
+
bestMatch = candidate;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return bestMatch;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build enhanced error message for server not found
|
|
61
|
+
*/
|
|
62
|
+
function buildServerNotFoundError(requestedServer) {
|
|
63
|
+
const servers = listServers();
|
|
64
|
+
const serverNames = servers.map(s => s.name);
|
|
65
|
+
let errorMsg = `Server '${requestedServer}' not found.`;
|
|
66
|
+
if (serverNames.length === 0) {
|
|
67
|
+
errorMsg += ' No servers are configured. Check that servers.json is properly set up.';
|
|
68
|
+
return errorMsg;
|
|
69
|
+
}
|
|
70
|
+
// Show available servers (limit to 5)
|
|
71
|
+
const displayServers = serverNames.slice(0, 5);
|
|
72
|
+
const hasMore = serverNames.length > 5;
|
|
73
|
+
errorMsg += ` Available: ${displayServers.join(', ')}${hasMore ? ` (+${serverNames.length - 5} more)` : ''}.`;
|
|
74
|
+
// Suggest closest match
|
|
75
|
+
const closest = findClosestMatch(requestedServer, serverNames);
|
|
76
|
+
if (closest) {
|
|
77
|
+
errorMsg += ` Did you mean '${closest}'?`;
|
|
78
|
+
}
|
|
79
|
+
return errorMsg;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build enhanced error message for tool not found
|
|
83
|
+
*/
|
|
84
|
+
function buildToolNotFoundError(serverName, requestedTool, availableTools) {
|
|
85
|
+
let errorMsg = `Tool '${requestedTool}' not found on server '${serverName}'.`;
|
|
86
|
+
if (availableTools.length === 0) {
|
|
87
|
+
errorMsg += ' No tools available on this server.';
|
|
88
|
+
return errorMsg;
|
|
89
|
+
}
|
|
90
|
+
// Show available tools (limit to 5)
|
|
91
|
+
const displayTools = availableTools.slice(0, 5);
|
|
92
|
+
const hasMore = availableTools.length > 5;
|
|
93
|
+
errorMsg += ` Available tools: ${displayTools.join(', ')}${hasMore ? ` (+${availableTools.length - 5} more)` : ''}.`;
|
|
94
|
+
// Suggest closest match
|
|
95
|
+
const closest = findClosestMatch(requestedTool, availableTools);
|
|
96
|
+
if (closest) {
|
|
97
|
+
errorMsg += ` Did you mean '${closest}'?`;
|
|
98
|
+
}
|
|
99
|
+
return errorMsg;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Build enhanced error message for connection failures
|
|
103
|
+
*/
|
|
104
|
+
function buildConnectionError(serverName, originalError) {
|
|
105
|
+
let errorMsg = `Failed to connect to server '${serverName}': ${originalError}`;
|
|
106
|
+
// Add troubleshooting hints based on error content
|
|
107
|
+
const hints = [];
|
|
108
|
+
if (originalError.includes('ENOENT') || originalError.includes('not found')) {
|
|
109
|
+
hints.push('Check that the server command/binary exists and is in PATH');
|
|
110
|
+
}
|
|
111
|
+
if (originalError.includes('ECONNREFUSED')) {
|
|
112
|
+
hints.push('Check that the server process is running');
|
|
113
|
+
}
|
|
114
|
+
if (originalError.includes('timeout') || originalError.includes('Timeout')) {
|
|
115
|
+
hints.push('Server may be slow to start - try increasing timeout in servers.json');
|
|
116
|
+
}
|
|
117
|
+
if (originalError.includes('spawn')) {
|
|
118
|
+
hints.push('Verify the server configuration in servers.json');
|
|
119
|
+
}
|
|
120
|
+
// Always add general hints
|
|
121
|
+
hints.push('Is the server configured in servers.json?');
|
|
122
|
+
if (hints.length > 0) {
|
|
123
|
+
errorMsg += ` Troubleshooting: ${hints.join('; ')}.`;
|
|
124
|
+
}
|
|
125
|
+
return errorMsg;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* MCP Bridge HTTP server that allows sandboxed code to call
|
|
129
|
+
* MCP tools via HTTP requests to localhost.
|
|
130
|
+
*/
|
|
131
|
+
export class MCPBridge {
|
|
132
|
+
constructor(pool, config = {}) {
|
|
133
|
+
this.server = null;
|
|
134
|
+
this.pool = pool;
|
|
135
|
+
this.port = config.port ?? DEFAULT_PORT;
|
|
136
|
+
this.host = config.host ?? DEFAULT_HOST;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Start the HTTP bridge server
|
|
140
|
+
* @returns Promise that resolves when server is listening
|
|
141
|
+
*/
|
|
142
|
+
async start() {
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
144
|
+
this.server = createServer((req, res) => {
|
|
145
|
+
this.handleRequest(req, res);
|
|
146
|
+
});
|
|
147
|
+
this.server.on('error', (err) => {
|
|
148
|
+
reject(err);
|
|
149
|
+
});
|
|
150
|
+
this.server.listen(this.port, this.host, () => {
|
|
151
|
+
resolve();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Stop the HTTP bridge server
|
|
157
|
+
* @returns Promise that resolves when server is closed
|
|
158
|
+
*/
|
|
159
|
+
async stop() {
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
if (!this.server) {
|
|
162
|
+
resolve();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this.server.close((err) => {
|
|
166
|
+
if (err) {
|
|
167
|
+
reject(err);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
this.server = null;
|
|
171
|
+
resolve();
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get the port the server is listening on
|
|
178
|
+
*/
|
|
179
|
+
getPort() {
|
|
180
|
+
return this.port;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get the host the server is bound to
|
|
184
|
+
*/
|
|
185
|
+
getHost() {
|
|
186
|
+
return this.host;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Check if the server is running
|
|
190
|
+
*/
|
|
191
|
+
isRunning() {
|
|
192
|
+
return this.server !== null && this.server.listening;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Handle incoming HTTP requests
|
|
196
|
+
*/
|
|
197
|
+
handleRequest(req, res) {
|
|
198
|
+
// Set CORS headers - restricted to localhost since bridge only serves sandbox code
|
|
199
|
+
res.setHeader('Content-Type', 'application/json');
|
|
200
|
+
res.setHeader('Access-Control-Allow-Origin', `http://${this.host}:${this.port}`);
|
|
201
|
+
res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
|
|
202
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
203
|
+
// Handle preflight
|
|
204
|
+
if (req.method === 'OPTIONS') {
|
|
205
|
+
res.writeHead(204);
|
|
206
|
+
res.end();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
// Route requests
|
|
210
|
+
if (req.method === 'POST' && req.url === '/call') {
|
|
211
|
+
this.handleCallRequest(req, res);
|
|
212
|
+
}
|
|
213
|
+
else if (req.method === 'GET' && req.url === '/health') {
|
|
214
|
+
this.handleHealthRequest(res);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
this.sendError(res, 404, 'Not Found');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Handle POST /call endpoint for tool invocation
|
|
222
|
+
*/
|
|
223
|
+
handleCallRequest(req, res) {
|
|
224
|
+
let body = '';
|
|
225
|
+
let bodySize = 0;
|
|
226
|
+
req.on('data', (chunk) => {
|
|
227
|
+
bodySize += chunk.length;
|
|
228
|
+
if (bodySize > MAX_REQUEST_BODY_SIZE) {
|
|
229
|
+
req.destroy();
|
|
230
|
+
this.sendError(res, 413, `Request body too large. Maximum size is ${MAX_REQUEST_BODY_SIZE / 1024 / 1024}MB`);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
body += chunk.toString();
|
|
234
|
+
});
|
|
235
|
+
req.on('end', async () => {
|
|
236
|
+
try {
|
|
237
|
+
// Parse request body
|
|
238
|
+
let request;
|
|
239
|
+
try {
|
|
240
|
+
request = JSON.parse(body);
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
this.sendError(res, 400, 'Invalid JSON body');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// Validate required fields
|
|
247
|
+
if (!request.server || typeof request.server !== 'string') {
|
|
248
|
+
this.sendError(res, 400, 'Missing or invalid "server" field');
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!request.tool || typeof request.tool !== 'string') {
|
|
252
|
+
this.sendError(res, 400, 'Missing or invalid "tool" field');
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// Validate args is an object if provided
|
|
256
|
+
if (request.args !== undefined && (typeof request.args !== 'object' || request.args === null || Array.isArray(request.args))) {
|
|
257
|
+
this.sendError(res, 400, '"args" must be an object');
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
// Get connection from pool
|
|
261
|
+
let connection;
|
|
262
|
+
try {
|
|
263
|
+
connection = await this.pool.getConnection(request.server);
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
267
|
+
// Check if this is a "server not found" type error
|
|
268
|
+
if (errorMsg.includes('not found') || errorMsg.includes('No server configured') || errorMsg.includes('Unknown server')) {
|
|
269
|
+
this.sendError(res, 404, buildServerNotFoundError(request.server));
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
this.sendError(res, 502, buildConnectionError(request.server, errorMsg));
|
|
273
|
+
}
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
// Call the tool with server-configured timeout or global default
|
|
277
|
+
try {
|
|
278
|
+
const serverConfig = getServerConfig(request.server);
|
|
279
|
+
const defaultTimeout = process.env.MCP_DEFAULT_TIMEOUT
|
|
280
|
+
? parseInt(process.env.MCP_DEFAULT_TIMEOUT, 10)
|
|
281
|
+
: undefined;
|
|
282
|
+
const timeout = serverConfig?.timeout ?? defaultTimeout;
|
|
283
|
+
const result = await connection.client.callTool({
|
|
284
|
+
name: request.tool,
|
|
285
|
+
arguments: request.args ?? {},
|
|
286
|
+
}, undefined, // resultSchema
|
|
287
|
+
timeout ? { timeout } : undefined);
|
|
288
|
+
const response = {
|
|
289
|
+
success: true,
|
|
290
|
+
content: result.content,
|
|
291
|
+
isError: result.isError,
|
|
292
|
+
};
|
|
293
|
+
res.writeHead(200);
|
|
294
|
+
res.end(JSON.stringify(response));
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
298
|
+
// Check if this is a "tool not found" type error
|
|
299
|
+
if (errorMsg.includes('not found') || errorMsg.includes('Unknown tool') || errorMsg.includes('no such tool')) {
|
|
300
|
+
// Try to get available tools for better error message
|
|
301
|
+
try {
|
|
302
|
+
const tools = await connection.getTools();
|
|
303
|
+
const toolNames = tools.map(t => t.name);
|
|
304
|
+
this.sendError(res, 404, buildToolNotFoundError(request.server, request.tool, toolNames));
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
// If we can't get tools, fall back to basic error
|
|
308
|
+
this.sendError(res, 500, `Tool '${request.tool}' not found on server '${request.server}'. Unable to fetch available tools.`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
this.sendError(res, 500, `Tool execution failed: ${errorMsg}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
finally {
|
|
316
|
+
// Release connection back to pool
|
|
317
|
+
this.pool.releaseConnection(request.server);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
catch (err) {
|
|
321
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
322
|
+
this.sendError(res, 500, `Internal error: ${errorMsg}`);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
req.on('error', (err) => {
|
|
326
|
+
this.sendError(res, 400, `Request error: ${err.message}`);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Handle GET /health endpoint
|
|
331
|
+
*/
|
|
332
|
+
handleHealthRequest(res) {
|
|
333
|
+
const response = {
|
|
334
|
+
status: 'ok',
|
|
335
|
+
timestamp: new Date().toISOString(),
|
|
336
|
+
};
|
|
337
|
+
res.writeHead(200);
|
|
338
|
+
res.end(JSON.stringify(response));
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Send an error response
|
|
342
|
+
*/
|
|
343
|
+
sendError(res, statusCode, message) {
|
|
344
|
+
const response = {
|
|
345
|
+
success: false,
|
|
346
|
+
error: message,
|
|
347
|
+
};
|
|
348
|
+
res.writeHead(statusCode);
|
|
349
|
+
res.end(JSON.stringify(response));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/bridge/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA2C,MAAM,MAAM,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAsDhF,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,YAAY,GAAG,WAAW,CAAC;AACjC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7D;;;GAGG;AACH,SAAS,gBAAgB,CAAC,CAAS,EAAE,CAAS;IAC5C,MAAM,MAAM,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAE/B,cAAc;IACd,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,CAAC,CAAC;IAEhC,kCAAkC;IAClC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,iCAAiC;IACjC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC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,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAClE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,QAAQ,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,kBAAkB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,GAAmB;QAC7C,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;QACF,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACnB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACK,SAAS,CAAC,GAAmB,EAAE,UAAkB,EAAE,OAAe;QACxE,MAAM,QAAQ,GAAiB;YAC7B,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,OAAO;SACf,CAAC;QACF,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code generation utilities for MCP tool wrappers
|
|
3
|
+
*/
|
|
4
|
+
export { generateToolWrapper, generateServerModule } from './wrapper-generator.js';
|
|
5
|
+
export { VirtualModuleResolver, generateFromManifest, createModuleResolver, type GenerateFromManifestOptions, } from './module-resolver.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code generation utilities for MCP tool wrappers
|
|
3
|
+
*/
|
|
4
|
+
export { generateToolWrapper, generateServerModule } from './wrapper-generator.js';
|
|
5
|
+
export { VirtualModuleResolver, generateFromManifest, createModuleResolver, } from './module-resolver.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual module resolver for MCP tool wrappers.
|
|
3
|
+
* Generates and caches TypeScript wrappers, enabling import from
|
|
4
|
+
* ./servers/<name>/<tool>.ts paths.
|
|
5
|
+
*/
|
|
6
|
+
import type { ToolDefinition, ServerManifest } from '@justanothermldude/meta-mcp-core';
|
|
7
|
+
/**
|
|
8
|
+
* Virtual module resolver that maintains a cache of generated TypeScript
|
|
9
|
+
* wrappers for MCP tools, enabling import from ./servers/<name>/<tool>.ts paths.
|
|
10
|
+
*/
|
|
11
|
+
export declare class VirtualModuleResolver {
|
|
12
|
+
/**
|
|
13
|
+
* Map of virtual module path -> generated TypeScript code
|
|
14
|
+
*/
|
|
15
|
+
private modules;
|
|
16
|
+
/**
|
|
17
|
+
* Register a virtual module at the given path
|
|
18
|
+
* @param path - Virtual path (e.g., ./servers/github/create_issue.ts)
|
|
19
|
+
* @param code - Generated TypeScript code
|
|
20
|
+
*/
|
|
21
|
+
registerModule(path: string, code: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a virtual module path to its generated code
|
|
24
|
+
* @param path - Virtual path to resolve
|
|
25
|
+
* @returns Generated TypeScript code or undefined if not found
|
|
26
|
+
*/
|
|
27
|
+
resolve(path: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a virtual module exists at the given path
|
|
30
|
+
* @param path - Virtual path to check
|
|
31
|
+
* @returns True if module exists
|
|
32
|
+
*/
|
|
33
|
+
has(path: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Clear all registered modules
|
|
36
|
+
*/
|
|
37
|
+
clear(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the number of registered modules
|
|
40
|
+
*/
|
|
41
|
+
size(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Get all registered module paths
|
|
44
|
+
*/
|
|
45
|
+
listModules(): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Normalize a path for consistent lookup
|
|
48
|
+
*/
|
|
49
|
+
private normalizePath;
|
|
50
|
+
/**
|
|
51
|
+
* Generate the virtual path for a tool
|
|
52
|
+
* @param serverName - Name of the MCP server
|
|
53
|
+
* @param toolName - Name of the tool
|
|
54
|
+
* @returns Virtual path in format servers/<name>/<tool>.ts
|
|
55
|
+
*/
|
|
56
|
+
static getToolPath(serverName: string, toolName: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generate the virtual path for a server's index module
|
|
59
|
+
* @param serverName - Name of the MCP server
|
|
60
|
+
* @returns Virtual path in format servers/<name>/index.ts
|
|
61
|
+
*/
|
|
62
|
+
static getServerIndexPath(serverName: string): string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Options for generating modules from manifest
|
|
66
|
+
*/
|
|
67
|
+
export interface GenerateFromManifestOptions {
|
|
68
|
+
/**
|
|
69
|
+
* Tool cache to fetch tool definitions from
|
|
70
|
+
* Maps server name to array of tool definitions
|
|
71
|
+
*/
|
|
72
|
+
toolCache: Map<string, ToolDefinition[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Optional custom manifest (uses loadServerManifest() if not provided)
|
|
75
|
+
*/
|
|
76
|
+
manifest?: ServerManifest;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Generate virtual modules from server manifest and tool cache.
|
|
80
|
+
* Creates wrappers for all configured servers and their tools.
|
|
81
|
+
*
|
|
82
|
+
* @param resolver - VirtualModuleResolver to populate
|
|
83
|
+
* @param options - Options including tool cache and optional manifest
|
|
84
|
+
* @returns Promise resolving to number of modules generated
|
|
85
|
+
*/
|
|
86
|
+
export declare function generateFromManifest(resolver: VirtualModuleResolver, options: GenerateFromManifestOptions): Promise<number>;
|
|
87
|
+
/**
|
|
88
|
+
* Create a VirtualModuleResolver and populate it from manifest
|
|
89
|
+
* Convenience function for one-step initialization
|
|
90
|
+
*
|
|
91
|
+
* @param options - Options including tool cache and optional manifest
|
|
92
|
+
* @returns Promise resolving to populated VirtualModuleResolver
|
|
93
|
+
*/
|
|
94
|
+
export declare function createModuleResolver(options: GenerateFromManifestOptions): Promise<VirtualModuleResolver>;
|
|
95
|
+
//# sourceMappingURL=module-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-resolver.d.ts","sourceRoot":"","sources":["../../src/codegen/module-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAWvF;;;GAGG;AACH,qBAAa,qBAAqB;IAChC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAkC;IAEjD;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIhD;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,WAAW,IAAI,MAAM,EAAE;IAIvB;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIhE;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAGtD;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAsBD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAI/G"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual module resolver for MCP tool wrappers.
|
|
3
|
+
* Generates and caches TypeScript wrappers, enabling import from
|
|
4
|
+
* ./servers/<name>/<tool>.ts paths.
|
|
5
|
+
*/
|
|
6
|
+
import { loadServerManifest } from '@justanothermldude/meta-mcp-core';
|
|
7
|
+
import { generateToolWrapper } from './wrapper-generator.js';
|
|
8
|
+
/**
|
|
9
|
+
* Sanitize a tool name to create a valid filename
|
|
10
|
+
*/
|
|
11
|
+
function sanitizeFileName(name) {
|
|
12
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, '_').toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Virtual module resolver that maintains a cache of generated TypeScript
|
|
16
|
+
* wrappers for MCP tools, enabling import from ./servers/<name>/<tool>.ts paths.
|
|
17
|
+
*/
|
|
18
|
+
export class VirtualModuleResolver {
|
|
19
|
+
constructor() {
|
|
20
|
+
/**
|
|
21
|
+
* Map of virtual module path -> generated TypeScript code
|
|
22
|
+
*/
|
|
23
|
+
this.modules = new Map();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Register a virtual module at the given path
|
|
27
|
+
* @param path - Virtual path (e.g., ./servers/github/create_issue.ts)
|
|
28
|
+
* @param code - Generated TypeScript code
|
|
29
|
+
*/
|
|
30
|
+
registerModule(path, code) {
|
|
31
|
+
this.modules.set(this.normalizePath(path), code);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a virtual module path to its generated code
|
|
35
|
+
* @param path - Virtual path to resolve
|
|
36
|
+
* @returns Generated TypeScript code or undefined if not found
|
|
37
|
+
*/
|
|
38
|
+
resolve(path) {
|
|
39
|
+
return this.modules.get(this.normalizePath(path));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if a virtual module exists at the given path
|
|
43
|
+
* @param path - Virtual path to check
|
|
44
|
+
* @returns True if module exists
|
|
45
|
+
*/
|
|
46
|
+
has(path) {
|
|
47
|
+
return this.modules.has(this.normalizePath(path));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Clear all registered modules
|
|
51
|
+
*/
|
|
52
|
+
clear() {
|
|
53
|
+
this.modules.clear();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the number of registered modules
|
|
57
|
+
*/
|
|
58
|
+
size() {
|
|
59
|
+
return this.modules.size;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get all registered module paths
|
|
63
|
+
*/
|
|
64
|
+
listModules() {
|
|
65
|
+
return Array.from(this.modules.keys());
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Normalize a path for consistent lookup
|
|
69
|
+
*/
|
|
70
|
+
normalizePath(path) {
|
|
71
|
+
// Remove leading ./ if present and ensure consistent format
|
|
72
|
+
return path.replace(/^\.\//, '').replace(/\\/g, '/');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Generate the virtual path for a tool
|
|
76
|
+
* @param serverName - Name of the MCP server
|
|
77
|
+
* @param toolName - Name of the tool
|
|
78
|
+
* @returns Virtual path in format servers/<name>/<tool>.ts
|
|
79
|
+
*/
|
|
80
|
+
static getToolPath(serverName, toolName) {
|
|
81
|
+
return `servers/${serverName}/${sanitizeFileName(toolName)}.ts`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Generate the virtual path for a server's index module
|
|
85
|
+
* @param serverName - Name of the MCP server
|
|
86
|
+
* @returns Virtual path in format servers/<name>/index.ts
|
|
87
|
+
*/
|
|
88
|
+
static getServerIndexPath(serverName) {
|
|
89
|
+
return `servers/${serverName}/index.ts`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate virtual modules from server manifest and tool cache.
|
|
94
|
+
* Creates wrappers for all configured servers and their tools.
|
|
95
|
+
*
|
|
96
|
+
* @param resolver - VirtualModuleResolver to populate
|
|
97
|
+
* @param options - Options including tool cache and optional manifest
|
|
98
|
+
* @returns Promise resolving to number of modules generated
|
|
99
|
+
*/
|
|
100
|
+
export async function generateFromManifest(resolver, options) {
|
|
101
|
+
const { toolCache, manifest = loadServerManifest() } = options;
|
|
102
|
+
let moduleCount = 0;
|
|
103
|
+
// Iterate over each server in the manifest
|
|
104
|
+
for (const serverName of Object.keys(manifest.servers)) {
|
|
105
|
+
const tools = toolCache.get(serverName);
|
|
106
|
+
if (!tools || tools.length === 0) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// Generate individual tool modules
|
|
110
|
+
for (const tool of tools) {
|
|
111
|
+
const path = VirtualModuleResolver.getToolPath(serverName, tool.name);
|
|
112
|
+
const code = generateToolWrapper(tool, serverName);
|
|
113
|
+
resolver.registerModule(path, code);
|
|
114
|
+
moduleCount++;
|
|
115
|
+
}
|
|
116
|
+
// Generate server index module that re-exports all tools
|
|
117
|
+
const indexPath = VirtualModuleResolver.getServerIndexPath(serverName);
|
|
118
|
+
const indexCode = generateServerIndexModule(serverName, tools);
|
|
119
|
+
resolver.registerModule(indexPath, indexCode);
|
|
120
|
+
moduleCount++;
|
|
121
|
+
}
|
|
122
|
+
return moduleCount;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Generate an index module that re-exports all tools for a server
|
|
126
|
+
*/
|
|
127
|
+
function generateServerIndexModule(serverName, tools) {
|
|
128
|
+
const lines = [];
|
|
129
|
+
lines.push('/**');
|
|
130
|
+
lines.push(` * Auto-generated index for ${serverName} MCP server tools.`);
|
|
131
|
+
lines.push(' * Re-exports all tool wrappers for convenient imports.');
|
|
132
|
+
lines.push(' */');
|
|
133
|
+
lines.push('');
|
|
134
|
+
for (const tool of tools) {
|
|
135
|
+
const fileName = sanitizeFileName(tool.name);
|
|
136
|
+
lines.push(`export * from './${fileName}.js';`);
|
|
137
|
+
}
|
|
138
|
+
return lines.join('\n');
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Create a VirtualModuleResolver and populate it from manifest
|
|
142
|
+
* Convenience function for one-step initialization
|
|
143
|
+
*
|
|
144
|
+
* @param options - Options including tool cache and optional manifest
|
|
145
|
+
* @returns Promise resolving to populated VirtualModuleResolver
|
|
146
|
+
*/
|
|
147
|
+
export async function createModuleResolver(options) {
|
|
148
|
+
const resolver = new VirtualModuleResolver();
|
|
149
|
+
await generateFromManifest(resolver, options);
|
|
150
|
+
return resolver;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=module-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-resolver.js","sourceRoot":"","sources":["../../src/codegen/module-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAAlC;QACE;;WAEG;QACK,YAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IA4EnD,CAAC;IA1EC;;;;OAIG;IACH,cAAc,CAAC,IAAY,EAAE,IAAY;QACvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IA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