cas-parser-node-mcp 1.4.0 → 1.7.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.
- package/LICENSE +1 -1
- package/README.md +29 -147
- package/auth.d.mts +4 -0
- package/auth.d.mts.map +1 -0
- package/auth.d.ts +4 -0
- package/auth.d.ts.map +1 -0
- package/{headers.js → auth.js} +2 -2
- package/auth.js.map +1 -0
- package/{headers.mjs → auth.mjs} +2 -2
- package/auth.mjs.map +1 -0
- package/code-tool-types.d.mts +7 -7
- package/code-tool-types.d.mts.map +1 -1
- package/code-tool-types.d.ts +7 -7
- package/code-tool-types.d.ts.map +1 -1
- package/code-tool.d.mts +6 -3
- package/code-tool.d.mts.map +1 -1
- package/code-tool.d.ts +6 -3
- package/code-tool.d.ts.map +1 -1
- package/code-tool.js +86 -132
- package/code-tool.js.map +1 -1
- package/code-tool.mjs +86 -99
- package/code-tool.mjs.map +1 -1
- package/{tools/cas-generator/generate-cas-cas-generator.d.ts → docs-search-tool.d.mts} +17 -11
- package/docs-search-tool.d.mts.map +1 -0
- package/{tools/cas-generator/generate-cas-cas-generator.d.mts → docs-search-tool.d.ts} +17 -11
- package/docs-search-tool.d.ts.map +1 -0
- package/docs-search-tool.js +57 -0
- package/docs-search-tool.js.map +1 -0
- package/docs-search-tool.mjs +53 -0
- package/docs-search-tool.mjs.map +1 -0
- package/http.d.mts +9 -4
- package/http.d.mts.map +1 -1
- package/http.d.ts +9 -4
- package/http.d.ts.map +1 -1
- package/http.js +31 -34
- package/http.js.map +1 -1
- package/http.mjs +31 -34
- package/http.mjs.map +1 -1
- package/index.js +8 -40
- package/index.js.map +1 -1
- package/index.mjs +8 -40
- package/index.mjs.map +1 -1
- package/methods.d.mts +10 -0
- package/methods.d.mts.map +1 -0
- package/methods.d.ts +10 -0
- package/methods.d.ts.map +1 -0
- package/methods.js +167 -0
- package/methods.js.map +1 -0
- package/methods.mjs +163 -0
- package/methods.mjs.map +1 -0
- package/options.d.mts +5 -9
- package/options.d.mts.map +1 -1
- package/options.d.ts +5 -9
- package/options.d.ts.map +1 -1
- package/options.js +37 -362
- package/options.js.map +1 -1
- package/options.mjs +37 -362
- package/options.mjs.map +1 -1
- package/package.json +57 -79
- package/server.d.mts +5 -15
- package/server.d.mts.map +1 -1
- package/server.d.ts +5 -15
- package/server.d.ts.map +1 -1
- package/server.js +54 -87
- package/server.js.map +1 -1
- package/server.mjs +53 -82
- package/server.mjs.map +1 -1
- package/src/{headers.ts → auth.ts} +1 -1
- package/src/code-tool-types.ts +7 -5
- package/src/code-tool.ts +104 -117
- package/src/docs-search-tool.ts +65 -0
- package/src/http.ts +44 -40
- package/src/index.ts +9 -52
- package/src/methods.ts +188 -0
- package/src/options.ts +48 -384
- package/src/server.ts +63 -97
- package/src/stdio.ts +4 -4
- package/src/{tools/types.ts → types.ts} +13 -1
- package/src/util.ts +25 -0
- package/stdio.d.mts +1 -1
- package/stdio.d.mts.map +1 -1
- package/stdio.d.ts +1 -1
- package/stdio.d.ts.map +1 -1
- package/stdio.js +3 -3
- package/stdio.js.map +1 -1
- package/stdio.mjs +3 -3
- package/stdio.mjs.map +1 -1
- package/{tools/types.d.mts → types.d.mts} +2 -1
- package/types.d.mts.map +1 -0
- package/{tools/types.d.ts → types.d.ts} +2 -1
- package/types.d.ts.map +1 -0
- package/{tools/types.js → types.js} +12 -0
- package/types.js.map +1 -0
- package/{tools/types.mjs → types.mjs} +11 -0
- package/types.mjs.map +1 -0
- package/util.d.mts +4 -0
- package/util.d.mts.map +1 -0
- package/util.d.ts +4 -0
- package/util.d.ts.map +1 -0
- package/util.js +30 -0
- package/util.js.map +1 -0
- package/util.mjs +24 -0
- package/util.mjs.map +1 -0
- package/code-tool-paths.cjs +0 -6
- package/code-tool-paths.cjs.map +0 -1
- package/code-tool-paths.d.cts +0 -2
- package/code-tool-paths.d.cts.map +0 -1
- package/code-tool-worker.d.mts +0 -5
- package/code-tool-worker.d.mts.map +0 -1
- package/code-tool-worker.d.ts +0 -5
- package/code-tool-worker.d.ts.map +0 -1
- package/code-tool-worker.js +0 -45
- package/code-tool-worker.js.map +0 -1
- package/code-tool-worker.mjs +0 -40
- package/code-tool-worker.mjs.map +0 -1
- package/compat.d.mts +0 -58
- package/compat.d.mts.map +0 -1
- package/compat.d.ts +0 -58
- package/compat.d.ts.map +0 -1
- package/compat.js +0 -387
- package/compat.js.map +0 -1
- package/compat.mjs +0 -378
- package/compat.mjs.map +0 -1
- package/dynamic-tools.d.mts +0 -12
- package/dynamic-tools.d.mts.map +0 -1
- package/dynamic-tools.d.ts +0 -12
- package/dynamic-tools.d.ts.map +0 -1
- package/dynamic-tools.js +0 -135
- package/dynamic-tools.js.map +0 -1
- package/dynamic-tools.mjs +0 -132
- package/dynamic-tools.mjs.map +0 -1
- package/filtering.d.mts +0 -2
- package/filtering.d.mts.map +0 -1
- package/filtering.d.ts +0 -2
- package/filtering.d.ts.map +0 -1
- package/filtering.js +0 -20
- package/filtering.js.map +0 -1
- package/filtering.mjs +0 -13
- package/filtering.mjs.map +0 -1
- package/headers.d.mts +0 -4
- package/headers.d.mts.map +0 -1
- package/headers.d.ts +0 -4
- package/headers.d.ts.map +0 -1
- package/headers.js.map +0 -1
- package/headers.mjs.map +0 -1
- package/src/code-tool-paths.cts +0 -3
- package/src/code-tool-worker.ts +0 -46
- package/src/compat.ts +0 -483
- package/src/dynamic-tools.ts +0 -159
- package/src/filtering.ts +0 -14
- package/src/tools/cas-generator/generate-cas-cas-generator.ts +0 -67
- package/src/tools/cas-parser/cams-kfintech-cas-parser.ts +0 -47
- package/src/tools/cas-parser/cdsl-cas-parser.ts +0 -47
- package/src/tools/cas-parser/nsdl-cas-parser.ts +0 -47
- package/src/tools/cas-parser/smart-parse-cas-parser.ts +0 -47
- package/src/tools/index.ts +0 -79
- package/src/tools.ts +0 -1
- package/tools/cas-generator/generate-cas-cas-generator.d.mts.map +0 -1
- package/tools/cas-generator/generate-cas-cas-generator.d.ts.map +0 -1
- package/tools/cas-generator/generate-cas-cas-generator.js +0 -62
- package/tools/cas-generator/generate-cas-cas-generator.js.map +0 -1
- package/tools/cas-generator/generate-cas-cas-generator.mjs +0 -58
- package/tools/cas-generator/generate-cas-cas-generator.mjs.map +0 -1
- package/tools/cas-parser/cams-kfintech-cas-parser.d.mts +0 -45
- package/tools/cas-parser/cams-kfintech-cas-parser.d.mts.map +0 -1
- package/tools/cas-parser/cams-kfintech-cas-parser.d.ts +0 -45
- package/tools/cas-parser/cams-kfintech-cas-parser.d.ts.map +0 -1
- package/tools/cas-parser/cams-kfintech-cas-parser.js +0 -43
- package/tools/cas-parser/cams-kfintech-cas-parser.js.map +0 -1
- package/tools/cas-parser/cams-kfintech-cas-parser.mjs +0 -39
- package/tools/cas-parser/cams-kfintech-cas-parser.mjs.map +0 -1
- package/tools/cas-parser/cdsl-cas-parser.d.mts +0 -45
- package/tools/cas-parser/cdsl-cas-parser.d.mts.map +0 -1
- package/tools/cas-parser/cdsl-cas-parser.d.ts +0 -45
- package/tools/cas-parser/cdsl-cas-parser.d.ts.map +0 -1
- package/tools/cas-parser/cdsl-cas-parser.js +0 -43
- package/tools/cas-parser/cdsl-cas-parser.js.map +0 -1
- package/tools/cas-parser/cdsl-cas-parser.mjs +0 -39
- package/tools/cas-parser/cdsl-cas-parser.mjs.map +0 -1
- package/tools/cas-parser/nsdl-cas-parser.d.mts +0 -45
- package/tools/cas-parser/nsdl-cas-parser.d.mts.map +0 -1
- package/tools/cas-parser/nsdl-cas-parser.d.ts +0 -45
- package/tools/cas-parser/nsdl-cas-parser.d.ts.map +0 -1
- package/tools/cas-parser/nsdl-cas-parser.js +0 -43
- package/tools/cas-parser/nsdl-cas-parser.js.map +0 -1
- package/tools/cas-parser/nsdl-cas-parser.mjs +0 -39
- package/tools/cas-parser/nsdl-cas-parser.mjs.map +0 -1
- package/tools/cas-parser/smart-parse-cas-parser.d.mts +0 -45
- package/tools/cas-parser/smart-parse-cas-parser.d.mts.map +0 -1
- package/tools/cas-parser/smart-parse-cas-parser.d.ts +0 -45
- package/tools/cas-parser/smart-parse-cas-parser.d.ts.map +0 -1
- package/tools/cas-parser/smart-parse-cas-parser.js +0 -43
- package/tools/cas-parser/smart-parse-cas-parser.js.map +0 -1
- package/tools/cas-parser/smart-parse-cas-parser.mjs +0 -39
- package/tools/cas-parser/smart-parse-cas-parser.mjs.map +0 -1
- package/tools/index.d.mts +0 -10
- package/tools/index.d.mts.map +0 -1
- package/tools/index.d.ts +0 -10
- package/tools/index.d.ts.map +0 -1
- package/tools/index.js +0 -63
- package/tools/index.js.map +0 -1
- package/tools/index.mjs +0 -56
- package/tools/index.mjs.map +0 -1
- package/tools/types.d.mts.map +0 -1
- package/tools/types.d.ts.map +0 -1
- package/tools/types.js.map +0 -1
- package/tools/types.mjs.map +0 -1
- package/tools.d.mts +0 -2
- package/tools.d.mts.map +0 -1
- package/tools.d.ts +0 -2
- package/tools.d.ts.map +0 -1
- package/tools.js +0 -18
- package/tools.js.map +0 -1
- package/tools.mjs +0 -2
- package/tools.mjs.map +0 -1
package/http.js
CHANGED
|
@@ -7,43 +7,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.launchStreamableHTTPServer = exports.streamableHTTPApp = void 0;
|
|
8
8
|
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
9
9
|
const express_1 = __importDefault(require("express"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const morgan_1 = __importDefault(require("morgan"));
|
|
11
|
+
const morgan_body_1 = __importDefault(require("morgan-body"));
|
|
12
|
+
const auth_1 = require("./auth.js");
|
|
12
13
|
const server_1 = require("./server.js");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const server = (0, server_1.newMcpServer)();
|
|
16
|
-
let mcpOptions;
|
|
14
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
15
|
+
const server = await (0, server_1.newMcpServer)();
|
|
17
16
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
catch (error) {
|
|
21
|
-
res.status(400).json({
|
|
22
|
-
jsonrpc: '2.0',
|
|
23
|
-
error: {
|
|
24
|
-
code: -32000,
|
|
25
|
-
message: `Invalid request: ${(0, v3_1.fromError)(error)}`,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
const authOptions = (0, headers_1.parseAuthHeaders)(req);
|
|
32
|
-
(0, server_1.initMcpServer)({
|
|
17
|
+
const authOptions = (0, auth_1.parseAuthHeaders)(req, false);
|
|
18
|
+
await (0, server_1.initMcpServer)({
|
|
33
19
|
server: server,
|
|
20
|
+
mcpOptions: mcpOptions,
|
|
34
21
|
clientOptions: {
|
|
35
22
|
...clientOptions,
|
|
36
23
|
...authOptions,
|
|
37
24
|
},
|
|
38
|
-
mcpOptions,
|
|
39
25
|
});
|
|
40
26
|
}
|
|
41
|
-
catch {
|
|
27
|
+
catch (error) {
|
|
42
28
|
res.status(401).json({
|
|
43
29
|
jsonrpc: '2.0',
|
|
44
30
|
error: {
|
|
45
31
|
code: -32000,
|
|
46
|
-
message:
|
|
32
|
+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
|
|
47
33
|
},
|
|
48
34
|
});
|
|
49
35
|
return null;
|
|
@@ -51,14 +37,11 @@ const newServer = ({ clientOptions, mcpOptions: defaultMcpOptions, req, res, })
|
|
|
51
37
|
return server;
|
|
52
38
|
};
|
|
53
39
|
const post = (options) => async (req, res) => {
|
|
54
|
-
const server = newServer({ ...options, req, res });
|
|
40
|
+
const server = await newServer({ ...options, req, res });
|
|
55
41
|
// If we return null, we already set the authorization error.
|
|
56
42
|
if (server === null)
|
|
57
43
|
return;
|
|
58
|
-
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport(
|
|
59
|
-
// Stateless server
|
|
60
|
-
sessionIdGenerator: undefined,
|
|
61
|
-
});
|
|
44
|
+
const transport = new streamableHttp_js_1.StreamableHTTPServerTransport();
|
|
62
45
|
await server.connect(transport);
|
|
63
46
|
await transport.handleRequest(req, res, req.body);
|
|
64
47
|
};
|
|
@@ -80,19 +63,33 @@ const del = async (req, res) => {
|
|
|
80
63
|
},
|
|
81
64
|
});
|
|
82
65
|
};
|
|
83
|
-
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions
|
|
66
|
+
const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
84
67
|
const app = (0, express_1.default)();
|
|
85
68
|
app.set('query parser', 'extended');
|
|
86
69
|
app.use(express_1.default.json());
|
|
70
|
+
if (debug) {
|
|
71
|
+
(0, morgan_body_1.default)(app, {
|
|
72
|
+
logAllReqHeader: true,
|
|
73
|
+
logAllResHeader: true,
|
|
74
|
+
logRequestBody: true,
|
|
75
|
+
logResponseBody: true,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
app.use((0, morgan_1.default)('combined'));
|
|
80
|
+
}
|
|
81
|
+
app.get('/health', async (req, res) => {
|
|
82
|
+
res.status(200).send('OK');
|
|
83
|
+
});
|
|
87
84
|
app.get('/', get);
|
|
88
85
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
89
86
|
app.delete('/', del);
|
|
90
87
|
return app;
|
|
91
88
|
};
|
|
92
89
|
exports.streamableHTTPApp = streamableHTTPApp;
|
|
93
|
-
const launchStreamableHTTPServer = async (
|
|
94
|
-
const app = (0, exports.streamableHTTPApp)({ mcpOptions:
|
|
95
|
-
const server = app.listen(port);
|
|
90
|
+
const launchStreamableHTTPServer = async (params) => {
|
|
91
|
+
const app = (0, exports.streamableHTTPApp)({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
92
|
+
const server = app.listen(params.port);
|
|
96
93
|
const address = server.address();
|
|
97
94
|
if (typeof address === 'string') {
|
|
98
95
|
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
@@ -101,7 +98,7 @@ const launchStreamableHTTPServer = async (options, port) => {
|
|
|
101
98
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
102
99
|
}
|
|
103
100
|
else {
|
|
104
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
101
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
105
102
|
}
|
|
106
103
|
};
|
|
107
104
|
exports.launchStreamableHTTPServer = launchStreamableHTTPServer;
|
package/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AAEnG,sDAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;AAGtF,0FAAmG;AAEnG,sDAA8B;AAC9B,oDAA4B;AAC5B,8DAAqC;AACrC,oCAA0C;AAE1C,wCAAuD;AAEvD,MAAM,SAAS,GAAG,KAAK,EAAE,EACvB,aAAa,EACb,UAAU,EACV,GAAG,EACH,GAAG,GAMJ,EAA6B,EAAE;IAC9B,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,GAAE,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAA,uBAAgB,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjD,MAAM,IAAA,sBAAa,EAAC;YAClB,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,UAAU;YACtB,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,CA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CAAC;IACvC,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,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC;AAhBW,QAAA,0BAA0B,8BAgBrC"}
|
package/http.mjs
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
3
|
import express from 'express';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import morgan from 'morgan';
|
|
5
|
+
import morganBody from 'morgan-body';
|
|
6
|
+
import { parseAuthHeaders } from "./auth.mjs";
|
|
6
7
|
import { initMcpServer, newMcpServer } from "./server.mjs";
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const server = newMcpServer();
|
|
10
|
-
let mcpOptions;
|
|
8
|
+
const newServer = async ({ clientOptions, mcpOptions, req, res, }) => {
|
|
9
|
+
const server = await newMcpServer();
|
|
11
10
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
catch (error) {
|
|
15
|
-
res.status(400).json({
|
|
16
|
-
jsonrpc: '2.0',
|
|
17
|
-
error: {
|
|
18
|
-
code: -32000,
|
|
19
|
-
message: `Invalid request: ${fromError(error)}`,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
const authOptions = parseAuthHeaders(req);
|
|
26
|
-
initMcpServer({
|
|
11
|
+
const authOptions = parseAuthHeaders(req, false);
|
|
12
|
+
await initMcpServer({
|
|
27
13
|
server: server,
|
|
14
|
+
mcpOptions: mcpOptions,
|
|
28
15
|
clientOptions: {
|
|
29
16
|
...clientOptions,
|
|
30
17
|
...authOptions,
|
|
31
18
|
},
|
|
32
|
-
mcpOptions,
|
|
33
19
|
});
|
|
34
20
|
}
|
|
35
|
-
catch {
|
|
21
|
+
catch (error) {
|
|
36
22
|
res.status(401).json({
|
|
37
23
|
jsonrpc: '2.0',
|
|
38
24
|
error: {
|
|
39
25
|
code: -32000,
|
|
40
|
-
message:
|
|
26
|
+
message: `Unauthorized: ${error instanceof Error ? error.message : error}`,
|
|
41
27
|
},
|
|
42
28
|
});
|
|
43
29
|
return null;
|
|
@@ -45,14 +31,11 @@ const newServer = ({ clientOptions, mcpOptions: defaultMcpOptions, req, res, })
|
|
|
45
31
|
return server;
|
|
46
32
|
};
|
|
47
33
|
const post = (options) => async (req, res) => {
|
|
48
|
-
const server = newServer({ ...options, req, res });
|
|
34
|
+
const server = await newServer({ ...options, req, res });
|
|
49
35
|
// If we return null, we already set the authorization error.
|
|
50
36
|
if (server === null)
|
|
51
37
|
return;
|
|
52
|
-
const transport = new StreamableHTTPServerTransport(
|
|
53
|
-
// Stateless server
|
|
54
|
-
sessionIdGenerator: undefined,
|
|
55
|
-
});
|
|
38
|
+
const transport = new StreamableHTTPServerTransport();
|
|
56
39
|
await server.connect(transport);
|
|
57
40
|
await transport.handleRequest(req, res, req.body);
|
|
58
41
|
};
|
|
@@ -74,18 +57,32 @@ const del = async (req, res) => {
|
|
|
74
57
|
},
|
|
75
58
|
});
|
|
76
59
|
};
|
|
77
|
-
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions
|
|
60
|
+
export const streamableHTTPApp = ({ clientOptions = {}, mcpOptions, debug, }) => {
|
|
78
61
|
const app = express();
|
|
79
62
|
app.set('query parser', 'extended');
|
|
80
63
|
app.use(express.json());
|
|
64
|
+
if (debug) {
|
|
65
|
+
morganBody(app, {
|
|
66
|
+
logAllReqHeader: true,
|
|
67
|
+
logAllResHeader: true,
|
|
68
|
+
logRequestBody: true,
|
|
69
|
+
logResponseBody: true,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
app.use(morgan('combined'));
|
|
74
|
+
}
|
|
75
|
+
app.get('/health', async (req, res) => {
|
|
76
|
+
res.status(200).send('OK');
|
|
77
|
+
});
|
|
81
78
|
app.get('/', get);
|
|
82
79
|
app.post('/', post({ clientOptions, mcpOptions }));
|
|
83
80
|
app.delete('/', del);
|
|
84
81
|
return app;
|
|
85
82
|
};
|
|
86
|
-
export const launchStreamableHTTPServer = async (
|
|
87
|
-
const app = streamableHTTPApp({ mcpOptions:
|
|
88
|
-
const server = app.listen(port);
|
|
83
|
+
export const launchStreamableHTTPServer = async (params) => {
|
|
84
|
+
const app = streamableHTTPApp({ mcpOptions: params.mcpOptions, debug: params.debug });
|
|
85
|
+
const server = app.listen(params.port);
|
|
89
86
|
const address = server.address();
|
|
90
87
|
if (typeof address === 'string') {
|
|
91
88
|
console.error(`MCP Server running on streamable HTTP at ${address}`);
|
|
@@ -94,7 +91,7 @@ export const launchStreamableHTTPServer = async (options, port) => {
|
|
|
94
91
|
console.error(`MCP Server running on streamable HTTP on port ${address.port}`);
|
|
95
92
|
}
|
|
96
93
|
else {
|
|
97
|
-
console.error(`MCP Server running on streamable HTTP on port ${port}`);
|
|
94
|
+
console.error(`MCP Server running on streamable HTTP on port ${params.port}`);
|
|
98
95
|
}
|
|
99
96
|
};
|
|
100
97
|
//# sourceMappingURL=http.mjs.map
|
package/http.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.mjs","sourceRoot":"","sources":["src/http.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAG/E,EAAE,6BAA6B,EAAE,MAAM,oDAAoD;O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C,iDAAiD,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC"}
|
package/index.js
CHANGED
|
@@ -2,24 +2,23 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const server_1 = require("./server.js");
|
|
5
|
-
const tools_1 = require("./tools.js");
|
|
6
5
|
const options_1 = require("./options.js");
|
|
7
6
|
const stdio_1 = require("./stdio.js");
|
|
8
7
|
const http_1 = require("./http.js");
|
|
9
8
|
async function main() {
|
|
10
9
|
const options = parseOptionsOrError();
|
|
11
|
-
|
|
12
|
-
listAllTools();
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const selectedTools = await selectToolsOrError(tools_1.endpoints, options);
|
|
10
|
+
const selectedTools = await selectToolsOrError(options);
|
|
16
11
|
console.error(`MCP Server starting with ${selectedTools.length} tools:`, selectedTools.map((e) => e.tool.name));
|
|
17
12
|
switch (options.transport) {
|
|
18
13
|
case 'stdio':
|
|
19
14
|
await (0, stdio_1.launchStdioServer)(options);
|
|
20
15
|
break;
|
|
21
16
|
case 'http':
|
|
22
|
-
await (0, http_1.launchStreamableHTTPServer)(
|
|
17
|
+
await (0, http_1.launchStreamableHTTPServer)({
|
|
18
|
+
mcpOptions: options,
|
|
19
|
+
debug: options.debug,
|
|
20
|
+
port: options.port ?? options.socket,
|
|
21
|
+
});
|
|
23
22
|
break;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -38,9 +37,9 @@ function parseOptionsOrError() {
|
|
|
38
37
|
process.exit(1);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
async function selectToolsOrError(
|
|
40
|
+
async function selectToolsOrError(options) {
|
|
42
41
|
try {
|
|
43
|
-
const includedTools =
|
|
42
|
+
const includedTools = (0, server_1.selectTools)(options);
|
|
44
43
|
if (includedTools.length === 0) {
|
|
45
44
|
console.error('No tools match the provided filters.');
|
|
46
45
|
process.exit(1);
|
|
@@ -57,35 +56,4 @@ async function selectToolsOrError(endpoints, options) {
|
|
|
57
56
|
process.exit(1);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
function listAllTools() {
|
|
61
|
-
if (tools_1.endpoints.length === 0) {
|
|
62
|
-
console.log('No tools available.');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
console.log('Available tools:\n');
|
|
66
|
-
// Group endpoints by resource
|
|
67
|
-
const resourceGroups = new Map();
|
|
68
|
-
for (const endpoint of tools_1.endpoints) {
|
|
69
|
-
const resource = endpoint.metadata.resource;
|
|
70
|
-
if (!resourceGroups.has(resource)) {
|
|
71
|
-
resourceGroups.set(resource, []);
|
|
72
|
-
}
|
|
73
|
-
resourceGroups.get(resource).push(endpoint);
|
|
74
|
-
}
|
|
75
|
-
// Sort resources alphabetically
|
|
76
|
-
const sortedResources = Array.from(resourceGroups.keys()).sort();
|
|
77
|
-
// Display hierarchically by resource
|
|
78
|
-
for (const resource of sortedResources) {
|
|
79
|
-
console.log(`Resource: ${resource}`);
|
|
80
|
-
const resourceEndpoints = resourceGroups.get(resource);
|
|
81
|
-
// Sort endpoints by tool name
|
|
82
|
-
resourceEndpoints.sort((a, b) => a.tool.name.localeCompare(b.tool.name));
|
|
83
|
-
for (const endpoint of resourceEndpoints) {
|
|
84
|
-
const { tool, metadata: { operation, tags }, } = endpoint;
|
|
85
|
-
console.log(` - ${tool.name} (${operation}) ${tags.length > 0 ? `tags: ${tags.join(', ')}` : ''}`);
|
|
86
|
-
console.log(` Description: ${tool.description}`);
|
|
87
|
-
}
|
|
88
|
-
console.log('');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
59
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";;;AAEA,wCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources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,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,OAAmB;IACnD,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
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { selectTools } from "./server.mjs";
|
|
3
|
-
import { endpoints } from "./tools.mjs";
|
|
4
3
|
import { parseCLIOptions } from "./options.mjs";
|
|
5
4
|
import { launchStdioServer } from "./stdio.mjs";
|
|
6
5
|
import { launchStreamableHTTPServer } from "./http.mjs";
|
|
7
6
|
async function main() {
|
|
8
7
|
const options = parseOptionsOrError();
|
|
9
|
-
|
|
10
|
-
listAllTools();
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const selectedTools = await selectToolsOrError(endpoints, options);
|
|
8
|
+
const selectedTools = await selectToolsOrError(options);
|
|
14
9
|
console.error(`MCP Server starting with ${selectedTools.length} tools:`, selectedTools.map((e) => e.tool.name));
|
|
15
10
|
switch (options.transport) {
|
|
16
11
|
case 'stdio':
|
|
17
12
|
await launchStdioServer(options);
|
|
18
13
|
break;
|
|
19
14
|
case 'http':
|
|
20
|
-
await launchStreamableHTTPServer(
|
|
15
|
+
await launchStreamableHTTPServer({
|
|
16
|
+
mcpOptions: options,
|
|
17
|
+
debug: options.debug,
|
|
18
|
+
port: options.port ?? options.socket,
|
|
19
|
+
});
|
|
21
20
|
break;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
@@ -36,9 +35,9 @@ function parseOptionsOrError() {
|
|
|
36
35
|
process.exit(1);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
async function selectToolsOrError(
|
|
38
|
+
async function selectToolsOrError(options) {
|
|
40
39
|
try {
|
|
41
|
-
const includedTools =
|
|
40
|
+
const includedTools = selectTools(options);
|
|
42
41
|
if (includedTools.length === 0) {
|
|
43
42
|
console.error('No tools match the provided filters.');
|
|
44
43
|
process.exit(1);
|
|
@@ -55,35 +54,4 @@ async function selectToolsOrError(endpoints, options) {
|
|
|
55
54
|
process.exit(1);
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
|
-
function listAllTools() {
|
|
59
|
-
if (endpoints.length === 0) {
|
|
60
|
-
console.log('No tools available.');
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
console.log('Available tools:\n');
|
|
64
|
-
// Group endpoints by resource
|
|
65
|
-
const resourceGroups = new Map();
|
|
66
|
-
for (const endpoint of endpoints) {
|
|
67
|
-
const resource = endpoint.metadata.resource;
|
|
68
|
-
if (!resourceGroups.has(resource)) {
|
|
69
|
-
resourceGroups.set(resource, []);
|
|
70
|
-
}
|
|
71
|
-
resourceGroups.get(resource).push(endpoint);
|
|
72
|
-
}
|
|
73
|
-
// Sort resources alphabetically
|
|
74
|
-
const sortedResources = Array.from(resourceGroups.keys()).sort();
|
|
75
|
-
// Display hierarchically by resource
|
|
76
|
-
for (const resource of sortedResources) {
|
|
77
|
-
console.log(`Resource: ${resource}`);
|
|
78
|
-
const resourceEndpoints = resourceGroups.get(resource);
|
|
79
|
-
// Sort endpoints by tool name
|
|
80
|
-
resourceEndpoints.sort((a, b) => a.tool.name.localeCompare(b.tool.name));
|
|
81
|
-
for (const endpoint of resourceEndpoints) {
|
|
82
|
-
const { tool, metadata: { operation, tags }, } = endpoint;
|
|
83
|
-
console.log(` - ${tool.name} (${operation}) ${tags.length > 0 ? `tags: ${tags.join(', ')}` : ''}`);
|
|
84
|
-
console.log(` Description: ${tool.description}`);
|
|
85
|
-
}
|
|
86
|
-
console.log('');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
57
|
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";OAEO,EAAE,WAAW,EAAE;OACf,
|
|
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,CAAC,OAAO,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,MAAM;YACT,MAAM,0BAA0B,CAAC;gBAC/B,UAAU,EAAE,OAAO;gBACnB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,OA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+1,10 @@
|
|
|
1
|
+
import { McpOptions } from "./options.mjs";
|
|
2
|
+
export type SdkMethod = {
|
|
3
|
+
clientCallName: string;
|
|
4
|
+
fullyQualifiedName: string;
|
|
5
|
+
httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query';
|
|
6
|
+
httpPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const sdkMethods: SdkMethod[];
|
|
9
|
+
export declare function blockedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined;
|
|
10
|
+
//# sourceMappingURL=methods.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.d.mts","sourceRoot":"","sources":["src/methods.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE;AAErB,MAAM,MAAM,SAAS,GAAG;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,SAAS,EAuGjC,CAAC;AA+DF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,EAAE,GAAG,SAAS,CAUlG"}
|
package/methods.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpOptions } from "./options.js";
|
|
2
|
+
export type SdkMethod = {
|
|
3
|
+
clientCallName: string;
|
|
4
|
+
fullyQualifiedName: string;
|
|
5
|
+
httpMethod?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'query';
|
|
6
|
+
httpPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const sdkMethods: SdkMethod[];
|
|
9
|
+
export declare function blockedMethodsForCodeTool(options: McpOptions | undefined): SdkMethod[] | undefined;
|
|
10
|
+
//# sourceMappingURL=methods.d.ts.map
|
package/methods.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["src/methods.ts"],"names":[],"mappings":"OAEO,EAAE,UAAU,EAAE;AAErB,MAAM,MAAM,SAAS,GAAG;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,SAAS,EAuGjC,CAAC;AA+DF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,EAAE,GAAG,SAAS,CAUlG"}
|
package/methods.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
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.sdkMethods = void 0;
|
|
5
|
+
exports.blockedMethodsForCodeTool = blockedMethodsForCodeTool;
|
|
6
|
+
exports.sdkMethods = [
|
|
7
|
+
{
|
|
8
|
+
clientCallName: 'client.credits.check',
|
|
9
|
+
fullyQualifiedName: 'credits.check',
|
|
10
|
+
httpMethod: 'post',
|
|
11
|
+
httpPath: '/credits',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
clientCallName: 'client.logs.create',
|
|
15
|
+
fullyQualifiedName: 'logs.create',
|
|
16
|
+
httpMethod: 'post',
|
|
17
|
+
httpPath: '/logs',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
clientCallName: 'client.logs.getSummary',
|
|
21
|
+
fullyQualifiedName: 'logs.getSummary',
|
|
22
|
+
httpMethod: 'post',
|
|
23
|
+
httpPath: '/logs/summary',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
clientCallName: 'client.accessToken.create',
|
|
27
|
+
fullyQualifiedName: 'accessToken.create',
|
|
28
|
+
httpMethod: 'post',
|
|
29
|
+
httpPath: '/v1/access-token',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
clientCallName: 'client.verifyToken.verify',
|
|
33
|
+
fullyQualifiedName: 'verifyToken.verify',
|
|
34
|
+
httpMethod: 'post',
|
|
35
|
+
httpPath: '/v1/verify-token',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
clientCallName: 'client.camsKfintech.parse',
|
|
39
|
+
fullyQualifiedName: 'camsKfintech.parse',
|
|
40
|
+
httpMethod: 'post',
|
|
41
|
+
httpPath: '/v4/cams_kfintech/parse',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
clientCallName: 'client.cdsl.parsePdf',
|
|
45
|
+
fullyQualifiedName: 'cdsl.parsePdf',
|
|
46
|
+
httpMethod: 'post',
|
|
47
|
+
httpPath: '/v4/cdsl/parse',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
clientCallName: 'client.cdsl.fetch.requestOtp',
|
|
51
|
+
fullyQualifiedName: 'cdsl.fetch.requestOtp',
|
|
52
|
+
httpMethod: 'post',
|
|
53
|
+
httpPath: '/v4/cdsl/fetch',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
clientCallName: 'client.cdsl.fetch.verifyOtp',
|
|
57
|
+
fullyQualifiedName: 'cdsl.fetch.verifyOtp',
|
|
58
|
+
httpMethod: 'post',
|
|
59
|
+
httpPath: '/v4/cdsl/fetch/{session_id}/verify',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
clientCallName: 'client.contractNote.parse',
|
|
63
|
+
fullyQualifiedName: 'contractNote.parse',
|
|
64
|
+
httpMethod: 'post',
|
|
65
|
+
httpPath: '/v4/contract_note/parse',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
clientCallName: 'client.inbox.checkConnectionStatus',
|
|
69
|
+
fullyQualifiedName: 'inbox.checkConnectionStatus',
|
|
70
|
+
httpMethod: 'post',
|
|
71
|
+
httpPath: '/v4/inbox/status',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
clientCallName: 'client.inbox.connectEmail',
|
|
75
|
+
fullyQualifiedName: 'inbox.connectEmail',
|
|
76
|
+
httpMethod: 'post',
|
|
77
|
+
httpPath: '/v4/inbox/connect',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
clientCallName: 'client.inbox.disconnectEmail',
|
|
81
|
+
fullyQualifiedName: 'inbox.disconnectEmail',
|
|
82
|
+
httpMethod: 'post',
|
|
83
|
+
httpPath: '/v4/inbox/disconnect',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
clientCallName: 'client.inbox.listCasFiles',
|
|
87
|
+
fullyQualifiedName: 'inbox.listCasFiles',
|
|
88
|
+
httpMethod: 'post',
|
|
89
|
+
httpPath: '/v4/inbox/cas',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
clientCallName: 'client.kfintech.generateCas',
|
|
93
|
+
fullyQualifiedName: 'kfintech.generateCas',
|
|
94
|
+
httpMethod: 'post',
|
|
95
|
+
httpPath: '/v4/kfintech/generate',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
clientCallName: 'client.nsdl.parse',
|
|
99
|
+
fullyQualifiedName: 'nsdl.parse',
|
|
100
|
+
httpMethod: 'post',
|
|
101
|
+
httpPath: '/v4/nsdl/parse',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
clientCallName: 'client.smart.parseCasPdf',
|
|
105
|
+
fullyQualifiedName: 'smart.parseCasPdf',
|
|
106
|
+
httpMethod: 'post',
|
|
107
|
+
httpPath: '/v4/smart/parse',
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
function allowedMethodsForCodeTool(options) {
|
|
111
|
+
if (!options) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
let allowedMethods;
|
|
115
|
+
if (options.codeAllowHttpGets || options.codeAllowedMethods) {
|
|
116
|
+
// Start with nothing allowed and then add into it from options
|
|
117
|
+
let allowedMethodsSet = new Set();
|
|
118
|
+
if (options.codeAllowHttpGets) {
|
|
119
|
+
// Add all methods that map to an HTTP GET
|
|
120
|
+
exports.sdkMethods
|
|
121
|
+
.filter((method) => method.httpMethod === 'get')
|
|
122
|
+
.forEach((method) => allowedMethodsSet.add(method));
|
|
123
|
+
}
|
|
124
|
+
if (options.codeAllowedMethods) {
|
|
125
|
+
// Add all methods that match any of the allowed regexps
|
|
126
|
+
const allowedRegexps = options.codeAllowedMethods.map((pattern) => {
|
|
127
|
+
try {
|
|
128
|
+
return new RegExp(pattern);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
throw new Error(`Invalid regex pattern for allowed method: "${pattern}": ${e instanceof Error ? e.message : e}`);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
exports.sdkMethods
|
|
135
|
+
.filter((method) => allowedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)))
|
|
136
|
+
.forEach((method) => allowedMethodsSet.add(method));
|
|
137
|
+
}
|
|
138
|
+
allowedMethods = Array.from(allowedMethodsSet);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Start with everything allowed
|
|
142
|
+
allowedMethods = [...exports.sdkMethods];
|
|
143
|
+
}
|
|
144
|
+
if (options.codeBlockedMethods) {
|
|
145
|
+
// Filter down based on blocked regexps
|
|
146
|
+
const blockedRegexps = options.codeBlockedMethods.map((pattern) => {
|
|
147
|
+
try {
|
|
148
|
+
return new RegExp(pattern);
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
throw new Error(`Invalid regex pattern for blocked method: "${pattern}": ${e instanceof Error ? e.message : e}`);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
allowedMethods = allowedMethods.filter((method) => !blockedRegexps.some((regexp) => regexp.test(method.fullyQualifiedName)));
|
|
155
|
+
}
|
|
156
|
+
return allowedMethods;
|
|
157
|
+
}
|
|
158
|
+
function blockedMethodsForCodeTool(options) {
|
|
159
|
+
const allowedMethods = allowedMethodsForCodeTool(options);
|
|
160
|
+
if (!allowedMethods) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
const allowedSet = new Set(allowedMethods.map((method) => method.fullyQualifiedName));
|
|
164
|
+
// Return any methods that are not explicitly allowed
|
|
165
|
+
return exports.sdkMethods.filter((method) => !allowedSet.has(method.fullyQualifiedName));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=methods.js.map
|