@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/src/headers.ts ADDED
@@ -0,0 +1,25 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { IncomingMessage } from 'node:http';
4
+ import { ClientOptions } from '@llamaindex/llama-cloud';
5
+
6
+ export const parseAuthHeaders = (req: IncomingMessage): Partial<ClientOptions> => {
7
+ if (req.headers.authorization) {
8
+ const scheme = req.headers.authorization.split(' ')[0]!;
9
+ const value = req.headers.authorization.slice(scheme.length + 1);
10
+ switch (scheme) {
11
+ case 'Bearer':
12
+ return { apiKey: req.headers.authorization.slice('Bearer '.length) };
13
+ default:
14
+ throw new Error(
15
+ 'Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).',
16
+ );
17
+ }
18
+ }
19
+
20
+ const apiKey =
21
+ Array.isArray(req.headers['x-llama-cloud-api-key']) ?
22
+ req.headers['x-llama-cloud-api-key'][0]
23
+ : req.headers['x-llama-cloud-api-key'];
24
+ return { apiKey };
25
+ };
package/src/http.ts ADDED
@@ -0,0 +1,109 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
4
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
5
+
6
+ import express from 'express';
7
+ import { McpOptions } from './options';
8
+ import { ClientOptions, initMcpServer, newMcpServer } from './server';
9
+ import { parseAuthHeaders } from './headers';
10
+
11
+ const newServer = ({
12
+ clientOptions,
13
+ req,
14
+ res,
15
+ }: {
16
+ clientOptions: ClientOptions;
17
+ req: express.Request;
18
+ res: express.Response;
19
+ }): McpServer | null => {
20
+ const server = newMcpServer();
21
+
22
+ try {
23
+ const authOptions = parseAuthHeaders(req);
24
+ initMcpServer({
25
+ server: server,
26
+ clientOptions: {
27
+ ...clientOptions,
28
+ ...authOptions,
29
+ },
30
+ });
31
+ } catch (error) {
32
+ res.status(401).json({
33
+ jsonrpc: '2.0',
34
+ error: {
35
+ code: -32000,
36
+ message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
37
+ },
38
+ });
39
+ return null;
40
+ }
41
+
42
+ return server;
43
+ };
44
+
45
+ const post =
46
+ (options: { clientOptions: ClientOptions; mcpOptions: McpOptions }) =>
47
+ async (req: express.Request, res: express.Response) => {
48
+ const server = newServer({ ...options, req, res });
49
+ // If we return null, we already set the authorization error.
50
+ if (server === null) return;
51
+ const transport = new StreamableHTTPServerTransport({
52
+ // Stateless server
53
+ sessionIdGenerator: undefined,
54
+ });
55
+ await server.connect(transport);
56
+ await transport.handleRequest(req, res, req.body);
57
+ };
58
+
59
+ const get = async (req: express.Request, res: express.Response) => {
60
+ res.status(405).json({
61
+ jsonrpc: '2.0',
62
+ error: {
63
+ code: -32000,
64
+ message: 'Method not supported',
65
+ },
66
+ });
67
+ };
68
+
69
+ const del = async (req: express.Request, res: express.Response) => {
70
+ res.status(405).json({
71
+ jsonrpc: '2.0',
72
+ error: {
73
+ code: -32000,
74
+ message: 'Method not supported',
75
+ },
76
+ });
77
+ };
78
+
79
+ export const streamableHTTPApp = ({
80
+ clientOptions = {},
81
+ mcpOptions = {},
82
+ }: {
83
+ clientOptions?: ClientOptions;
84
+ mcpOptions?: McpOptions;
85
+ }): express.Express => {
86
+ const app = express();
87
+ app.set('query parser', 'extended');
88
+ app.use(express.json());
89
+
90
+ app.get('/', get);
91
+ app.post('/', post({ clientOptions, mcpOptions }));
92
+ app.delete('/', del);
93
+
94
+ return app;
95
+ };
96
+
97
+ export const launchStreamableHTTPServer = async (options: McpOptions, port: number | string | undefined) => {
98
+ const app = streamableHTTPApp({ mcpOptions: options });
99
+ const server = app.listen(port);
100
+ const address = server.address();
101
+
102
+ if (typeof address === 'string') {
103
+ console.error(`MCP Server running on streamable HTTP at ${address}`);
104
+ } else if (address !== null) {
105
+ console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
106
+ } else {
107
+ console.error(`MCP Server running on streamable HTTP on port ${port}`);
108
+ }
109
+ };
package/src/index.ts ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { selectTools } from './server';
4
+ import { McpOptions, parseCLIOptions } from './options';
5
+ import { launchStdioServer } from './stdio';
6
+ import { launchStreamableHTTPServer } from './http';
7
+ import type { McpTool } from './types';
8
+
9
+ async function main() {
10
+ const options = parseOptionsOrError();
11
+
12
+ const selectedTools = await selectToolsOrError(options);
13
+
14
+ console.error(
15
+ `MCP Server starting with ${selectedTools.length} tools:`,
16
+ selectedTools.map((e) => e.tool.name),
17
+ );
18
+
19
+ switch (options.transport) {
20
+ case 'stdio':
21
+ await launchStdioServer();
22
+ break;
23
+ case 'http':
24
+ await launchStreamableHTTPServer(options, options.port ?? options.socket);
25
+ break;
26
+ }
27
+ }
28
+
29
+ if (require.main === module) {
30
+ main().catch((error) => {
31
+ console.error('Fatal error in main():', error);
32
+ process.exit(1);
33
+ });
34
+ }
35
+
36
+ function parseOptionsOrError() {
37
+ try {
38
+ return parseCLIOptions();
39
+ } catch (error) {
40
+ console.error('Error parsing options:', error);
41
+ process.exit(1);
42
+ }
43
+ }
44
+
45
+ async function selectToolsOrError(options: McpOptions): Promise<McpTool[]> {
46
+ try {
47
+ const includedTools = selectTools(options);
48
+ if (includedTools.length === 0) {
49
+ console.error('No tools match the provided filters.');
50
+ process.exit(1);
51
+ }
52
+ return includedTools;
53
+ } catch (error) {
54
+ if (error instanceof Error) {
55
+ console.error('Error filtering tools:', error.message);
56
+ } else {
57
+ console.error('Error filtering tools:', error);
58
+ }
59
+ process.exit(1);
60
+ }
61
+ }
package/src/options.ts ADDED
@@ -0,0 +1,92 @@
1
+ import qs from 'qs';
2
+ import yargs from 'yargs';
3
+ import { hideBin } from 'yargs/helpers';
4
+ import z from 'zod';
5
+
6
+ export type CLIOptions = McpOptions & {
7
+ transport: 'stdio' | 'http';
8
+ port: number | undefined;
9
+ socket: string | undefined;
10
+ };
11
+
12
+ export type McpOptions = {
13
+ includeDocsTools?: boolean | undefined;
14
+ };
15
+
16
+ export function parseCLIOptions(): CLIOptions {
17
+ const opts = yargs(hideBin(process.argv))
18
+ .option('tools', {
19
+ type: 'string',
20
+ array: true,
21
+ choices: ['code', 'docs'],
22
+ description: 'Use dynamic tools or all tools',
23
+ })
24
+ .option('no-tools', {
25
+ type: 'string',
26
+ array: true,
27
+ choices: ['code', 'docs'],
28
+ description: 'Do not use any dynamic or all tools',
29
+ })
30
+ .option('transport', {
31
+ type: 'string',
32
+ choices: ['stdio', 'http'],
33
+ default: 'stdio',
34
+ description: 'What transport to use; stdio for local servers or http for remote servers',
35
+ })
36
+ .option('port', {
37
+ type: 'number',
38
+ description: 'Port to serve on if using http transport',
39
+ })
40
+ .option('socket', {
41
+ type: 'string',
42
+ description: 'Unix socket to serve on if using http transport',
43
+ })
44
+ .help();
45
+
46
+ const argv = opts.parseSync();
47
+
48
+ const shouldIncludeToolType = (toolType: 'code' | 'docs') =>
49
+ argv.noTools?.includes(toolType) ? false
50
+ : argv.tools?.includes(toolType) ? true
51
+ : undefined;
52
+
53
+ const includeDocsTools = shouldIncludeToolType('docs');
54
+
55
+ const transport = argv.transport as 'stdio' | 'http';
56
+
57
+ return {
58
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
59
+ transport,
60
+ port: argv.port,
61
+ socket: argv.socket,
62
+ };
63
+ }
64
+
65
+ const coerceArray = <T extends z.ZodTypeAny>(zodType: T) =>
66
+ z.preprocess(
67
+ (val) =>
68
+ Array.isArray(val) ? val
69
+ : val ? [val]
70
+ : val,
71
+ z.array(zodType).optional(),
72
+ );
73
+
74
+ const QueryOptions = z.object({
75
+ tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
76
+ no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
77
+ tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
78
+ });
79
+
80
+ export function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions {
81
+ const queryObject = typeof query === 'string' ? qs.parse(query) : query;
82
+ const queryOptions = QueryOptions.parse(queryObject);
83
+
84
+ let docsTools: boolean | undefined =
85
+ queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
86
+ : queryOptions.tools?.includes('docs') ? true
87
+ : defaultOptions.includeDocsTools;
88
+
89
+ return {
90
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
91
+ };
92
+ }
package/src/server.ts ADDED
@@ -0,0 +1,147 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import {
6
+ CallToolRequestSchema,
7
+ ListToolsRequestSchema,
8
+ SetLevelRequestSchema,
9
+ } from '@modelcontextprotocol/sdk/types.js';
10
+ import { ClientOptions } from '@llamaindex/llama-cloud';
11
+ import LlamaCloud from '@llamaindex/llama-cloud';
12
+ import { codeTool } from './code-tool';
13
+ import docsSearchTool from './docs-search-tool';
14
+ import { McpOptions } from './options';
15
+ import { HandlerFunction, McpTool } from './types';
16
+
17
+ export { McpOptions } from './options';
18
+ export { ClientOptions } from '@llamaindex/llama-cloud';
19
+
20
+ export const newMcpServer = () =>
21
+ new McpServer(
22
+ {
23
+ name: 'llamaindex_llama_cloud_api',
24
+ version: '0.14.1',
25
+ },
26
+ { capabilities: { tools: {}, logging: {} } },
27
+ );
28
+
29
+ // Create server instance
30
+ export const server = newMcpServer();
31
+
32
+ /**
33
+ * Initializes the provided MCP Server with the given tools and handlers.
34
+ * If not provided, the default client, tools and handlers will be used.
35
+ */
36
+ export function initMcpServer(params: {
37
+ server: Server | McpServer;
38
+ clientOptions?: ClientOptions;
39
+ mcpOptions?: McpOptions;
40
+ }) {
41
+ const server = params.server instanceof McpServer ? params.server.server : params.server;
42
+
43
+ const logAtLevel =
44
+ (level: 'debug' | 'info' | 'warning' | 'error') =>
45
+ (message: string, ...rest: unknown[]) => {
46
+ void server.sendLoggingMessage({
47
+ level,
48
+ data: { message, rest },
49
+ });
50
+ };
51
+ const logger = {
52
+ debug: logAtLevel('debug'),
53
+ info: logAtLevel('info'),
54
+ warn: logAtLevel('warning'),
55
+ error: logAtLevel('error'),
56
+ };
57
+
58
+ let client = new LlamaCloud({
59
+ logger,
60
+ ...params.clientOptions,
61
+ defaultHeaders: {
62
+ ...params.clientOptions?.defaultHeaders,
63
+ 'X-Stainless-MCP': 'true',
64
+ },
65
+ });
66
+
67
+ const providedTools = selectTools(params.mcpOptions);
68
+ const toolMap = Object.fromEntries(providedTools.map((mcpTool) => [mcpTool.tool.name, mcpTool]));
69
+
70
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
71
+ return {
72
+ tools: providedTools.map((mcpTool) => mcpTool.tool),
73
+ };
74
+ });
75
+
76
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
77
+ const { name, arguments: args } = request.params;
78
+ const mcpTool = toolMap[name];
79
+ if (!mcpTool) {
80
+ throw new Error(`Unknown tool: ${name}`);
81
+ }
82
+
83
+ return executeHandler(mcpTool.handler, client, args);
84
+ });
85
+
86
+ server.setRequestHandler(SetLevelRequestSchema, async (request) => {
87
+ const { level } = request.params;
88
+ switch (level) {
89
+ case 'debug':
90
+ client = client.withOptions({ logLevel: 'debug' });
91
+ break;
92
+ case 'info':
93
+ client = client.withOptions({ logLevel: 'info' });
94
+ break;
95
+ case 'notice':
96
+ case 'warning':
97
+ client = client.withOptions({ logLevel: 'warn' });
98
+ break;
99
+ case 'error':
100
+ client = client.withOptions({ logLevel: 'error' });
101
+ break;
102
+ default:
103
+ client = client.withOptions({ logLevel: 'off' });
104
+ break;
105
+ }
106
+ return {};
107
+ });
108
+ }
109
+
110
+ /**
111
+ * Selects the tools to include in the MCP Server based on the provided options.
112
+ */
113
+ export function selectTools(options?: McpOptions): McpTool[] {
114
+ const includedTools = [codeTool()];
115
+ if (options?.includeDocsTools ?? true) {
116
+ includedTools.push(docsSearchTool);
117
+ }
118
+ return includedTools;
119
+ }
120
+
121
+ /**
122
+ * Runs the provided handler with the given client and arguments.
123
+ */
124
+ export async function executeHandler(
125
+ handler: HandlerFunction,
126
+ client: LlamaCloud,
127
+ args: Record<string, unknown> | undefined,
128
+ ) {
129
+ return await handler(client, args || {});
130
+ }
131
+
132
+ export const readEnv = (env: string): string | undefined => {
133
+ if (typeof (globalThis as any).process !== 'undefined') {
134
+ return (globalThis as any).process.env?.[env]?.trim();
135
+ } else if (typeof (globalThis as any).Deno !== 'undefined') {
136
+ return (globalThis as any).Deno.env?.get?.(env)?.trim();
137
+ }
138
+ return;
139
+ };
140
+
141
+ export const readEnvOrError = (env: string): string => {
142
+ let envValue = readEnv(env);
143
+ if (envValue === undefined) {
144
+ throw new Error(`Environment variable ${env} is not set`);
145
+ }
146
+ return envValue;
147
+ };
package/src/stdio.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
2
+ import { initMcpServer, newMcpServer } from './server';
3
+
4
+ export const launchStdioServer = async () => {
5
+ const server = newMcpServer();
6
+
7
+ initMcpServer({ server });
8
+
9
+ const transport = new StdioServerTransport();
10
+ await server.connect(transport);
11
+ console.error('MCP Server running on stdio');
12
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ // this config is included in the published src directory to prevent TS errors
3
+ // from appearing when users go to source, and VSCode opens the source .ts file
4
+ // via declaration maps
5
+ "include": ["index.ts"],
6
+ "compilerOptions": {
7
+ "target": "es2015",
8
+ "lib": ["DOM"],
9
+ "moduleResolution": "node"
10
+ }
11
+ }
package/src/types.ts ADDED
@@ -0,0 +1,115 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import LlamaCloud from '@llamaindex/llama-cloud';
4
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
5
+
6
+ type TextContentBlock = {
7
+ type: 'text';
8
+ text: string;
9
+ };
10
+
11
+ type ImageContentBlock = {
12
+ type: 'image';
13
+ data: string;
14
+ mimeType: string;
15
+ };
16
+
17
+ type AudioContentBlock = {
18
+ type: 'audio';
19
+ data: string;
20
+ mimeType: string;
21
+ };
22
+
23
+ type ResourceContentBlock = {
24
+ type: 'resource';
25
+ resource:
26
+ | {
27
+ uri: string;
28
+ mimeType: string;
29
+ text: string;
30
+ }
31
+ | {
32
+ uri: string;
33
+ mimeType: string;
34
+ blob: string;
35
+ };
36
+ };
37
+
38
+ export type ContentBlock = TextContentBlock | ImageContentBlock | AudioContentBlock | ResourceContentBlock;
39
+
40
+ export type ToolCallResult = {
41
+ content: ContentBlock[];
42
+ isError?: boolean;
43
+ };
44
+
45
+ export type HandlerFunction = (
46
+ client: LlamaCloud,
47
+ args: Record<string, unknown> | undefined,
48
+ ) => Promise<ToolCallResult>;
49
+
50
+ export function asTextContentResult(result: unknown): ToolCallResult {
51
+ return {
52
+ content: [
53
+ {
54
+ type: 'text',
55
+ text: JSON.stringify(result, null, 2),
56
+ },
57
+ ],
58
+ };
59
+ }
60
+
61
+ export async function asBinaryContentResult(response: Response): Promise<ToolCallResult> {
62
+ const blob = await response.blob();
63
+ const mimeType = blob.type;
64
+ const data = Buffer.from(await blob.arrayBuffer()).toString('base64');
65
+ if (mimeType.startsWith('image/')) {
66
+ return {
67
+ content: [{ type: 'image', mimeType, data }],
68
+ };
69
+ } else if (mimeType.startsWith('audio/')) {
70
+ return {
71
+ content: [{ type: 'audio', mimeType, data }],
72
+ };
73
+ } else {
74
+ return {
75
+ content: [
76
+ {
77
+ type: 'resource',
78
+ resource: {
79
+ // We must give a URI, even though this isn't actually an MCP resource.
80
+ uri: 'resource://tool-response',
81
+ mimeType,
82
+ blob: data,
83
+ },
84
+ },
85
+ ],
86
+ };
87
+ }
88
+ }
89
+
90
+ export function asErrorResult(message: string): ToolCallResult {
91
+ return {
92
+ content: [
93
+ {
94
+ type: 'text',
95
+ text: message,
96
+ },
97
+ ],
98
+ isError: true,
99
+ };
100
+ }
101
+
102
+ export type Metadata = {
103
+ resource: string;
104
+ operation: 'read' | 'write';
105
+ tags: string[];
106
+ httpMethod?: string;
107
+ httpPath?: string;
108
+ operationId?: string;
109
+ };
110
+
111
+ export type McpTool = {
112
+ metadata: Metadata;
113
+ tool: Tool;
114
+ handler: HandlerFunction;
115
+ };
package/stdio.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const launchStdioServer: () => Promise<void>;
2
+ //# sourceMappingURL=stdio.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.mts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,qBAQ7B,CAAC"}
package/stdio.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const launchStdioServer: () => Promise<void>;
2
+ //# sourceMappingURL=stdio.d.ts.map
package/stdio.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,qBAQ7B,CAAC"}
package/stdio.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.launchStdioServer = void 0;
4
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
5
+ const server_1 = require("./server.js");
6
+ const launchStdioServer = async () => {
7
+ const server = (0, server_1.newMcpServer)();
8
+ (0, server_1.initMcpServer)({ server });
9
+ const transport = new stdio_js_1.StdioServerTransport();
10
+ await server.connect(transport);
11
+ console.error('MCP Server running on stdio');
12
+ };
13
+ exports.launchStdioServer = launchStdioServer;
14
+ //# sourceMappingURL=stdio.js.map
package/stdio.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.js","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":";;;AAAA,wEAAiF;AACjF,wCAAuD;AAEhD,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAA,qBAAY,GAAE,CAAC;IAE9B,IAAA,sBAAa,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1B,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
package/stdio.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
2
+ import { initMcpServer, newMcpServer } from "./server.mjs";
3
+ export const launchStdioServer = async () => {
4
+ const server = newMcpServer();
5
+ initMcpServer({ server });
6
+ const transport = new StdioServerTransport();
7
+ await server.connect(transport);
8
+ console.error('MCP Server running on stdio');
9
+ };
10
+ //# sourceMappingURL=stdio.mjs.map
package/stdio.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.mjs","sourceRoot":"","sources":["src/stdio.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C;OACzE,EAAE,aAAa,EAAE,YAAY,EAAE;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE;IAC1C,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAE9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC,CAAC"}
package/types.d.mts ADDED
@@ -0,0 +1,52 @@
1
+ import LlamaCloud from '@llamaindex/llama-cloud';
2
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
3
+ type TextContentBlock = {
4
+ type: 'text';
5
+ text: string;
6
+ };
7
+ type ImageContentBlock = {
8
+ type: 'image';
9
+ data: string;
10
+ mimeType: string;
11
+ };
12
+ type AudioContentBlock = {
13
+ type: 'audio';
14
+ data: string;
15
+ mimeType: string;
16
+ };
17
+ type ResourceContentBlock = {
18
+ type: 'resource';
19
+ resource: {
20
+ uri: string;
21
+ mimeType: string;
22
+ text: string;
23
+ } | {
24
+ uri: string;
25
+ mimeType: string;
26
+ blob: string;
27
+ };
28
+ };
29
+ export type ContentBlock = TextContentBlock | ImageContentBlock | AudioContentBlock | ResourceContentBlock;
30
+ export type ToolCallResult = {
31
+ content: ContentBlock[];
32
+ isError?: boolean;
33
+ };
34
+ export type HandlerFunction = (client: LlamaCloud, args: Record<string, unknown> | undefined) => Promise<ToolCallResult>;
35
+ export declare function asTextContentResult(result: unknown): ToolCallResult;
36
+ export declare function asBinaryContentResult(response: Response): Promise<ToolCallResult>;
37
+ export declare function asErrorResult(message: string): ToolCallResult;
38
+ export type Metadata = {
39
+ resource: string;
40
+ operation: 'read' | 'write';
41
+ tags: string[];
42
+ httpMethod?: string;
43
+ httpPath?: string;
44
+ operationId?: string;
45
+ };
46
+ export type McpTool = {
47
+ metadata: Metadata;
48
+ tool: Tool;
49
+ handler: HandlerFunction;
50
+ };
51
+ export {};
52
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["src/types.ts"],"names":[],"mappings":"OAEO,UAAU,MAAM,yBAAyB;OACzC,EAAE,IAAI,EAAE,MAAM,oCAAoC;AAEzD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EACJ;QACE,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,GACD;QACE,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAE3G,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,KACtC,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CASnE;AAED,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CA2BvF;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAU7D;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC"}