@llamaindex/llama-cloud-mcp 1.4.0 → 1.6.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/auth.d.mts +6 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +6 -0
- package/auth.d.ts.map +1 -0
- package/{headers.mjs → auth.js} +18 -2
- package/auth.js.map +1 -0
- package/{headers.js → auth.mjs} +13 -6
- package/auth.mjs.map +1 -0
- package/code-tool.d.mts +4 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +4 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +22 -10
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +20 -8
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +9 -3
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +9 -3
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +6 -2
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +6 -2
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts +2 -2
- package/http.d.mts.map +1 -1
- package/http.d.ts +2 -2
- package/http.d.ts.map +1 -1
- package/http.js +14 -8
- package/http.js.map +1 -1
- package/http.mjs +14 -8
- package/http.mjs.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +791 -0
- package/methods.js.map +1 -0
- package/methods.mjs +787 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +4 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +4 -0
- package/options.d.ts.map +1 -1
- package/options.js +25 -0
- package/options.js.map +1 -1
- package/options.mjs +25 -0
- package/options.mjs.map +1 -1
- package/package.json +32 -12
- package/server.d.mts +8 -9
- package/server.d.mts.map +1 -1
- package/server.d.ts +8 -9
- package/server.d.ts.map +1 -1
- package/server.js +30 -42
- package/server.js.map +1 -1
- package/server.mjs +28 -37
- package/server.mjs.map +1 -1
- package/src/{headers.ts → auth.ts} +16 -1
- package/src/code-tool.ts +37 -9
- package/src/docs-search-tool.ts +13 -4
- package/src/http.ts +22 -8
- package/src/index.ts +1 -1
- package/src/methods.ts +812 -0
- package/src/options.ts +34 -0
- package/src/server.ts +38 -47
- package/src/stdio.ts +4 -3
- package/src/types.ts +12 -4
- package/src/util.ts +25 -0
- package/stdio.d.mts +2 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +2 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +3 -3
- package/stdio.js.map +1 -1
- package/stdio.mjs +3 -3
- package/stdio.mjs.map +1 -1
- package/types.d.mts +8 -1
- package/types.d.mts.map +1 -1
- package/types.d.ts +8 -1
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js.map +0 -1
- package/headers.mjs.map +0 -1
package/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,SAAS,EAAE,MAAM,yCAAyC;OAC5D,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC;OAEpC,UAAU,MAAM,yBAAyB;OACzC,EAAE,QAAQ,EAAE;OACZ,cAAc;
|
|
1
|
+
{"version":3,"file":"server.mjs","sourceRoot":"","sources":["src/server.ts"],"names":[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AG,MAAM,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACjD,MAAM;QACV,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAAoB;IAC9C,MAAM,aAAa,GAAG;QACpB,QAAQ,CAAC;YACP,cAAc,EAAE,yBAAyB,CAAC,OAAO,CAAC;SACnD,CAAC;KACH,CAAC;IACF,IAAI,OAAO,EAAE,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACtC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,UAAU,EACV,IAAI,GAKL;IACC,OAAO,MAAM,OAAO,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { IncomingMessage } from 'node:http';
|
|
4
4
|
import { ClientOptions } from '@llamaindex/llama-cloud';
|
|
5
|
+
import { McpOptions } from './options';
|
|
5
6
|
|
|
6
|
-
export const
|
|
7
|
+
export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial<ClientOptions> => {
|
|
7
8
|
if (req.headers.authorization) {
|
|
8
9
|
const scheme = req.headers.authorization.split(' ')[0]!;
|
|
9
10
|
const value = req.headers.authorization.slice(scheme.length + 1);
|
|
@@ -25,3 +26,17 @@ export const parseAuthHeaders = (req: IncomingMessage, required?: boolean): Part
|
|
|
25
26
|
: req.headers['x-llama-cloud-api-key'];
|
|
26
27
|
return { apiKey };
|
|
27
28
|
};
|
|
29
|
+
|
|
30
|
+
export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => {
|
|
31
|
+
// Try to get the key from the x-stainless-api-key header
|
|
32
|
+
const headerKey =
|
|
33
|
+
Array.isArray(req.headers['x-stainless-api-key']) ?
|
|
34
|
+
req.headers['x-stainless-api-key'][0]
|
|
35
|
+
: req.headers['x-stainless-api-key'];
|
|
36
|
+
if (headerKey && typeof headerKey === 'string') {
|
|
37
|
+
return headerKey;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Fall back to value set in the mcpOptions (e.g. from environment variable), if provided
|
|
41
|
+
return mcpOptions.stainlessApiKey;
|
|
42
|
+
};
|
package/src/code-tool.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
McpRequestContext,
|
|
5
|
+
McpTool,
|
|
6
|
+
Metadata,
|
|
7
|
+
ToolCallResult,
|
|
8
|
+
asErrorResult,
|
|
9
|
+
asTextContentResult,
|
|
10
|
+
} from './types';
|
|
4
11
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { readEnv, requireValue } from './
|
|
12
|
+
import { readEnv, requireValue } from './util';
|
|
6
13
|
import { WorkerInput, WorkerOutput } from './code-tool-types';
|
|
7
|
-
import {
|
|
14
|
+
import { SdkMethod } from './methods';
|
|
8
15
|
|
|
9
16
|
const prompt = `Runs JavaScript code to interact with the Llama Cloud API.
|
|
10
17
|
|
|
@@ -39,7 +46,7 @@ Variables will not persist between calls, so make sure to return or log any data
|
|
|
39
46
|
*
|
|
40
47
|
* @param endpoints - The endpoints to include in the list.
|
|
41
48
|
*/
|
|
42
|
-
export function codeTool(): McpTool {
|
|
49
|
+
export function codeTool({ blockedMethods }: { blockedMethods: SdkMethod[] | undefined }): McpTool {
|
|
43
50
|
const metadata: Metadata = { resource: 'all', operation: 'write', tags: [] };
|
|
44
51
|
const tool: Tool = {
|
|
45
52
|
name: 'execute',
|
|
@@ -59,20 +66,41 @@ export function codeTool(): McpTool {
|
|
|
59
66
|
required: ['code'],
|
|
60
67
|
},
|
|
61
68
|
};
|
|
62
|
-
const handler = async (
|
|
69
|
+
const handler = async ({
|
|
70
|
+
reqContext,
|
|
71
|
+
args,
|
|
72
|
+
}: {
|
|
73
|
+
reqContext: McpRequestContext;
|
|
74
|
+
args: any;
|
|
75
|
+
}): Promise<ToolCallResult> => {
|
|
63
76
|
const code = args.code as string;
|
|
64
77
|
const intent = args.intent as string | undefined;
|
|
78
|
+
const client = reqContext.client;
|
|
79
|
+
|
|
80
|
+
// Do very basic blocking of code that includes forbidden method names.
|
|
81
|
+
//
|
|
82
|
+
// WARNING: This is not secure against obfuscation and other evasion methods. If
|
|
83
|
+
// stronger security blocks are required, then these should be enforced in the downstream
|
|
84
|
+
// API (e.g., by having users call the MCP server with API keys with limited permissions).
|
|
85
|
+
if (blockedMethods) {
|
|
86
|
+
const blockedMatches = blockedMethods.filter((method) => code.includes(method.fullyQualifiedName));
|
|
87
|
+
if (blockedMatches.length > 0) {
|
|
88
|
+
return asErrorResult(
|
|
89
|
+
`The following methods have been blocked by the MCP server and cannot be used in code execution: ${blockedMatches
|
|
90
|
+
.map((m) => m.fullyQualifiedName)
|
|
91
|
+
.join(', ')}`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
65
95
|
|
|
66
|
-
// this is not required, but passing a Stainless API key for the matching project_name
|
|
67
|
-
// will allow you to run code-mode queries against non-published versions of your SDK.
|
|
68
|
-
const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
|
|
69
96
|
const codeModeEndpoint =
|
|
70
97
|
readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
|
|
71
98
|
|
|
99
|
+
// Setting a Stainless API key authenticates requests to the code tool endpoint.
|
|
72
100
|
const res = await fetch(codeModeEndpoint, {
|
|
73
101
|
method: 'POST',
|
|
74
102
|
headers: {
|
|
75
|
-
...(
|
|
103
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
76
104
|
'Content-Type': 'application/json',
|
|
77
105
|
client_envs: JSON.stringify({
|
|
78
106
|
LLAMA_CLOUD_API_KEY: requireValue(
|
package/src/docs-search-tool.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { Metadata, asTextContentResult } from './types';
|
|
4
|
-
|
|
3
|
+
import { Metadata, McpRequestContext, asTextContentResult } from './types';
|
|
5
4
|
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
6
5
|
|
|
7
6
|
export const metadata: Metadata = {
|
|
@@ -42,10 +41,20 @@ export const tool: Tool = {
|
|
|
42
41
|
const docsSearchURL =
|
|
43
42
|
process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/llamacloud-prod/docs/search';
|
|
44
43
|
|
|
45
|
-
export const handler = async (
|
|
44
|
+
export const handler = async ({
|
|
45
|
+
reqContext,
|
|
46
|
+
args,
|
|
47
|
+
}: {
|
|
48
|
+
reqContext: McpRequestContext;
|
|
49
|
+
args: Record<string, unknown> | undefined;
|
|
50
|
+
}) => {
|
|
46
51
|
const body = args as any;
|
|
47
52
|
const query = new URLSearchParams(body).toString();
|
|
48
|
-
const result = await fetch(`${docsSearchURL}?${query}
|
|
53
|
+
const result = await fetch(`${docsSearchURL}?${query}`, {
|
|
54
|
+
headers: {
|
|
55
|
+
...(reqContext.stainlessApiKey && { Authorization: reqContext.stainlessApiKey }),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
49
58
|
|
|
50
59
|
if (!result.ok) {
|
|
51
60
|
throw new Error(
|
package/src/http.ts
CHANGED
|
@@ -2,32 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
4
4
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
+
import { ClientOptions } from '@llamaindex/llama-cloud';
|
|
5
6
|
import express from 'express';
|
|
6
7
|
import morgan from 'morgan';
|
|
7
8
|
import morganBody from 'morgan-body';
|
|
9
|
+
import { getStainlessApiKey, parseClientAuthHeaders } from './auth';
|
|
8
10
|
import { McpOptions } from './options';
|
|
9
|
-
import {
|
|
10
|
-
import { parseAuthHeaders } from './headers';
|
|
11
|
+
import { initMcpServer, newMcpServer } from './server';
|
|
11
12
|
|
|
12
13
|
const newServer = async ({
|
|
13
14
|
clientOptions,
|
|
15
|
+
mcpOptions,
|
|
14
16
|
req,
|
|
15
17
|
res,
|
|
16
18
|
}: {
|
|
17
19
|
clientOptions: ClientOptions;
|
|
20
|
+
mcpOptions: McpOptions;
|
|
18
21
|
req: express.Request;
|
|
19
22
|
res: express.Response;
|
|
20
23
|
}): Promise<McpServer | null> => {
|
|
21
|
-
const
|
|
24
|
+
const stainlessApiKey = getStainlessApiKey(req, mcpOptions);
|
|
25
|
+
const server = await newMcpServer(stainlessApiKey);
|
|
22
26
|
|
|
23
27
|
try {
|
|
24
|
-
const authOptions =
|
|
28
|
+
const authOptions = parseClientAuthHeaders(req, false);
|
|
29
|
+
|
|
25
30
|
await initMcpServer({
|
|
26
31
|
server: server,
|
|
32
|
+
mcpOptions: mcpOptions,
|
|
27
33
|
clientOptions: {
|
|
28
34
|
...clientOptions,
|
|
29
35
|
...authOptions,
|
|
30
36
|
},
|
|
37
|
+
stainlessApiKey: stainlessApiKey,
|
|
31
38
|
});
|
|
32
39
|
} catch (error) {
|
|
33
40
|
res.status(401).json({
|
|
@@ -98,6 +105,9 @@ export const streamableHTTPApp = ({
|
|
|
98
105
|
app.use(morgan('combined'));
|
|
99
106
|
}
|
|
100
107
|
|
|
108
|
+
app.get('/health', async (req: express.Request, res: express.Response) => {
|
|
109
|
+
res.status(200).send('OK');
|
|
110
|
+
});
|
|
101
111
|
app.get('/', get);
|
|
102
112
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
103
113
|
app.delete('/', del);
|
|
@@ -105,13 +115,17 @@ export const streamableHTTPApp = ({
|
|
|
105
115
|
return app;
|
|
106
116
|
};
|
|
107
117
|
|
|
108
|
-
export const launchStreamableHTTPServer = async (
|
|
118
|
+
export const launchStreamableHTTPServer = async ({
|
|
119
|
+
mcpOptions,
|
|
120
|
+
debug,
|
|
121
|
+
port,
|
|
122
|
+
}: {
|
|
109
123
|
mcpOptions: McpOptions;
|
|
110
124
|
debug: boolean;
|
|
111
125
|
port: number | string | undefined;
|
|
112
126
|
}) => {
|
|
113
|
-
const app = streamableHTTPApp({ mcpOptions
|
|
114
|
-
const server = app.listen(
|
|
127
|
+
const app = streamableHTTPApp({ mcpOptions, debug });
|
|
128
|
+
const server = app.listen(port);
|
|
115
129
|
const address = server.address();
|
|
116
130
|
|
|
117
131
|
if (typeof address === 'string') {
|
|
@@ -119,6 +133,6 @@ export const launchStreamableHTTPServer = async (params: {
|
|
|
119
133
|
} else if (address !== null) {
|
|
120
134
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
121
135
|
} else {
|
|
122
|
-
console.error(`MCP Server running on streamable HTTP on port ${
|
|
136
|
+
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
123
137
|
}
|
|
124
138
|
};
|