@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/headers.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAK/E,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAA0B,EAAE;IAC/E,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACvE;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GACV,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAnBW,QAAA,gBAAgB,oBAmB3B"}
package/headers.mjs ADDED
@@ -0,0 +1,18 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ export const parseAuthHeaders = (req) => {
3
+ if (req.headers.authorization) {
4
+ const scheme = req.headers.authorization.split(' ')[0];
5
+ const value = req.headers.authorization.slice(scheme.length + 1);
6
+ switch (scheme) {
7
+ case 'Bearer':
8
+ return { apiKey: req.headers.authorization.slice('Bearer '.length) };
9
+ default:
10
+ throw new Error('Unsupported authorization scheme. Expected the "Authorization" header to be a supported scheme (Bearer).');
11
+ }
12
+ }
13
+ const apiKey = Array.isArray(req.headers['x-llama-cloud-api-key']) ?
14
+ req.headers['x-llama-cloud-api-key'][0]
15
+ : req.headers['x-llama-cloud-api-key'];
16
+ return { apiKey };
17
+ };
18
+ //# sourceMappingURL=headers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.mjs","sourceRoot":"","sources":["src/headers.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAKtF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAA0B,EAAE;IAC/E,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjE,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACvE;gBACE,MAAM,IAAI,KAAK,CACb,0GAA0G,CAC3G,CAAC;QACN,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GACV,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACnD,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC"}
package/http.d.mts ADDED
@@ -0,0 +1,9 @@
1
+ import express from 'express';
2
+ import { McpOptions } from "./options.mjs";
3
+ import { ClientOptions } from "./server.mjs";
4
+ export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
5
+ clientOptions?: ClientOptions;
6
+ mcpOptions?: McpOptions;
7
+ }) => express.Express;
8
+ export declare const launchStreamableHTTPServer: (options: McpOptions, port: number | string | undefined) => Promise<void>;
9
+ //# sourceMappingURL=http.d.mts.map
package/http.d.mts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.mts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAKO,OAAO,MAAM,SAAS;OACtB,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAA+B;AAuErD,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,OAAO,CAAC,OAUX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,SAAS,UAAU,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,kBAYtG,CAAC"}
package/http.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import express from 'express';
2
+ import { McpOptions } from "./options.js";
3
+ import { ClientOptions } from "./server.js";
4
+ export declare const streamableHTTPApp: ({ clientOptions, mcpOptions, }: {
5
+ clientOptions?: ClientOptions;
6
+ mcpOptions?: McpOptions;
7
+ }) => express.Express;
8
+ export declare const launchStreamableHTTPServer: (options: McpOptions, port: number | string | undefined) => Promise<void>;
9
+ //# sourceMappingURL=http.d.ts.map
package/http.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"OAKO,OAAO,MAAM,SAAS;OACtB,EAAE,UAAU,EAAE;OACd,EAAE,aAAa,EAA+B;AAuErD,eAAO,MAAM,iBAAiB,GAAI,gCAG/B;IACD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,KAAG,OAAO,CAAC,OAUX,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,SAAS,UAAU,EAAE,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,kBAYtG,CAAC"}
package/http.js ADDED
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
8
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
9
+ const express_1 = __importDefault(require("express"));
10
+ const server_1 = require("./server.js");
11
+ const headers_1 = require("./headers.js");
12
+ const newServer = ({ clientOptions, req, res, }) => {
13
+ const server = (0, server_1.newMcpServer)();
14
+ try {
15
+ const authOptions = (0, headers_1.parseAuthHeaders)(req);
16
+ (0, server_1.initMcpServer)({
17
+ server: server,
18
+ clientOptions: {
19
+ ...clientOptions,
20
+ ...authOptions,
21
+ },
22
+ });
23
+ }
24
+ catch (error) {
25
+ res.status(401).json({
26
+ jsonrpc: '2.0',
27
+ error: {
28
+ code: -32000,
29
+ message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
30
+ },
31
+ });
32
+ return null;
33
+ }
34
+ return server;
35
+ };
36
+ const post = (options) => async (req, res) => {
37
+ const server = newServer({ ...options, req, res });
38
+ // If we return null, we already set the authorization error.
39
+ if (server === null)
40
+ return;
41
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
42
+ // Stateless server
43
+ sessionIdGenerator: undefined,
44
+ });
45
+ await server.connect(transport);
46
+ await transport.handleRequest(req, res, req.body);
47
+ };
48
+ const get = async (req, res) => {
49
+ res.status(405).json({
50
+ jsonrpc: '2.0',
51
+ error: {
52
+ code: -32000,
53
+ message: 'Method not supported',
54
+ },
55
+ });
56
+ };
57
+ const del = async (req, res) => {
58
+ res.status(405).json({
59
+ jsonrpc: '2.0',
60
+ error: {
61
+ code: -32000,
62
+ message: 'Method not supported',
63
+ },
64
+ });
65
+ };
66
+ const streamableHTTPApp = ({ clientOptions = {}, mcpOptions = {}, }) => {
67
+ const app = (0, express_1.default)();
68
+ app.set('query parser', 'extended');
69
+ app.use(express_1.default.json());
70
+ app.get('/', get);
71
+ app.post('/', post({ clientOptions, mcpOptions }));
72
+ app.delete('/', del);
73
+ return app;
74
+ };
75
+ exports.streamableHTTPApp = streamableHTTPApp;
76
+ const launchStreamableHTTPServer = async (options, port) => {
77
+ const app = (0, exports.streamableHTTPApp)({ mcpOptions: options });
78
+ const server = app.listen(port);
79
+ const address = server.address();
80
+ if (typeof address === 'string') {
81
+ console.error(`MCP Server running on streamable HTTP at ${address}`);
82
+ }
83
+ else if (address !== null) {
84
+ console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
85
+ }
86
+ else {
87
+ console.error(`MCP Server running on streamable HTTP on port ${port}`);
88
+ }
89
+ };
90
+ exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
91
+ //# sourceMappingURL=http.js.map
package/http.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AAEnG,sDAA8B;AAE9B,wCAAsE;AACtE,0CAA6C;AAE7C,MAAM,SAAS,GAAG,CAAC,EACjB,aAAa,EACb,GAAG,EACH,GAAG,GAKJ,EAAoB,EAAE;IACrB,MAAM,MAAM,GAAG,IAAA,qBAAY,GAAE,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAA,0BAAgB,EAAC,GAAG,CAAC,CAAC;QAC1C,IAAA,sBAAa,EAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,GAAG,WAAW;aACf;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI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,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,0BAA0B,8BAYrC"}
package/http.mjs ADDED
@@ -0,0 +1,83 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
3
+ import express from 'express';
4
+ import { initMcpServer, newMcpServer } from "./server.mjs";
5
+ import { parseAuthHeaders } from "./headers.mjs";
6
+ const newServer = ({ clientOptions, req, res, }) => {
7
+ const server = newMcpServer();
8
+ try {
9
+ const authOptions = parseAuthHeaders(req);
10
+ initMcpServer({
11
+ server: server,
12
+ clientOptions: {
13
+ ...clientOptions,
14
+ ...authOptions,
15
+ },
16
+ });
17
+ }
18
+ catch (error) {
19
+ res.status(401).json({
20
+ jsonrpc: '2.0',
21
+ error: {
22
+ code: -32000,
23
+ message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
24
+ },
25
+ });
26
+ return null;
27
+ }
28
+ return server;
29
+ };
30
+ const post = (options) => async (req, res) => {
31
+ const server = newServer({ ...options, req, res });
32
+ // If we return null, we already set the authorization error.
33
+ if (server === null)
34
+ return;
35
+ const transport = new StreamableHTTPServerTransport({
36
+ // Stateless server
37
+ sessionIdGenerator: undefined,
38
+ });
39
+ await server.connect(transport);
40
+ await transport.handleRequest(req, res, req.body);
41
+ };
42
+ const get = async (req, res) => {
43
+ res.status(405).json({
44
+ jsonrpc: '2.0',
45
+ error: {
46
+ code: -32000,
47
+ message: 'Method not supported',
48
+ },
49
+ });
50
+ };
51
+ const del = async (req, res) => {
52
+ res.status(405).json({
53
+ jsonrpc: '2.0',
54
+ error: {
55
+ code: -32000,
56
+ message: 'Method not supported',
57
+ },
58
+ });
59
+ };
60
+ export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions = {}, }) => {
61
+ const app = express();
62
+ app.set('query parser', 'extended');
63
+ app.use(express.json());
64
+ app.get('/', get);
65
+ app.post('/', post({ clientOptions, mcpOptions }));
66
+ app.delete('/', del);
67
+ return app;
68
+ };
69
+ export const launchStreamableHTTPServer = async (options, port) => {
70
+ const app = streamableHTTPApp({ mcpOptions: options });
71
+ const server = app.listen(port);
72
+ const address = server.address();
73
+ if (typeof address === 'string') {
74
+ console.error(`MCP Server running on streamable HTTP at ${address}`);
75
+ }
76
+ else if (address !== null) {
77
+ console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
78
+ }
79
+ else {
80
+ console.error(`MCP Server running on streamable HTTP on port ${port}`);
81
+ }
82
+ };
83
+ //# sourceMappingURL=http.mjs.map
package/http.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;OAE3F,OAAO,MAAM,SAAS;OAEtB,EAAiB,aAAa,EAAE,YAAY,EAAE;OAC9C,EAAE,gBAAgB,EAAE;AAE3B,MAAM,SAAS,GAAG,CAAC,EACjB,aAAa,EACb,GAAG,EACH,GAAG,GAKJ,EAAoB,EAAE;IACrB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC1C,aAAa,CAAC;YACZ,MAAM,EAAE,MAAM;YACd,aAAa,EAAE;gBACb,GAAG,aAAa;gBAChB,GAAG,WAAW;aACf;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK;gBACZ,OAAO,EAAE,iBAAiB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;aAC3E;SACF,CAAC,CAAC;QACH,OAAO,IAAI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M,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACpC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IACnD,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAErB,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAAE,OAAmB,EAAE,IAAiC,EAAE,EAAE;IACzG,MAAM,GAAG,GAAG,iBAAiB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,CAAC,KAAK,CAAC,iDAAiD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CAAC"}
package/index.d.mts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
package/index.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const server_1 = require("./server.js");
5
+ const options_1 = require("./options.js");
6
+ const stdio_1 = require("./stdio.js");
7
+ const http_1 = require("./http.js");
8
+ async function main() {
9
+ const options = parseOptionsOrError();
10
+ const selectedTools = await selectToolsOrError(options);
11
+ console.error(`MCP Server starting with ${selectedTools.length} tools:`, selectedTools.map((e) => e.tool.name));
12
+ switch (options.transport) {
13
+ case 'stdio':
14
+ await (0, stdio_1.launchStdioServer)();
15
+ break;
16
+ case 'http':
17
+ await (0, http_1.launchStreamableHTTPServer)(options, options.port ?? options.socket);
18
+ break;
19
+ }
20
+ }
21
+ if (require.main === module) {
22
+ main().catch((error) => {
23
+ console.error('Fatal error in main():', error);
24
+ process.exit(1);
25
+ });
26
+ }
27
+ function parseOptionsOrError() {
28
+ try {
29
+ return (0, options_1.parseCLIOptions)();
30
+ }
31
+ catch (error) {
32
+ console.error('Error parsing options:', error);
33
+ process.exit(1);
34
+ }
35
+ }
36
+ async function selectToolsOrError(options) {
37
+ try {
38
+ const includedTools = (0, server_1.selectTools)(options);
39
+ if (includedTools.length === 0) {
40
+ console.error('No tools match the provided filters.');
41
+ process.exit(1);
42
+ }
43
+ return includedTools;
44
+ }
45
+ catch (error) {
46
+ if (error instanceof Error) {
47
+ console.error('Error filtering tools:', error.message);
48
+ }
49
+ else {
50
+ console.error('Error filtering tools:', error);
51
+ }
52
+ process.exit(1);
53
+ }
54
+ }
55
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version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nD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,IAAA,oBAAW,EAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
package/index.mjs ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ import { selectTools } from "./server.mjs";
3
+ import { parseCLIOptions } from "./options.mjs";
4
+ import { launchStdioServer } from "./stdio.mjs";
5
+ import { launchStreamableHTTPServer } from "./http.mjs";
6
+ async function main() {
7
+ const options = parseOptionsOrError();
8
+ const selectedTools = await selectToolsOrError(options);
9
+ console.error(`MCP Server starting with ${selectedTools.length} tools:`, selectedTools.map((e) => e.tool.name));
10
+ switch (options.transport) {
11
+ case 'stdio':
12
+ await launchStdioServer();
13
+ break;
14
+ case 'http':
15
+ await launchStreamableHTTPServer(options, options.port ?? options.socket);
16
+ break;
17
+ }
18
+ }
19
+ if (require.main === module) {
20
+ main().catch((error) => {
21
+ console.error('Fatal error in main():', error);
22
+ process.exit(1);
23
+ });
24
+ }
25
+ function parseOptionsOrError() {
26
+ try {
27
+ return parseCLIOptions();
28
+ }
29
+ catch (error) {
30
+ console.error('Error parsing options:', error);
31
+ process.exit(1);
32
+ }
33
+ }
34
+ async function selectToolsOrError(options) {
35
+ try {
36
+ const includedTools = selectTools(options);
37
+ if (includedTools.length === 0) {
38
+ console.error('No tools match the provided filters.');
39
+ process.exit(1);
40
+ }
41
+ return includedTools;
42
+ }
43
+ catch (error) {
44
+ if (error instanceof Error) {
45
+ console.error('Error filtering tools:', error.message);
46
+ }
47
+ else {
48
+ console.error('Error filtering tools:', error);
49
+ }
50
+ process.exit(1);
51
+ }
52
+ }
53
+ //# sourceMappingURL=index.mjs.map
package/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";OAEO,EAAE,WAAW,EAAE;OACf,EAAc,eAAe,EAAE;OAC/B,EAAE,iBAAiB,EAAE;OACrB,EAAE,0BAA0B,EAAE;AAGrC,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IAEtC,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAExD,OAAO,CAAC,KAAK,CACX,4BAA4B,aAAa,CAAC,MAAM,SAAS,EACzD,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACtC,CAAC;IAEF,QAAQ,OAAO,CAAC,SAAS,EAAE,CAAC;QAC1B,KAAK,OAAO;YACV,MAAM,iBAAiB,EAAE,CAAC;YAC1B,MAAM;QACR,KAAK,MAAM;YACT,MAAM,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;YAC1E,MAAM;IACV,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB;IAC1B,IAAI,CAAC;QACH,OAAO,eAAe,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,OAAmB;IACnD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
package/options.d.mts ADDED
@@ -0,0 +1,11 @@
1
+ export type CLIOptions = McpOptions & {
2
+ transport: 'stdio' | 'http';
3
+ port: number | undefined;
4
+ socket: string | undefined;
5
+ };
6
+ export type McpOptions = {
7
+ includeDocsTools?: boolean | undefined;
8
+ };
9
+ export declare function parseCLIOptions(): CLIOptions;
10
+ export declare function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions;
11
+ //# sourceMappingURL=options.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.mts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CA+C5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
package/options.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export type CLIOptions = McpOptions & {
2
+ transport: 'stdio' | 'http';
3
+ port: number | undefined;
4
+ socket: string | undefined;
5
+ };
6
+ export type McpOptions = {
7
+ includeDocsTools?: boolean | undefined;
8
+ };
9
+ export declare function parseCLIOptions(): CLIOptions;
10
+ export declare function parseQueryOptions(defaultOptions: McpOptions, query: unknown): McpOptions;
11
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG;IACpC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,wBAAgB,eAAe,IAAI,UAAU,CA+C5C;AAiBD,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAYxF"}
package/options.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseCLIOptions = parseCLIOptions;
7
+ exports.parseQueryOptions = parseQueryOptions;
8
+ const qs_1 = __importDefault(require("qs"));
9
+ const yargs_1 = __importDefault(require("yargs"));
10
+ const helpers_1 = require("yargs/helpers");
11
+ const zod_1 = __importDefault(require("zod"));
12
+ function parseCLIOptions() {
13
+ const opts = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
14
+ .option('tools', {
15
+ type: 'string',
16
+ array: true,
17
+ choices: ['code', 'docs'],
18
+ description: 'Use dynamic tools or all tools',
19
+ })
20
+ .option('no-tools', {
21
+ type: 'string',
22
+ array: true,
23
+ choices: ['code', 'docs'],
24
+ description: 'Do not use any dynamic or all tools',
25
+ })
26
+ .option('transport', {
27
+ type: 'string',
28
+ choices: ['stdio', 'http'],
29
+ default: 'stdio',
30
+ description: 'What transport to use; stdio for local servers or http for remote servers',
31
+ })
32
+ .option('port', {
33
+ type: 'number',
34
+ description: 'Port to serve on if using http transport',
35
+ })
36
+ .option('socket', {
37
+ type: 'string',
38
+ description: 'Unix socket to serve on if using http transport',
39
+ })
40
+ .help();
41
+ const argv = opts.parseSync();
42
+ const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
43
+ : argv.tools?.includes(toolType) ? true
44
+ : undefined;
45
+ const includeDocsTools = shouldIncludeToolType('docs');
46
+ const transport = argv.transport;
47
+ return {
48
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
49
+ transport,
50
+ port: argv.port,
51
+ socket: argv.socket,
52
+ };
53
+ }
54
+ const coerceArray = (zodType) => zod_1.default.preprocess((val) => Array.isArray(val) ? val
55
+ : val ? [val]
56
+ : val, zod_1.default.array(zodType).optional());
57
+ const QueryOptions = zod_1.default.object({
58
+ tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
59
+ no_tools: coerceArray(zod_1.default.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
60
+ tool: coerceArray(zod_1.default.string()).describe('Include tools matching the specified names'),
61
+ });
62
+ function parseQueryOptions(defaultOptions, query) {
63
+ const queryObject = typeof query === 'string' ? qs_1.default.parse(query) : query;
64
+ const queryOptions = QueryOptions.parse(queryObject);
65
+ let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
66
+ : queryOptions.tools?.includes('docs') ? true
67
+ : defaultOptions.includeDocsTools;
68
+ return {
69
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
70
+ };
71
+ }
72
+ //# sourceMappingURL=options.js.map
package/options.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["src/options.ts"],"names":[],"mappings":";;;;;AAeA,0CA+CC;AAiBD,8CAYC;AA3FD,4CAAoB;AACpB,kDAA0B;AAC1B,2CAAwC;AACxC,8CAAoB;AAYpB,SAAgB,eAAe;IAC7B,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACtC,MAAM,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,gCAAgC;KAC9C,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAClB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,qCAAqC;KACnD,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACnB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,C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,aAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,WAAW,CAAC,aAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IACvF,QAAQ,EAAE,WAAW,CAAC,aAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAC/F,IAAI,EAAE,WAAW,CAAC,aAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CACrF,CAAC,CAAC;AAEH,SAAgB,iBAAiB,CAAC,cAA0B,EAAE,KAAc;IAC1E,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxE,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAErD,IAAI,SAAS,GACX,YAAY,CAAC,QAAQ,IAAI,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;QACxE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;YAC7C,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAEpC,OAAO;QACL,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC"}
package/options.mjs ADDED
@@ -0,0 +1,65 @@
1
+ import qs from 'qs';
2
+ import yargs from 'yargs';
3
+ import { hideBin } from 'yargs/helpers';
4
+ import z from 'zod';
5
+ export function parseCLIOptions() {
6
+ const opts = yargs(hideBin(process.argv))
7
+ .option('tools', {
8
+ type: 'string',
9
+ array: true,
10
+ choices: ['code', 'docs'],
11
+ description: 'Use dynamic tools or all tools',
12
+ })
13
+ .option('no-tools', {
14
+ type: 'string',
15
+ array: true,
16
+ choices: ['code', 'docs'],
17
+ description: 'Do not use any dynamic or all tools',
18
+ })
19
+ .option('transport', {
20
+ type: 'string',
21
+ choices: ['stdio', 'http'],
22
+ default: 'stdio',
23
+ description: 'What transport to use; stdio for local servers or http for remote servers',
24
+ })
25
+ .option('port', {
26
+ type: 'number',
27
+ description: 'Port to serve on if using http transport',
28
+ })
29
+ .option('socket', {
30
+ type: 'string',
31
+ description: 'Unix socket to serve on if using http transport',
32
+ })
33
+ .help();
34
+ const argv = opts.parseSync();
35
+ const shouldIncludeToolType = (toolType) => argv.noTools?.includes(toolType) ? false
36
+ : argv.tools?.includes(toolType) ? true
37
+ : undefined;
38
+ const includeDocsTools = shouldIncludeToolType('docs');
39
+ const transport = argv.transport;
40
+ return {
41
+ ...(includeDocsTools !== undefined && { includeDocsTools }),
42
+ transport,
43
+ port: argv.port,
44
+ socket: argv.socket,
45
+ };
46
+ }
47
+ const coerceArray = (zodType) => z.preprocess((val) => Array.isArray(val) ? val
48
+ : val ? [val]
49
+ : val, z.array(zodType).optional());
50
+ const QueryOptions = z.object({
51
+ tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to use'),
52
+ no_tools: coerceArray(z.enum(['code', 'docs'])).describe('Specify which MCP tools to not use.'),
53
+ tool: coerceArray(z.string()).describe('Include tools matching the specified names'),
54
+ });
55
+ export function parseQueryOptions(defaultOptions, query) {
56
+ const queryObject = typeof query === 'string' ? qs.parse(query) : query;
57
+ const queryOptions = QueryOptions.parse(queryObject);
58
+ let docsTools = queryOptions.no_tools && queryOptions.no_tools?.includes('docs') ? false
59
+ : queryOptions.tools?.includes('docs') ? true
60
+ : defaultOptions.includeDocsTools;
61
+ return {
62
+ ...(docsTools !== undefined && { includeDocsTools: docsTools }),
63
+ };
64
+ }
65
+ //# sourceMappingURL=options.mjs.map
@@ -0,0 +1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