@llamaindex/llama-cloud-mcp 1.8.0 → 2.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/code-tool-paths.cjs +4 -2
- package/code-tool-paths.cjs.map +1 -1
- package/code-tool-paths.d.cts +1 -1
- package/code-tool-paths.d.cts.map +1 -1
- package/code-tool-worker.d.mts.map +1 -1
- package/code-tool-worker.d.ts.map +1 -1
- package/code-tool-worker.js +49 -19
- package/code-tool-worker.js.map +1 -1
- package/code-tool-worker.mjs +16 -19
- package/code-tool-worker.mjs.map +1 -1
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +29 -23
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +20 -11
- package/code-tool.mjs.map +1 -1
- package/docs-search-tool.d.mts +2 -0
- package/docs-search-tool.d.mts.map +1 -1
- package/docs-search-tool.d.ts +2 -0
- package/docs-search-tool.d.ts.map +1 -1
- package/docs-search-tool.js +33 -3
- package/docs-search-tool.js.map +1 -1
- package/docs-search-tool.mjs +32 -3
- package/docs-search-tool.mjs.map +1 -1
- package/http.d.mts.map +1 -1
- package/http.d.ts.map +1 -1
- package/http.js +58 -3
- package/http.js.map +1 -1
- package/http.mjs +58 -3
- package/http.mjs.map +1 -1
- package/instructions.d.mts +4 -1
- package/instructions.d.mts.map +1 -1
- package/instructions.d.ts +4 -1
- package/instructions.d.ts.map +1 -1
- package/instructions.js +30 -25
- package/instructions.js.map +1 -1
- package/instructions.mjs +27 -25
- package/instructions.mjs.map +1 -1
- package/local-docs-search.d.mts +28 -0
- package/local-docs-search.d.mts.map +1 -0
- package/local-docs-search.d.ts +28 -0
- package/local-docs-search.d.ts.map +1 -0
- package/local-docs-search.js +3605 -0
- package/local-docs-search.js.map +1 -0
- package/local-docs-search.mjs +3565 -0
- package/local-docs-search.mjs.map +1 -0
- package/methods.d.mts.map +1 -1
- package/methods.d.ts.map +1 -1
- package/methods.js +18 -84
- package/methods.js.map +1 -1
- package/methods.mjs +18 -84
- package/methods.mjs.map +1 -1
- package/options.d.mts +3 -0
- package/options.d.mts.map +1 -1
- package/options.d.ts +3 -0
- package/options.d.ts.map +1 -1
- package/options.js +19 -0
- package/options.js.map +1 -1
- package/options.mjs +19 -0
- package/options.mjs.map +1 -1
- package/package.json +19 -5
- package/server.d.mts +10 -1
- package/server.d.mts.map +1 -1
- package/server.d.ts +10 -1
- package/server.d.ts.map +1 -1
- package/server.js +13 -3
- package/server.js.map +1 -1
- package/server.mjs +13 -3
- package/server.mjs.map +1 -1
- package/src/code-tool-paths.cts +3 -1
- package/src/code-tool-worker.ts +16 -19
- package/src/code-tool.ts +27 -16
- package/src/docs-search-tool.ts +48 -9
- package/src/http.ts +62 -3
- package/src/instructions.ts +34 -26
- package/src/local-docs-search.ts +4220 -0
- package/src/methods.ts +18 -84
- package/src/options.ts +24 -0
- package/src/server.ts +23 -3
- package/src/stdio.ts +4 -1
- package/src/types.ts +3 -0
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +4 -1
- package/stdio.js.map +1 -1
- package/stdio.mjs +4 -1
- package/stdio.mjs.map +1 -1
- package/types.d.mts +6 -0
- package/types.d.mts.map +1 -1
- package/types.d.ts +6 -0
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/types.mjs.map +1 -1
package/instructions.mjs
CHANGED
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import fs from 'fs/promises';
|
|
2
3
|
import { readEnv } from "./util.mjs";
|
|
3
4
|
import { getLogger } from "./logger.mjs";
|
|
4
5
|
const INSTRUCTIONS_CACHE_TTL_MS = 15 * 60 * 1000; // 15 minutes
|
|
5
6
|
const instructionsCache = new Map();
|
|
6
|
-
|
|
7
|
-
const _cacheCleanupInterval = setInterval(() => {
|
|
7
|
+
export async function getInstructions({ stainlessApiKey, customInstructionsPath, }) {
|
|
8
8
|
const now = Date.now();
|
|
9
|
+
const cacheKey = customInstructionsPath ?? stainlessApiKey ?? '';
|
|
10
|
+
const cached = instructionsCache.get(cacheKey);
|
|
11
|
+
if (cached && now - cached.fetchedAt <= INSTRUCTIONS_CACHE_TTL_MS) {
|
|
12
|
+
return cached.fetchedInstructions;
|
|
13
|
+
}
|
|
14
|
+
// Evict stale entries so the cache doesn't grow unboundedly.
|
|
9
15
|
for (const [key, entry] of instructionsCache) {
|
|
10
16
|
if (now - entry.fetchedAt > INSTRUCTIONS_CACHE_TTL_MS) {
|
|
11
17
|
instructionsCache.delete(key);
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export async function getInstructions(stainlessApiKey) {
|
|
18
|
-
const cacheKey = stainlessApiKey ?? '';
|
|
19
|
-
const cached = instructionsCache.get(cacheKey);
|
|
20
|
-
if (cached && Date.now() - cached.fetchedAt <= INSTRUCTIONS_CACHE_TTL_MS) {
|
|
21
|
-
return cached.fetchedInstructions;
|
|
20
|
+
let fetchedInstructions;
|
|
21
|
+
if (customInstructionsPath) {
|
|
22
|
+
fetchedInstructions = await fetchLatestInstructionsFromFile(customInstructionsPath);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
else {
|
|
25
|
+
fetchedInstructions = await fetchLatestInstructionsFromApi(stainlessApiKey);
|
|
26
|
+
}
|
|
27
|
+
instructionsCache.set(cacheKey, { fetchedInstructions, fetchedAt: now });
|
|
25
28
|
return fetchedInstructions;
|
|
26
29
|
}
|
|
27
|
-
async function
|
|
30
|
+
async function fetchLatestInstructionsFromFile(path) {
|
|
31
|
+
try {
|
|
32
|
+
return await fs.readFile(path, 'utf-8');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
getLogger().error({ error, path }, 'Error fetching instructions from file');
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function fetchLatestInstructionsFromApi(stainlessApiKey) {
|
|
28
40
|
// Setting the stainless API key is optional, but may be required
|
|
29
41
|
// to authenticate requests to the Stainless API.
|
|
30
42
|
const response = await fetch(readEnv('CODE_MODE_INSTRUCTIONS_URL') ?? 'https://api.stainless.com/api/ai/instructions/llamacloud-prod', {
|
|
@@ -34,20 +46,10 @@ async function fetchLatestInstructions(stainlessApiKey) {
|
|
|
34
46
|
let instructions;
|
|
35
47
|
if (!response.ok) {
|
|
36
48
|
getLogger().warn('Warning: failed to retrieve MCP server instructions. Proceeding with default instructions...');
|
|
37
|
-
instructions =
|
|
38
|
-
|
|
39
|
-
actions. You can use search_docs tool to learn about how to take action with this server. Then,
|
|
40
|
-
you will write TypeScript code using the execute tool take action. It is CRITICAL that you be
|
|
41
|
-
thoughtful and deliberate when executing code. Always try to entirely solve the problem in code
|
|
42
|
-
block: it can be as long as you need to get the job done!
|
|
43
|
-
`;
|
|
49
|
+
instructions =
|
|
50
|
+
'\n This is the llamacloud-prod MCP server.\n\n Available tools:\n - search_docs: Search SDK documentation to find the right methods and parameters.\n - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.\n\n Workflow:\n - If unsure about the API, call search_docs first.\n - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.\n - If execute returns an error, read the error and fix your code rather than retrying the same approach.\n - Variables do not persist between execute calls. Return or log all data you need.\n - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.\n - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.\n ';
|
|
44
51
|
}
|
|
45
52
|
instructions ??= (await response.json()).instructions;
|
|
46
|
-
instructions = `
|
|
47
|
-
If needed, you can get the current time by executing Date.now().
|
|
48
|
-
|
|
49
|
-
${instructions}
|
|
50
|
-
`;
|
|
51
53
|
return instructions;
|
|
52
54
|
}
|
|
53
55
|
//# sourceMappingURL=instructions.mjs.map
|
package/instructions.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.mjs","sourceRoot":"","sources":["src/instructions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,EAAE;OACX,EAAE,SAAS,EAAE;AAEpB,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAO/D,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkC,CAAC;AAEpE,
|
|
1
|
+
{"version":3,"file":"instructions.mjs","sourceRoot":"","sources":["src/instructions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,MAAM,aAAa;OACrB,EAAE,OAAO,EAAE;OACX,EAAE,SAAS,EAAE;AAEpB,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAO/D,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkC,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,eAAe,EACf,sBAAsB,GAIvB;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,sBAAsB,IAAI,eAAe,IAAI,EAAE,CAAC;IACjE,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE/C,IAAI,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,SAAS,IAAI,yBAAyB,EAAE,CAAC;QAClE,OAAO,MAAM,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED,6DAA6D;IAC7D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,EAAE,CAAC;QAC7C,IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,GAAG,yBAAyB,EAAE,CAAC;YACtD,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,IAAI,mBAA2B,CAAC;IAEh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0,0 +1,28 @@
|
|
|
1
|
+
type SearchResult = {
|
|
2
|
+
results: (string | Record<string, unknown>)[];
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Self-contained local search engine backed by MiniSearch.
|
|
6
|
+
* Method data is embedded at SDK build time; prose documents
|
|
7
|
+
* can be loaded from an optional docs directory at runtime.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LocalDocsSearch {
|
|
10
|
+
private methodIndex;
|
|
11
|
+
private proseIndex;
|
|
12
|
+
private constructor();
|
|
13
|
+
static create(opts?: {
|
|
14
|
+
docsDir?: string;
|
|
15
|
+
}): Promise<LocalDocsSearch>;
|
|
16
|
+
search(props: {
|
|
17
|
+
query: string;
|
|
18
|
+
language?: string;
|
|
19
|
+
detail?: string;
|
|
20
|
+
maxResults?: number;
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
}): SearchResult;
|
|
23
|
+
private indexMethods;
|
|
24
|
+
private loadDocsDirectory;
|
|
25
|
+
private indexProse;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=local-docs-search.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-docs-search.d.mts","sourceRoot":"","sources":["src/local-docs-search.ts"],"names":[],"mappings":"AA+CA,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CAC/C,CAAC;AAo1HF;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,UAAU,CAAiC;IAEnD,OAAO;WAKM,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAY1E,MAAM,CAAC,KAAK,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,YAAY;IA2EhB,OAAO,CAAC,YAAY;YAiBN,iBAAiB;IA4C/B,OAAO,CAAC,UAAU;CAgBnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type SearchResult = {
|
|
2
|
+
results: (string | Record<string, unknown>)[];
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Self-contained local search engine backed by MiniSearch.
|
|
6
|
+
* Method data is embedded at SDK build time; prose documents
|
|
7
|
+
* can be loaded from an optional docs directory at runtime.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LocalDocsSearch {
|
|
10
|
+
private methodIndex;
|
|
11
|
+
private proseIndex;
|
|
12
|
+
private constructor();
|
|
13
|
+
static create(opts?: {
|
|
14
|
+
docsDir?: string;
|
|
15
|
+
}): Promise<LocalDocsSearch>;
|
|
16
|
+
search(props: {
|
|
17
|
+
query: string;
|
|
18
|
+
language?: string;
|
|
19
|
+
detail?: string;
|
|
20
|
+
maxResults?: number;
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
}): SearchResult;
|
|
23
|
+
private indexMethods;
|
|
24
|
+
private loadDocsDirectory;
|
|
25
|
+
private indexProse;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=local-docs-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-docs-search.d.ts","sourceRoot":"","sources":["src/local-docs-search.ts"],"names":[],"mappings":"AA+CA,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CAC/C,CAAC;AAo1HF;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAiC;IACpD,OAAO,CAAC,UAAU,CAAiC;IAEnD,OAAO;WAKM,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAY1E,MAAM,CAAC,KAAK,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,YAAY;IA2EhB,OAAO,CAAC,YAAY;YAiBN,iBAAiB;IA4C/B,OAAO,CAAC,UAAU;CAgBnB"}
|