@llamaindex/llama-cloud-mcp 2.0.0 → 2.2.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/code-tool-worker.d.mts.map +1 -1
- package/code-tool-worker.d.ts.map +1 -1
- package/code-tool-worker.js +48 -2
- package/code-tool-worker.js.map +1 -1
- package/code-tool-worker.mjs +15 -2
- package/code-tool-worker.mjs.map +1 -1
- package/http.d.mts.map +1 -1
- package/http.d.ts.map +1 -1
- package/http.js +10 -3
- package/http.js.map +1 -1
- package/http.mjs +10 -3
- package/http.mjs.map +1 -1
- package/local-docs-search.d.mts.map +1 -1
- package/local-docs-search.d.ts.map +1 -1
- package/local-docs-search.js +182 -37
- package/local-docs-search.js.map +1 -1
- package/local-docs-search.mjs +182 -37
- package/local-docs-search.mjs.map +1 -1
- package/methods.d.mts.map +1 -1
- package/methods.d.ts.map +1 -1
- package/methods.js +30 -0
- package/methods.js.map +1 -1
- package/methods.mjs +30 -0
- package/methods.mjs.map +1 -1
- package/package.json +2 -2
- package/server.js +1 -1
- package/server.mjs +1 -1
- package/src/code-tool-worker.ts +15 -2
- package/src/http.ts +13 -4
- package/src/local-docs-search.ts +207 -37
- package/src/methods.ts +30 -0
- package/src/server.ts +1 -1
package/src/code-tool-worker.ts
CHANGED
|
@@ -7,6 +7,10 @@ import ts from 'typescript';
|
|
|
7
7
|
import { WorkerOutput } from './code-tool-types';
|
|
8
8
|
import { LlamaCloud, ClientOptions } from '@llamaindex/llama-cloud';
|
|
9
9
|
|
|
10
|
+
async function tseval(code: string) {
|
|
11
|
+
return import('data:application/typescript;charset=utf-8;base64,' + Buffer.from(code).toString('base64'));
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
function getRunFunctionSource(code: string): {
|
|
11
15
|
type: 'declaration' | 'expression';
|
|
12
16
|
client: string | undefined;
|
|
@@ -125,6 +129,11 @@ const fuse = new Fuse(
|
|
|
125
129
|
'client.classify.create',
|
|
126
130
|
'client.classify.get',
|
|
127
131
|
'client.classify.list',
|
|
132
|
+
'client.configurations.create',
|
|
133
|
+
'client.configurations.delete',
|
|
134
|
+
'client.configurations.list',
|
|
135
|
+
'client.configurations.retrieve',
|
|
136
|
+
'client.configurations.update',
|
|
128
137
|
'client.projects.get',
|
|
129
138
|
'client.projects.list',
|
|
130
139
|
'client.dataSinks.create',
|
|
@@ -349,7 +358,9 @@ const fetch = async (req: Request): Promise<Response> => {
|
|
|
349
358
|
|
|
350
359
|
const log_lines: string[] = [];
|
|
351
360
|
const err_lines: string[] = [];
|
|
352
|
-
const
|
|
361
|
+
const originalConsole = globalThis.console;
|
|
362
|
+
globalThis.console = {
|
|
363
|
+
...originalConsole,
|
|
353
364
|
log: (...args: unknown[]) => {
|
|
354
365
|
log_lines.push(util.format(...args));
|
|
355
366
|
},
|
|
@@ -359,7 +370,7 @@ const fetch = async (req: Request): Promise<Response> => {
|
|
|
359
370
|
};
|
|
360
371
|
try {
|
|
361
372
|
let run_ = async (client: any) => {};
|
|
362
|
-
|
|
373
|
+
run_ = (await tseval(`${code}\nexport default run;`)).default;
|
|
363
374
|
const result = await run_(makeSdkProxy(client, { path: ['client'] }));
|
|
364
375
|
return Response.json({
|
|
365
376
|
is_error: false,
|
|
@@ -377,6 +388,8 @@ const fetch = async (req: Request): Promise<Response> => {
|
|
|
377
388
|
} satisfies WorkerOutput,
|
|
378
389
|
{ status: 400, statusText: 'Code execution error' },
|
|
379
390
|
);
|
|
391
|
+
} finally {
|
|
392
|
+
globalThis.console = originalConsole;
|
|
380
393
|
}
|
|
381
394
|
};
|
|
382
395
|
|
package/src/http.ts
CHANGED
|
@@ -69,6 +69,11 @@ const newServer = async ({
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
const mcpClientInfo =
|
|
73
|
+
typeof req.body?.params?.clientInfo?.name === 'string' ?
|
|
74
|
+
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
|
|
75
|
+
: undefined;
|
|
76
|
+
|
|
72
77
|
await initMcpServer({
|
|
73
78
|
server: server,
|
|
74
79
|
mcpOptions: effectiveMcpOptions,
|
|
@@ -79,12 +84,13 @@ const newServer = async ({
|
|
|
79
84
|
stainlessApiKey: stainlessApiKey,
|
|
80
85
|
upstreamClientEnvs,
|
|
81
86
|
mcpSessionId: (req as any).mcpSessionId,
|
|
82
|
-
mcpClientInfo
|
|
83
|
-
typeof req.body?.params?.clientInfo?.name === 'string' ?
|
|
84
|
-
{ name: req.body.params.clientInfo.name, version: String(req.body.params.clientInfo.version ?? '') }
|
|
85
|
-
: undefined,
|
|
87
|
+
mcpClientInfo,
|
|
86
88
|
});
|
|
87
89
|
|
|
90
|
+
if (mcpClientInfo) {
|
|
91
|
+
getLogger().info({ mcpSessionId: (req as any).mcpSessionId, mcpClientInfo }, 'MCP client connected');
|
|
92
|
+
}
|
|
93
|
+
|
|
88
94
|
return server;
|
|
89
95
|
};
|
|
90
96
|
|
|
@@ -154,6 +160,9 @@ export const streamableHTTPApp = ({
|
|
|
154
160
|
app.use(
|
|
155
161
|
pinoHttp({
|
|
156
162
|
logger: getLogger(),
|
|
163
|
+
customProps: (req) => ({
|
|
164
|
+
mcpSessionId: (req as any).mcpSessionId,
|
|
165
|
+
}),
|
|
157
166
|
customLogLevel: (req, res) => {
|
|
158
167
|
if (res.statusCode >= 500) {
|
|
159
168
|
return 'error';
|