@llamaindex/llama-cloud-mcp 0.14.1

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.
Files changed (94) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +101 -0
  3. package/code-tool-types.d.mts +13 -0
  4. package/code-tool-types.d.mts.map +1 -0
  5. package/code-tool-types.d.ts +13 -0
  6. package/code-tool-types.d.ts.map +1 -0
  7. package/code-tool-types.js +4 -0
  8. package/code-tool-types.js.map +1 -0
  9. package/code-tool-types.mjs +3 -0
  10. package/code-tool-types.mjs.map +1 -0
  11. package/code-tool.d.mts +12 -0
  12. package/code-tool.d.mts.map +1 -0
  13. package/code-tool.d.ts +12 -0
  14. package/code-tool.d.ts.map +1 -0
  15. package/code-tool.js +85 -0
  16. package/code-tool.js.map +1 -0
  17. package/code-tool.mjs +82 -0
  18. package/code-tool.mjs.map +1 -0
  19. package/docs-search-tool.d.mts +50 -0
  20. package/docs-search-tool.d.mts.map +1 -0
  21. package/docs-search-tool.d.ts +50 -0
  22. package/docs-search-tool.d.ts.map +1 -0
  23. package/docs-search-tool.js +51 -0
  24. package/docs-search-tool.js.map +1 -0
  25. package/docs-search-tool.mjs +47 -0
  26. package/docs-search-tool.mjs.map +1 -0
  27. package/headers.d.mts +4 -0
  28. package/headers.d.mts.map +1 -0
  29. package/headers.d.ts +4 -0
  30. package/headers.d.ts.map +1 -0
  31. package/headers.js +22 -0
  32. package/headers.js.map +1 -0
  33. package/headers.mjs +18 -0
  34. package/headers.mjs.map +1 -0
  35. package/http.d.mts +9 -0
  36. package/http.d.mts.map +1 -0
  37. package/http.d.ts +9 -0
  38. package/http.d.ts.map +1 -0
  39. package/http.js +91 -0
  40. package/http.js.map +1 -0
  41. package/http.mjs +83 -0
  42. package/http.mjs.map +1 -0
  43. package/index.d.mts +3 -0
  44. package/index.d.mts.map +1 -0
  45. package/index.d.ts +3 -0
  46. package/index.d.ts.map +1 -0
  47. package/index.js +55 -0
  48. package/index.js.map +1 -0
  49. package/index.mjs +53 -0
  50. package/index.mjs.map +1 -0
  51. package/options.d.mts +11 -0
  52. package/options.d.mts.map +1 -0
  53. package/options.d.ts +11 -0
  54. package/options.d.ts.map +1 -0
  55. package/options.js +72 -0
  56. package/options.js.map +1 -0
  57. package/options.mjs +65 -0
  58. package/options.mjs.map +1 -0
  59. package/package.json +162 -0
  60. package/server.d.mts +30 -0
  61. package/server.d.mts.map +1 -0
  62. package/server.d.ts +30 -0
  63. package/server.d.ts.map +1 -0
  64. package/server.js +121 -0
  65. package/server.js.map +1 -0
  66. package/server.mjs +109 -0
  67. package/server.mjs.map +1 -0
  68. package/src/code-tool-types.ts +15 -0
  69. package/src/code-tool.ts +96 -0
  70. package/src/docs-search-tool.ts +59 -0
  71. package/src/headers.ts +25 -0
  72. package/src/http.ts +109 -0
  73. package/src/index.ts +61 -0
  74. package/src/options.ts +92 -0
  75. package/src/server.ts +147 -0
  76. package/src/stdio.ts +12 -0
  77. package/src/tsconfig.json +11 -0
  78. package/src/types.ts +115 -0
  79. package/stdio.d.mts +2 -0
  80. package/stdio.d.mts.map +1 -0
  81. package/stdio.d.ts +2 -0
  82. package/stdio.d.ts.map +1 -0
  83. package/stdio.js +14 -0
  84. package/stdio.js.map +1 -0
  85. package/stdio.mjs +10 -0
  86. package/stdio.mjs.map +1 -0
  87. package/types.d.mts +52 -0
  88. package/types.d.mts.map +1 -0
  89. package/types.d.ts +52 -0
  90. package/types.d.ts.map +1 -0
  91. package/types.js +58 -0
  92. package/types.js.map +1 -0
  93. package/types.mjs +53 -0
  94. package/types.mjs.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 llama-cloud
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Llama Cloud TypeScript MCP Server
2
+
3
+ It is generated with [Stainless](https://www.stainless.com/).
4
+
5
+ ## Installation
6
+
7
+ ### Direct invocation
8
+
9
+ You can run the MCP Server directly via `npx`:
10
+
11
+ ```sh
12
+ export LLAMA_CLOUD_API_KEY="My API Key"
13
+ npx -y @llamaindex/llama-cloud-mcp@latest
14
+ ```
15
+
16
+ ### Via MCP Client
17
+
18
+ There is a partial list of existing clients at [modelcontextprotocol.io](https://modelcontextprotocol.io/clients). If you already
19
+ have a client, consult their documentation to install the MCP server.
20
+
21
+ For clients with a configuration JSON, it might look something like this:
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "llamaindex_llama_cloud_api": {
27
+ "command": "npx",
28
+ "args": ["-y", "@llamaindex/llama-cloud-mcp"],
29
+ "env": {
30
+ "LLAMA_CLOUD_API_KEY": "My API Key"
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ ### Cursor
38
+
39
+ If you use Cursor, you can install the MCP server by using the button below. You will need to set your environment variables
40
+ in Cursor's `mcp.json`, which can be found in Cursor Settings > Tools & MCP > New MCP Server.
41
+
42
+ [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40llamaindex%2Fllama-cloud-mcp&config=eyJuYW1lIjoiQGxsYW1haW5kZXgvbGxhbWEtY2xvdWQtbWNwIiwidHJhbnNwb3J0Ijoic3NlIiwidXJsIjoiaHR0cHM6Ly9sbGFtYWNsb3VkLXByb2Quc3RsbWNwLmNvbS9zc2UiLCJlbnYiOnsiTExBTUFfQ0xPVURfQVBJX0tFWSI6IlNldCB5b3VyIExMQU1BX0NMT1VEX0FQSV9LRVkgaGVyZS4ifX0)
43
+
44
+ ### VS Code
45
+
46
+ If you use MCP, you can install the MCP server by clicking the link below. You will need to set your environment variables
47
+ in VS Code's `mcp.json`, which can be found via Command Palette > MCP: Open User Configuration.
48
+
49
+ [Open VS Code](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40llamaindex%2Fllama-cloud-mcp%22%2C%22type%22%3A%22sse%22%2C%22url%22%3A%22https%3A%2F%2Fllamacloud-prod.stlmcp.com%2Fsse%22%2C%22env%22%3A%7B%22LLAMA_CLOUD_API_KEY%22%3A%22Set%20your%20LLAMA_CLOUD_API_KEY%20here.%22%7D%7D)
50
+
51
+ ### Claude Code
52
+
53
+ If you use Claude Code, you can install the MCP server by running the command below in your terminal. You will need to set your
54
+ environment variables in Claude Code's `.claude.json`, which can be found in your home directory.
55
+
56
+ ```
57
+ claude mcp add llamaindex_llama_cloud_mcp_api --env LLAMA_CLOUD_API_KEY="Your LLAMA_CLOUD_API_KEY here." --transport sse https://llamacloud-prod.stlmcp.com/sse
58
+ ```
59
+
60
+ ## Code Mode
61
+
62
+ This MCP server is built on the "Code Mode" tool scheme. In this MCP Server,
63
+ your agent will write code against the TypeScript SDK, which will then be executed in an
64
+ isolated sandbox. To accomplish this, the server will expose two tools to your agent:
65
+
66
+ - The first tool is a docs search tool, which can be used to generically query for
67
+ documentation about your API/SDK.
68
+
69
+ - The second tool is a code tool, where the agent can write code against the TypeScript SDK.
70
+ The code will be executed in a sandbox environment without web or filesystem access. Then,
71
+ anything the code returns or prints will be returned to the agent as the result of the
72
+ tool call.
73
+
74
+ Using this scheme, agents are capable of performing very complex tasks deterministically
75
+ and repeatably.
76
+
77
+ ## Running remotely
78
+
79
+ Launching the client with `--transport=http` launches the server as a remote server using Streamable HTTP transport. The `--port` setting can choose the port it will run on, and the `--socket` setting allows it to run on a Unix socket.
80
+
81
+ Authorization can be provided via the `Authorization` header using the Bearer scheme.
82
+
83
+ Additionally, authorization can be provided via the following headers:
84
+ | Header | Equivalent client option | Security scheme |
85
+ | ----------------------- | ------------------------ | --------------- |
86
+ | `x-llama-cloud-api-key` | `apiKey` | HTTPBearer |
87
+
88
+ A configuration JSON for this server might look like this, assuming the server is hosted at `http://localhost:3000`:
89
+
90
+ ```json
91
+ {
92
+ "mcpServers": {
93
+ "llamaindex_llama_cloud_api": {
94
+ "url": "http://localhost:3000",
95
+ "headers": {
96
+ "Authorization": "Bearer <auth value>"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ ```
@@ -0,0 +1,13 @@
1
+ import { ClientOptions } from '@llamaindex/llama-cloud';
2
+ export type WorkerInput = {
3
+ project_name: string;
4
+ code: string;
5
+ client_opts: ClientOptions;
6
+ };
7
+ export type WorkerOutput = {
8
+ is_error: boolean;
9
+ result: unknown | null;
10
+ log_lines: string[];
11
+ err_lines: string[];
12
+ };
13
+ //# sourceMappingURL=code-tool-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.d.mts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,yBAAyB;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { ClientOptions } from '@llamaindex/llama-cloud';
2
+ export type WorkerInput = {
3
+ project_name: string;
4
+ code: string;
5
+ client_opts: ClientOptions;
6
+ };
7
+ export type WorkerOutput = {
8
+ is_error: boolean;
9
+ result: unknown | null;
10
+ log_lines: string[];
11
+ err_lines: string[];
12
+ };
13
+ //# sourceMappingURL=code-tool-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.d.ts","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"OAEO,EAAE,aAAa,EAAE,MAAM,yBAAyB;AAEvD,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=code-tool-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.js","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":";AAAA,sFAAsF"}
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export {};
3
+ //# sourceMappingURL=code-tool-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool-types.mjs","sourceRoot":"","sources":["src/code-tool-types.ts"],"names":[],"mappings":"AAAA,sFAAsF"}
@@ -0,0 +1,12 @@
1
+ import { McpTool } from "./types.mjs";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): McpTool;
12
+ //# sourceMappingURL=code-tool.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.mts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AA6BhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAuDlC"}
package/code-tool.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { McpTool } from "./types.js";
2
+ /**
3
+ * A tool that runs code against a copy of the SDK.
4
+ *
5
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
6
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
7
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
8
+ *
9
+ * @param endpoints - The endpoints to include in the list.
10
+ */
11
+ export declare function codeTool(): McpTool;
12
+ //# sourceMappingURL=code-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.d.ts","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":"OAEO,EAAE,OAAO,EAAgE;AA6BhF;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAuDlC"}
package/code-tool.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.codeTool = codeTool;
5
+ const types_1 = require("./types.js");
6
+ const server_1 = require("./server.js");
7
+ const prompt = `Runs JavaScript code to interact with the Llama Cloud API.
8
+
9
+ You are a skilled programmer writing code to interface with the service.
10
+ Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
11
+ For example:
12
+
13
+ \`\`\`
14
+ async function run(client) {
15
+ const parsing = await client.parsing.create({
16
+ tier: 'agentic',
17
+ version: 'latest',
18
+ file_id: 'abc1234',
19
+ });
20
+
21
+ console.log(parsing.id);
22
+ }
23
+ \`\`\`
24
+
25
+ You will be returned anything that your function returns, plus the results of any console.log statements.
26
+ Do not add try-catch blocks for single API calls. The tool will handle errors for you.
27
+ Do not add comments unless necessary for generating better code.
28
+ Code will run in a container, and cannot interact with the network outside of the given SDK client.
29
+ Variables will not persist between calls, so make sure to return or log any data you might need later.`;
30
+ /**
31
+ * A tool that runs code against a copy of the SDK.
32
+ *
33
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
34
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
35
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
36
+ *
37
+ * @param endpoints - The endpoints to include in the list.
38
+ */
39
+ function codeTool() {
40
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
41
+ const tool = {
42
+ name: 'execute',
43
+ description: prompt,
44
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
45
+ };
46
+ const handler = async (_, args) => {
47
+ const code = args.code;
48
+ // this is not required, but passing a Stainless API key for the matching project_name
49
+ // will allow you to run code-mode queries against non-published versions of your SDK.
50
+ const stainlessAPIKey = (0, server_1.readEnv)('STAINLESS_API_KEY');
51
+ const codeModeEndpoint = (0, server_1.readEnv)('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
52
+ const res = await fetch(codeModeEndpoint, {
53
+ method: 'POST',
54
+ headers: {
55
+ ...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
56
+ 'Content-Type': 'application/json',
57
+ client_envs: JSON.stringify({
58
+ LLAMA_CLOUD_API_KEY: (0, server_1.readEnvOrError)('LLAMA_CLOUD_API_KEY'),
59
+ LLAMA_CLOUD_BASE_URL: (0, server_1.readEnv)('LLAMA_CLOUD_BASE_URL'),
60
+ }),
61
+ },
62
+ body: JSON.stringify({
63
+ project_name: 'llamacloud-prod',
64
+ code,
65
+ client_opts: {},
66
+ }),
67
+ });
68
+ if (!res.ok) {
69
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
70
+ }
71
+ const { is_error, result, log_lines, err_lines } = (await res.json());
72
+ const hasLogs = log_lines.length > 0 || err_lines.length > 0;
73
+ const output = {
74
+ result,
75
+ ...(log_lines.length > 0 && { log_lines }),
76
+ ...(err_lines.length > 0 && { err_lines }),
77
+ };
78
+ if (is_error) {
79
+ return (0, types_1.asErrorResult)(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
80
+ }
81
+ return (0, types_1.asTextContentResult)(output);
82
+ };
83
+ return { metadata, tool, handler };
84
+ }
85
+ //# sourceMappingURL=code-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-tool.js","sourceRoot":"","sources":["src/code-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;AAwCtF,4BAuDC;AA7FD,sCAAgG;AAEhG,wCAAmD;AAGnD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;uGAsBwF,CAAC;AAExG;;;;;;;;GAQG;AACH,SAAgB,QAAQ;IACtB,MAAM,QAAQ,GAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAS;QACjB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC1E,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,E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,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;YAC1C,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;SAC3C,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAA,qBAAa,EAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,IAAA,2BAAmB,EAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
package/code-tool.mjs ADDED
@@ -0,0 +1,82 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { asErrorResult, asTextContentResult } from "./types.mjs";
3
+ import { readEnv, readEnvOrError } from "./server.mjs";
4
+ const prompt = `Runs JavaScript code to interact with the Llama Cloud API.
5
+
6
+ You are a skilled programmer writing code to interface with the service.
7
+ Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
8
+ For example:
9
+
10
+ \`\`\`
11
+ async function run(client) {
12
+ const parsing = await client.parsing.create({
13
+ tier: 'agentic',
14
+ version: 'latest',
15
+ file_id: 'abc1234',
16
+ });
17
+
18
+ console.log(parsing.id);
19
+ }
20
+ \`\`\`
21
+
22
+ You will be returned anything that your function returns, plus the results of any console.log statements.
23
+ Do not add try-catch blocks for single API calls. The tool will handle errors for you.
24
+ Do not add comments unless necessary for generating better code.
25
+ Code will run in a container, and cannot interact with the network outside of the given SDK client.
26
+ Variables will not persist between calls, so make sure to return or log any data you might need later.`;
27
+ /**
28
+ * A tool that runs code against a copy of the SDK.
29
+ *
30
+ * Instead of exposing every endpoint as its own tool, which uses up too many tokens for LLMs to use at once,
31
+ * we expose a single tool that can be used to search for endpoints by name, resource, operation, or tag, and then
32
+ * a generic endpoint that can be used to invoke any endpoint with the provided arguments.
33
+ *
34
+ * @param endpoints - The endpoints to include in the list.
35
+ */
36
+ export function codeTool() {
37
+ const metadata = { resource: 'all', operation: 'write', tags: [] };
38
+ const tool = {
39
+ name: 'execute',
40
+ description: prompt,
41
+ inputSchema: { type: 'object', properties: { code: { type: 'string' } } },
42
+ };
43
+ const handler = async (_, args) => {
44
+ const code = args.code;
45
+ // this is not required, but passing a Stainless API key for the matching project_name
46
+ // will allow you to run code-mode queries against non-published versions of your SDK.
47
+ const stainlessAPIKey = readEnv('STAINLESS_API_KEY');
48
+ const codeModeEndpoint = readEnv('CODE_MODE_ENDPOINT_URL') ?? 'https://api.stainless.com/api/ai/code-tool';
49
+ const res = await fetch(codeModeEndpoint, {
50
+ method: 'POST',
51
+ headers: {
52
+ ...(stainlessAPIKey && { Authorization: stainlessAPIKey }),
53
+ 'Content-Type': 'application/json',
54
+ client_envs: JSON.stringify({
55
+ LLAMA_CLOUD_API_KEY: readEnvOrError('LLAMA_CLOUD_API_KEY'),
56
+ LLAMA_CLOUD_BASE_URL: readEnv('LLAMA_CLOUD_BASE_URL'),
57
+ }),
58
+ },
59
+ body: JSON.stringify({
60
+ project_name: 'llamacloud-prod',
61
+ code,
62
+ client_opts: {},
63
+ }),
64
+ });
65
+ if (!res.ok) {
66
+ throw new Error(`${res.status}: ${res.statusText} error when trying to contact Code Tool server. Details: ${await res.text()}`);
67
+ }
68
+ const { is_error, result, log_lines, err_lines } = (await res.json());
69
+ const hasLogs = log_lines.length > 0 || err_lines.length > 0;
70
+ const output = {
71
+ result,
72
+ ...(log_lines.length > 0 && { log_lines }),
73
+ ...(err_lines.length > 0 && { err_lines }),
74
+ };
75
+ if (is_error) {
76
+ return asErrorResult(typeof result === 'string' && !hasLogs ? result : JSON.stringify(output, null, 2));
77
+ }
78
+ return asTextContentResult(output);
79
+ };
80
+ return { met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contextprotocol/sdk/types.js';
3
+ export declare const metadata: Metadata;
4
+ export declare const tool: Tool;
5
+ export declare const handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
6
+ declare const _default: {
7
+ metadata: Metadata;
8
+ tool: {
9
+ inputSchema: {
10
+ [x: string]: unknown;
11
+ type: "object";
12
+ properties?: {
13
+ [x: string]: object;
14
+ } | undefined;
15
+ required?: string[] | undefined;
16
+ };
17
+ name: string;
18
+ description?: string | undefined;
19
+ outputSchema?: {
20
+ [x: string]: unknown;
21
+ type: "object";
22
+ properties?: {
23
+ [x: string]: object;
24
+ } | undefined;
25
+ required?: string[] | undefined;
26
+ } | undefined;
27
+ annotations?: {
28
+ title?: string | undefined;
29
+ readOnlyHint?: boolean | undefined;
30
+ destructiveHint?: boolean | undefined;
31
+ idempotentHint?: boolean | undefined;
32
+ openWorldHint?: boolean | undefined;
33
+ } | undefined;
34
+ execution?: {
35
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
36
+ } | undefined;
37
+ _meta?: {
38
+ [x: string]: unknown;
39
+ } | undefined;
40
+ icons?: {
41
+ src: string;
42
+ mimeType?: string | undefined;
43
+ sizes?: string[] | undefined;
44
+ }[] | undefined;
45
+ title?: string | undefined;
46
+ };
47
+ handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
48
+ };
49
+ export default _default;
50
+ //# sourceMappingURL=docs-search-tool.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.d.mts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,8CAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}
@@ -0,0 +1,50 @@
1
+ import { Metadata } from "./types.js";
2
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
3
+ export declare const metadata: Metadata;
4
+ export declare const tool: Tool;
5
+ export declare const handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
6
+ declare const _default: {
7
+ metadata: Metadata;
8
+ tool: {
9
+ inputSchema: {
10
+ [x: string]: unknown;
11
+ type: "object";
12
+ properties?: {
13
+ [x: string]: object;
14
+ } | undefined;
15
+ required?: string[] | undefined;
16
+ };
17
+ name: string;
18
+ description?: string | undefined;
19
+ outputSchema?: {
20
+ [x: string]: unknown;
21
+ type: "object";
22
+ properties?: {
23
+ [x: string]: object;
24
+ } | undefined;
25
+ required?: string[] | undefined;
26
+ } | undefined;
27
+ annotations?: {
28
+ title?: string | undefined;
29
+ readOnlyHint?: boolean | undefined;
30
+ destructiveHint?: boolean | undefined;
31
+ idempotentHint?: boolean | undefined;
32
+ openWorldHint?: boolean | undefined;
33
+ } | undefined;
34
+ execution?: {
35
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
36
+ } | undefined;
37
+ _meta?: {
38
+ [x: string]: unknown;
39
+ } | undefined;
40
+ icons?: {
41
+ src: string;
42
+ mimeType?: string | undefined;
43
+ sizes?: string[] | undefined;
44
+ }[] | undefined;
45
+ title?: string | undefined;
46
+ };
47
+ handler: (_: unknown, args: Record<string, unknown> | undefined) => Promise<import("./types").ToolCallResult>;
48
+ };
49
+ export default _default;
50
+ //# sourceMappingURL=docs-search-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.d.ts","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"OAEO,EAAE,QAAQ,EAAuB;OAEjC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,eAAO,MAAM,QAAQ,EAAE,QAKtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,IA0BlB,CAAC;AAKF,eAAO,MAAM,OAAO,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,8CAYlF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAZ+B,OAAO,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;;AAcnF,wBAA2C"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.handler = exports.tool = exports.metadata = void 0;
5
+ const types_1 = require("./types.js");
6
+ exports.metadata = {
7
+ resource: 'all',
8
+ operation: 'read',
9
+ tags: [],
10
+ httpMethod: 'get',
11
+ };
12
+ exports.tool = {
13
+ name: 'search_docs',
14
+ description: 'Search for documentation for how to use the client to interact with the API.',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ query: {
19
+ type: 'string',
20
+ description: 'The query to search for.',
21
+ },
22
+ language: {
23
+ type: 'string',
24
+ description: 'The language for the SDK to search for.',
25
+ enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
26
+ },
27
+ detail: {
28
+ type: 'string',
29
+ description: 'The amount of detail to return.',
30
+ enum: ['default', 'verbose'],
31
+ },
32
+ },
33
+ required: ['query', 'language'],
34
+ },
35
+ annotations: {
36
+ readOnlyHint: true,
37
+ },
38
+ };
39
+ const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/llamacloud-prod/docs/search';
40
+ const handler = async (_, args) => {
41
+ const body = args;
42
+ const query = new URLSearchParams(body).toString();
43
+ const result = await fetch(`${docsSearchURL}?${query}`);
44
+ if (!result.ok) {
45
+ throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
46
+ }
47
+ return (0, types_1.asTextContentResult)(await result.json());
48
+ };
49
+ exports.handler = handler;
50
+ exports.default = { metadata: exports.metadata, tool: exports.tool, handler: exports.handler };
51
+ //# sourceMappingURL=docs-search-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.js","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,sCAAwD;AAI3C,QAAA,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,KAAK;CAClB,CAAC;AAEW,QAAA,IAAI,GAAS;IACxB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,8EAA8E;IAC3F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;gBACtD,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;aAClG;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;gBAC9C,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;aAC7B;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KAChC;IACD,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;KACnB;CACF,CAAC;AAEF,MAAM,aAAa,GACjB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,oEAAoE,CAAC;AAElG,MAAM,OAAO,GAAG,KAAK,EAAE,CAAU,EAAE,IAAyC,EAAE,EAAE;IACrF,MAAM,IAAI,GAAG,IAAW,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,2BAAmB,EAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAZW,QAAA,OAAO,WAYlB;AAEF,kBAAe,EAAE,QAAQ,EAAR,gBAAQ,EAAE,IAAI,EAAJ,YAAI,EAAE,OAAO,EAAP,eAAO,EAAE,CAAC"}
@@ -0,0 +1,47 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { asTextContentResult } from "./types.mjs";
3
+ export const metadata = {
4
+ resource: 'all',
5
+ operation: 'read',
6
+ tags: [],
7
+ httpMethod: 'get',
8
+ };
9
+ export const tool = {
10
+ name: 'search_docs',
11
+ description: 'Search for documentation for how to use the client to interact with the API.',
12
+ inputSchema: {
13
+ type: 'object',
14
+ properties: {
15
+ query: {
16
+ type: 'string',
17
+ description: 'The query to search for.',
18
+ },
19
+ language: {
20
+ type: 'string',
21
+ description: 'The language for the SDK to search for.',
22
+ enum: ['http', 'python', 'go', 'typescript', 'javascript', 'terraform', 'ruby', 'java', 'kotlin'],
23
+ },
24
+ detail: {
25
+ type: 'string',
26
+ description: 'The amount of detail to return.',
27
+ enum: ['default', 'verbose'],
28
+ },
29
+ },
30
+ required: ['query', 'language'],
31
+ },
32
+ annotations: {
33
+ readOnlyHint: true,
34
+ },
35
+ };
36
+ const docsSearchURL = process.env['DOCS_SEARCH_URL'] || 'https://api.stainless.com/api/projects/llamacloud-prod/docs/search';
37
+ export const handler = async (_, args) => {
38
+ const body = args;
39
+ const query = new URLSearchParams(body).toString();
40
+ const result = await fetch(`${docsSearchURL}?${query}`);
41
+ if (!result.ok) {
42
+ throw new Error(`${result.status}: ${result.statusText} when using doc search tool. Details: ${await result.text()}`);
43
+ }
44
+ return asTextContentResult(await result.json());
45
+ };
46
+ export default { metadata, tool, handler };
47
+ //# sourceMappingURL=docs-search-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-search-tool.mjs","sourceRoot":"","sources":["src/docs-search-tool.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAY,mBAAmB,EAAE;AAIxC,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAS;IACxB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,8EAA8E;IAC3F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yCAAyC;gBACtD,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;aAClG;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;gBAC9C,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;aAC7B;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KAChC;IACD,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;KACnB;CACF,CAAC;AAEF,MAAM,aAAa,GACjB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,oEAAoE,CAAC;AAEzG,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,CAAU,EAAE,IAAyC,EAAE,EAAE;IACrF,MAAM,IAAI,GAAG,IAAW,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,IAAI,KAAK,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,yCAAyC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,mBAAmB,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC"}
package/headers.d.mts ADDED
@@ -0,0 +1,4 @@
1
+ import { IncomingMessage } from 'node:http';
2
+ import { ClientOptions } from '@llamaindex/llama-cloud';
3
+ export declare const parseAuthHeaders: (req: IncomingMessage) => Partial<ClientOptions>;
4
+ //# sourceMappingURL=headers.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.d.mts","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,yBAAyB;AAEvD,eAAO,MAAM,gBAAgB,GAAI,KAAK,eAAe,KAAG,OAAO,CAAC,aAAa,CAmB5E,CAAC"}
package/headers.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { IncomingMessage } from 'node:http';
2
+ import { ClientOptions } from '@llamaindex/llama-cloud';
3
+ export declare const parseAuthHeaders: (req: IncomingMessage) => Partial<ClientOptions>;
4
+ //# sourceMappingURL=headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":"OAEO,EAAE,eAAe,EAAE,MAAM,WAAW;OACpC,EAAE,aAAa,EAAE,MAAM,yBAAyB;AAEvD,eAAO,MAAM,gBAAgB,GAAI,KAAK,eAAe,KAAG,OAAO,CAAC,aAAa,CAmB5E,CAAC"}
package/headers.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseAuthHeaders = void 0;
5
+ const parseAuthHeaders = (req) => {
6
+ if (req.headers.authorization) {
7
+ const scheme = req.headers.authorization.split(' ')[0];
8
+ const value = req.headers.authorization.slice(scheme.length + 1);
9
+ switch (scheme) {
10
+ case 'Bearer':
11
+ return { apiKey: req.headers.authorization.slice('Bearer '.length) };
12
+ default:
13
+ throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
14
+ }
15
+ }
16
+ const apiKey = Array.isArray(req.headers['x-llama-cloud-api-key']) ?
17
+ req.headers['x-llama-cloud-api-key'][0]
18
+ : req.headers['x-llama-cloud-api-key'];
19
+ return { apiKey };
20
+ };
21
+ exports.parseAuthHeaders = parseAuthHeaders;
22
+ //# sourceMappingURL=headers.js.map