@mcp-abap-adt/core 18.1.0 → 19.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +26 -5
  2. package/bin/mcp-abap-adt.js +15 -15
  3. package/dist/StdioServer.d.ts +68 -14
  4. package/dist/StdioServer.d.ts.map +1 -1
  5. package/dist/StdioServer.js +101 -31
  6. package/dist/StdioServer.js.map +1 -1
  7. package/dist/auth/IAuthBrokerFactory.d.ts +62 -0
  8. package/dist/auth/IAuthBrokerFactory.d.ts.map +1 -0
  9. package/dist/auth/IAuthBrokerFactory.js +8 -0
  10. package/dist/auth/IAuthBrokerFactory.js.map +1 -0
  11. package/dist/auth/IAuthBrokerFactoryConfig.d.ts +90 -0
  12. package/dist/auth/IAuthBrokerFactoryConfig.d.ts.map +1 -0
  13. package/dist/auth/IAuthBrokerFactoryConfig.js +8 -0
  14. package/dist/auth/IAuthBrokerFactoryConfig.js.map +1 -0
  15. package/dist/auth/brokerFactory.d.ts +93 -0
  16. package/dist/auth/brokerFactory.d.ts.map +1 -0
  17. package/dist/auth/brokerFactory.js +341 -0
  18. package/dist/auth/brokerFactory.js.map +1 -0
  19. package/dist/auth/browser.d.ts +60 -0
  20. package/dist/auth/browser.d.ts.map +1 -0
  21. package/dist/auth/browser.js +116 -0
  22. package/dist/auth/browser.js.map +1 -0
  23. package/dist/auth/countedProvider.d.ts +43 -0
  24. package/dist/auth/countedProvider.d.ts.map +1 -0
  25. package/dist/auth/countedProvider.js +105 -0
  26. package/dist/auth/countedProvider.js.map +1 -0
  27. package/dist/auth/destinationFailure.d.ts +69 -0
  28. package/dist/auth/destinationFailure.d.ts.map +1 -0
  29. package/dist/auth/destinationFailure.js +183 -0
  30. package/dist/auth/destinationFailure.js.map +1 -0
  31. package/dist/auth/destinationStores.d.ts +55 -0
  32. package/dist/auth/destinationStores.d.ts.map +1 -0
  33. package/dist/auth/destinationStores.js +158 -0
  34. package/dist/auth/destinationStores.js.map +1 -0
  35. package/dist/auth/handlers/basic.d.ts +3 -0
  36. package/dist/auth/handlers/basic.d.ts.map +1 -0
  37. package/dist/auth/handlers/basic.js +8 -0
  38. package/dist/auth/handlers/basic.js.map +1 -0
  39. package/dist/auth/handlers/index.d.ts +15 -0
  40. package/dist/auth/handlers/index.d.ts.map +1 -0
  41. package/dist/auth/handlers/index.js +32 -0
  42. package/dist/auth/handlers/index.js.map +1 -0
  43. package/dist/auth/handlers/jwtAuthorizationCode.d.ts +8 -0
  44. package/dist/auth/handlers/jwtAuthorizationCode.d.ts.map +1 -0
  45. package/dist/auth/handlers/jwtAuthorizationCode.js +32 -0
  46. package/dist/auth/handlers/jwtAuthorizationCode.js.map +1 -0
  47. package/dist/auth/handlers/snc.d.ts +3 -0
  48. package/dist/auth/handlers/snc.d.ts.map +1 -0
  49. package/dist/auth/handlers/snc.js +14 -0
  50. package/dist/auth/handlers/snc.js.map +1 -0
  51. package/dist/auth/handlers/types.d.ts +30 -0
  52. package/dist/auth/handlers/types.d.ts.map +1 -0
  53. package/dist/auth/handlers/types.js +3 -0
  54. package/dist/auth/handlers/types.js.map +1 -0
  55. package/dist/auth/index.d.ts +15 -0
  56. package/dist/auth/index.d.ts.map +1 -0
  57. package/dist/auth/index.js +38 -0
  58. package/dist/auth/index.js.map +1 -0
  59. package/dist/auth/serverLogin.d.ts +75 -0
  60. package/dist/auth/serverLogin.d.ts.map +1 -0
  61. package/dist/auth/serverLogin.js +138 -0
  62. package/dist/auth/serverLogin.js.map +1 -0
  63. package/dist/auth/serverSentences.d.ts +39 -0
  64. package/dist/auth/serverSentences.d.ts.map +1 -0
  65. package/dist/auth/serverSentences.js +49 -0
  66. package/dist/auth/serverSentences.js.map +1 -0
  67. package/dist/auth/vocabulary.d.ts +28 -0
  68. package/dist/auth/vocabulary.d.ts.map +1 -0
  69. package/dist/auth/vocabulary.js +67 -0
  70. package/dist/auth/vocabulary.js.map +1 -0
  71. package/dist/config/coreParameters.d.ts +125 -0
  72. package/dist/config/coreParameters.d.ts.map +1 -0
  73. package/dist/config/coreParameters.js +331 -0
  74. package/dist/config/coreParameters.js.map +1 -0
  75. package/dist/config/envFileContext.d.ts +26 -0
  76. package/dist/config/envFileContext.d.ts.map +1 -0
  77. package/dist/config/envFileContext.js +90 -0
  78. package/dist/config/envFileContext.js.map +1 -0
  79. package/dist/config/envResolver.d.ts +6 -0
  80. package/dist/config/envResolver.d.ts.map +1 -0
  81. package/dist/config/envResolver.js +81 -0
  82. package/dist/config/envResolver.js.map +1 -0
  83. package/dist/config/platformPaths.d.ts +28 -0
  84. package/dist/config/platformPaths.d.ts.map +1 -0
  85. package/dist/config/platformPaths.js +152 -0
  86. package/dist/config/platformPaths.js.map +1 -0
  87. package/dist/destinationSource.d.ts +26 -0
  88. package/dist/destinationSource.d.ts.map +1 -0
  89. package/dist/destinationSource.js +43 -0
  90. package/dist/destinationSource.js.map +1 -0
  91. package/dist/index.d.ts +9 -5
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +16 -11
  94. package/dist/index.js.map +1 -1
  95. package/dist/launcher.d.ts +102 -59
  96. package/dist/launcher.d.ts.map +1 -1
  97. package/dist/launcher.js +419 -286
  98. package/dist/launcher.js.map +1 -1
  99. package/dist/shutdown.d.ts +76 -24
  100. package/dist/shutdown.d.ts.map +1 -1
  101. package/dist/shutdown.js +114 -57
  102. package/dist/shutdown.js.map +1 -1
  103. package/package.json +22 -39
  104. package/dist/InstancePool.d.ts +0 -87
  105. package/dist/InstancePool.d.ts.map +0 -1
  106. package/dist/InstancePool.js +0 -240
  107. package/dist/InstancePool.js.map +0 -1
  108. package/dist/SseServer.d.ts +0 -144
  109. package/dist/SseServer.d.ts.map +0 -1
  110. package/dist/SseServer.js +0 -359
  111. package/dist/SseServer.js.map +0 -1
  112. package/dist/StreamableHttpServer.d.ts +0 -143
  113. package/dist/StreamableHttpServer.d.ts.map +0 -1
  114. package/dist/StreamableHttpServer.js +0 -349
  115. package/dist/StreamableHttpServer.js.map +0 -1
  116. package/dist/destinationRequest.d.ts +0 -38
  117. package/dist/destinationRequest.d.ts.map +0 -1
  118. package/dist/destinationRequest.js +0 -85
  119. package/dist/destinationRequest.js.map +0 -1
  120. package/dist/dnsRebindingProtection.d.ts +0 -21
  121. package/dist/dnsRebindingProtection.d.ts.map +0 -1
  122. package/dist/dnsRebindingProtection.js +0 -45
  123. package/dist/dnsRebindingProtection.js.map +0 -1
  124. package/dist/stateClose.d.ts +0 -8
  125. package/dist/stateClose.d.ts.map +0 -1
  126. package/dist/stateClose.js +0 -14
  127. package/dist/stateClose.js.map +0 -1
  128. package/dist/tlsUtils.d.ts +0 -19
  129. package/dist/tlsUtils.d.ts.map +0 -1
  130. package/dist/tlsUtils.js +0 -77
  131. package/dist/tlsUtils.js.map +0 -1
@@ -1,349 +0,0 @@
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.StreamableHttpServer = void 0;
7
- const auth_1 = require("@mcp-abap-adt/lib/auth");
8
- const embeddable_1 = require("@mcp-abap-adt/lib/embeddable");
9
- const logger_1 = require("@mcp-abap-adt/lib/logger");
10
- const request_context_1 = require("@mcp-abap-adt/lib/request-context");
11
- const state_1 = require("@mcp-abap-adt/lib/state");
12
- const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
13
- const express_1 = __importDefault(require("express"));
14
- const coreVersion_js_1 = require("./coreVersion.js");
15
- const destinationRequest_js_1 = require("./destinationRequest.js");
16
- const dnsRebindingProtection_js_1 = require("./dnsRebindingProtection.js");
17
- const InstancePool_js_1 = require("./InstancePool.js");
18
- const tlsUtils_js_1 = require("./tlsUtils.js");
19
- /**
20
- * Minimal Streamable HTTP server implementation.
21
- * Creates new transport for each HTTP POST and forwards request to the MCP server.
22
- * Destination is taken from x-mcp-destination header or defaultDestination.
23
- *
24
- * Supports two modes:
25
- * 1. Standalone mode: Creates its own Express server (when no app option provided)
26
- * 2. Embedded mode: Registers routes on external app (when app option provided)
27
- */
28
- class StreamableHttpServer extends embeddable_1.BaseMcpServer {
29
- handlersRegistry;
30
- destinations;
31
- host;
32
- port;
33
- enableJsonResponse;
34
- defaultDestination;
35
- path;
36
- externalApp;
37
- version;
38
- standaloneServer;
39
- tls;
40
- allowDestinationHeader;
41
- allowedHosts;
42
- allowedOrigins;
43
- enableDnsRebindingProtection;
44
- /** Per-destination lock around the first connect: it serialises the first login. */
45
- firstConnect = new destinationRequest_js_1.FirstConnectLock();
46
- /** The instances that hold state between requests (spec D9). */
47
- pool = new InstancePool_js_1.InstancePool();
48
- stateIdleMinutes;
49
- stateLogger;
50
- constructor(handlersRegistry,
51
- /** The destinations: settings and the counted provider, nothing else. */
52
- destinations, opts) {
53
- super({
54
- name: 'mcp-abap-adt',
55
- version: opts?.version ?? coreVersion_js_1.CORE_VERSION,
56
- logger: opts?.logger ?? logger_1.noopLogger,
57
- // Validated by the base: a misconfiguration stops the start.
58
- stateIdleMinutes: opts?.stateIdleMinutes,
59
- // From the options as given: the silent default above is never the state's.
60
- stateLogger: (0, state_1.stateLoggerOf)(opts ?? {}),
61
- });
62
- this.handlersRegistry = handlersRegistry;
63
- this.destinations = destinations;
64
- this.stateIdleMinutes = opts?.stateIdleMinutes;
65
- this.stateLogger = (0, state_1.stateLoggerOf)(opts ?? {});
66
- this.version = opts?.version ?? coreVersion_js_1.CORE_VERSION;
67
- this.host = opts?.host ?? '127.0.0.1';
68
- this.port = opts?.port ?? 3000;
69
- this.enableJsonResponse = opts?.enableJsonResponse ?? true;
70
- this.defaultDestination = opts?.defaultDestination;
71
- this.path = opts?.path ?? '/mcp/stream/http';
72
- this.externalApp = opts?.app;
73
- this.tls = opts?.tls;
74
- this.allowDestinationHeader = opts?.allowDestinationHeader ?? false;
75
- this.allowedHosts = opts?.allowedHosts;
76
- this.allowedOrigins = opts?.allowedOrigins;
77
- this.enableDnsRebindingProtection = opts?.enableDnsRebindingProtection;
78
- // Register handlers once for shared MCP server
79
- this.registerHandlers(this.handlersRegistry);
80
- }
81
- /**
82
- * Creates the request handler function
83
- * Can be used to register on external app or internal Express
84
- */
85
- createRequestHandler() {
86
- return async (req, res) => {
87
- const clientId = `${req.socket.remoteAddress}:${req.socket.remotePort}`;
88
- const mcpMethod = req.body?.method;
89
- const mcpId = req.body?.id;
90
- const toolName = mcpMethod === 'tools/call'
91
- ? req.body?.params?.name
92
- : undefined;
93
- const methodInfo = toolName
94
- ? `${mcpMethod} -> ${toolName}`
95
- : (mcpMethod ?? 'unknown');
96
- const isPing = mcpMethod === 'ping';
97
- if (!isPing) {
98
- console.error(`[StreamableHttpServer] ${req.method} ${req.path} from ${clientId} | ${methodInfo} (id=${mcpId ?? '-'})`);
99
- }
100
- try {
101
- let destination;
102
- let fromHeaders = false;
103
- // Priority 1: x-mcp-destination (only with --allow-destination-header),
104
- // refused when it is not a destination name
105
- const destinationHeader = (0, destinationRequest_js_1.destinationFromHeader)(req.headers, this.allowDestinationHeader);
106
- if (destinationHeader !== undefined) {
107
- destination = destinationHeader;
108
- }
109
- // Priority 2: Check SAP connection headers (x-sap-url + auth params)
110
- // The settings and the credential come from the headers, no destination
111
- else if (this.hasSapConnectionHeaders(req.headers)) {
112
- destination = undefined;
113
- fromHeaders = true;
114
- }
115
- // Priority 3: Use default destination
116
- else if (this.defaultDestination) {
117
- destination = this.defaultDestination;
118
- }
119
- // Priority 4: No auth params at all -> reject request
120
- else {
121
- res
122
- .status(400)
123
- .send('Missing SAP connection context. Provide x-mcp-destination header, configure default destination (--mcp/--env-path), or pass x-sap-* headers.');
124
- return;
125
- }
126
- let handle;
127
- try {
128
- handle = (0, InstancePool_js_1.handleOf)(req.body);
129
- }
130
- catch (err) {
131
- if (err instanceof InstancePool_js_1.BatchWithHandleError) {
132
- res.status(400).send(err.message);
133
- return;
134
- }
135
- throw err;
136
- }
137
- const authSource = destination
138
- ? `destination=${destination}`
139
- : fromHeaders
140
- ? 'x-sap-* headers'
141
- : 'none';
142
- if (!isPing) {
143
- console.error(`[StreamableHttpServer] ${methodInfo} | auth: ${authSource}`);
144
- }
145
- await this.pool.serve({ handle }, () => this.createPerRequestServer(), async (server) => {
146
- // A client that left while this request waited for the lease gets nothing.
147
- if (res.destroyed)
148
- return;
149
- const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
150
- sessionIdGenerator: undefined, // stateless mode to avoid ID collisions
151
- enableJsonResponse: this.enableJsonResponse,
152
- });
153
- let transportClosed;
154
- const closeTransport = () => {
155
- transportClosed ??= transport.close().catch(() => undefined);
156
- return transportClosed;
157
- };
158
- const disconnected = new Promise((resolve) => res.once('close', () => {
159
- void closeTransport();
160
- resolve();
161
- }));
162
- try {
163
- // The request's own credentials, every time — also on a kept instance.
164
- if (!isPing && fromHeaders) {
165
- server.setConnectionContextFromHeadersPublic(req.headers);
166
- }
167
- else if (!isPing && destination) {
168
- // Skip SAP connection setup for ping — it's a protocol-level check.
169
- // The first request of a destination connects inside the lock:
170
- // two first logins must not race for the same callback port
171
- const chosen = destination;
172
- await this.firstConnect.run(chosen, () => server.setConnectionContextPublic(chosen, this.destinations), () => server.connectPublic());
173
- }
174
- await server.connect(transport);
175
- // Scope what the request states — x-sap-language, x-sap-responsible,
176
- // x-sap-master-system — to this request's dispatch, so it cannot
177
- // leak into other requests/modes via a process-global cache (#110).
178
- const dispatch = (0, request_context_1.runWithRequestContext)((0, request_context_1.requestContextFromHeaders)(req.headers), () => transport.handleRequest(req, res, req.body));
179
- // JSON mode answers when the handler has; SSE mode when the stream
180
- // ends. A client that disconnects first must not hold the lease on
181
- // a dispatch that waits for a handler.
182
- let failed;
183
- await Promise.race([
184
- dispatch.catch((error) => {
185
- failed = { error };
186
- }),
187
- disconnected,
188
- ]);
189
- // A dispatch that failed is answered below, as before the pool.
190
- if (failed)
191
- throw failed.error;
192
- }
193
- finally {
194
- await closeTransport();
195
- // The instance goes back only when its tool handlers have settled:
196
- // they do not consume the transport's abort signal.
197
- await server.idle();
198
- }
199
- });
200
- if (!isPing) {
201
- console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) completed`);
202
- }
203
- }
204
- catch (err) {
205
- if (err instanceof InstancePool_js_1.PoolClosedError) {
206
- if (!res.headersSent)
207
- res.status(503).send(err.message);
208
- return;
209
- }
210
- const answer = (0, destinationRequest_js_1.destinationFailureAnswer)(err);
211
- if (!answer.known) {
212
- // No words for it: its class only — a message may quote a file (H4).
213
- console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) FAILED: ${(0, auth_1.errorClassOf)(err)}`);
214
- }
215
- else {
216
- console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) FAILED: ${answer.text}`);
217
- }
218
- if (!res.headersSent) {
219
- res.status(answer.status).send(answer.text);
220
- }
221
- }
222
- };
223
- }
224
- /**
225
- * Register routes on an external HTTP application
226
- * Use this when integrating with existing Express/CDS/CAP server
227
- *
228
- * @param app - External HTTP application (Express, CDS, etc.)
229
- * @param options - Route registration options
230
- */
231
- registerRoutes(app, _options) {
232
- const handler = this.createRequestHandler();
233
- // Health check endpoint — lightweight, no MCP protocol logic
234
- app.get('/mcp/health', (_req, res) => {
235
- res.json({
236
- status: 'ok',
237
- uptime: Math.floor(process.uptime()),
238
- version: this.version,
239
- transport: 'http',
240
- });
241
- });
242
- const dnsOpts = {
243
- enable: this.enableDnsRebindingProtection,
244
- allowedHosts: this.allowedHosts,
245
- allowedOrigins: this.allowedOrigins,
246
- };
247
- // Only handle POST requests - GET SSE streams cause abort errors on disconnect
248
- app.post(this.path, (0, dnsRebindingProtection_js_1.withDnsRebindingProtection)(handler, dnsOpts));
249
- // Return 405 for other methods to avoid SSE stream issues
250
- app.all(this.path, (0, dnsRebindingProtection_js_1.withDnsRebindingProtection)((_req, res) => {
251
- res.status(405).send('Method Not Allowed');
252
- }, dnsOpts));
253
- console.error(`[StreamableHttpServer] Routes registered on external app at ${this.path}`);
254
- console.error(`[StreamableHttpServer] JSON response mode: ${this.enableJsonResponse}`);
255
- if (this.defaultDestination) {
256
- console.error(`[StreamableHttpServer] Default destination: ${this.defaultDestination}`);
257
- }
258
- }
259
- /**
260
- * Get the configured endpoint path
261
- */
262
- getPath() {
263
- return this.path;
264
- }
265
- /**
266
- * Start the server
267
- *
268
- * In standalone mode (no external app): Creates Express server and starts listening
269
- * In embedded mode (external app provided): Only registers routes on external app
270
- */
271
- async start() {
272
- // If external app was provided in constructor, register routes on it
273
- if (this.externalApp) {
274
- this.registerRoutes(this.externalApp);
275
- return;
276
- }
277
- // Standalone mode: create own Express server
278
- const app = (0, express_1.default)();
279
- app.use(express_1.default.json());
280
- this.registerRoutes(app);
281
- await new Promise((resolve, reject) => {
282
- const protocol = (0, tlsUtils_js_1.getProtocol)(this.tls);
283
- const server = (0, tlsUtils_js_1.createServerListener)(app, this.tls);
284
- this.standaloneServer = server;
285
- server.listen(this.port, this.host);
286
- server.once('listening', () => {
287
- console.error(`[StreamableHttpServer] Server started on ${this.host}:${this.port}`);
288
- console.error(`[StreamableHttpServer] Endpoint: ${protocol}://${this.host}:${this.port}${this.path}`);
289
- resolve();
290
- });
291
- server.once('error', reject);
292
- });
293
- }
294
- /**
295
- * Stops taking connections (shutdown, step 1), then the pool: no request is
296
- * admitted any more, the running ones finish, every instance that holds
297
- * state is disposed and waited for (no timer). Rejects with what could not
298
- * be undone. Embedded on an external app, there is no listener of its own
299
- * to stop, but the pool is still ours to drain.
300
- */
301
- async stop() {
302
- const server = this.standaloneServer;
303
- if (server) {
304
- this.standaloneServer = undefined;
305
- server.close();
306
- server.closeIdleConnections();
307
- }
308
- const failures = await this.pool.shutdown();
309
- if (failures.length) {
310
- throw new Error(`state cleanup failed: ${failures.join('; ')}`);
311
- }
312
- }
313
- /**
314
- * Check if request has SAP connection headers
315
- */
316
- hasSapConnectionHeaders(headers) {
317
- const hasUrl = headers['x-sap-url'] || headers['X-SAP-URL'];
318
- const hasJwtAuth = headers['x-sap-jwt-token'] || headers['X-SAP-JWT-Token'];
319
- const hasBasicAuth = (headers['x-sap-login'] || headers['X-SAP-Login']) &&
320
- (headers['x-sap-password'] || headers['X-SAP-Password']);
321
- return !!(hasUrl && (hasJwtAuth || hasBasicAuth));
322
- }
323
- createPerRequestServer() {
324
- class PerRequestServer extends embeddable_1.BaseMcpServer {
325
- registry;
326
- constructor(registry, version, logger, state) {
327
- super({ name: 'mcp-abap-adt', version, logger, ...state });
328
- this.registry = registry;
329
- this.registerHandlers(this.registry);
330
- }
331
- setConnectionContextPublic(destination, destinations) {
332
- return this.setConnectionContext(destination, destinations);
333
- }
334
- /** The context's connection, connected (cached for this request). */
335
- connectPublic() {
336
- return this.getConnection();
337
- }
338
- setConnectionContextFromHeadersPublic(headers) {
339
- this.setConnectionContextFromHeaders(headers);
340
- }
341
- }
342
- return new PerRequestServer(this.handlersRegistry, this.version, this.logger, {
343
- stateIdleMinutes: this.stateIdleMinutes,
344
- stateLogger: this.stateLogger,
345
- });
346
- }
347
- }
348
- exports.StreamableHttpServer = StreamableHttpServer;
349
- //# sourceMappingURL=StreamableHttpServer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StreamableHttpServer.js","sourceRoot":"","sources":["../src/StreamableHttpServer.ts"],"names":[],"mappings":";;;;;;AAEA,iDAA0E;AAM1E,6DAA6D;AAE7D,qDAAsD;AACtD,uEAG2C;AAC3C,mDAA0E;AAE1E,0FAAmG;AACnG,sDAA+D;AAC/D,qDAAgD;AAChD,mEAIiC;AACjC,2EAAyE;AACzE,uDAM2B;AAC3B,+CAAkE;AA+ElE;;;;;;;;GAQG;AACH,MAAa,oBAAqB,SAAQ,0BAAa;IAsBlC;IAEA;IAvBF,IAAI,CAAS;IACb,IAAI,CAAS;IACb,kBAAkB,CAAU;IAC5B,kBAAkB,CAAU;IAC5B,IAAI,CAAS;IACb,WAAW,CAAoB;IAC/B,OAAO,CAAS;IACzB,gBAAgB,CAA4B;IACnC,GAAG,CAAa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B,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,MAAM,EACX;YACE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CACF,CAAC;IACJ,CAAC;CACF;AAtZD,oDAsZC"}
@@ -1,38 +0,0 @@
1
- /**
2
- * What the HTTP and SSE transports share about a request's destination:
3
- * reading `x-mcp-destination`, and answering a destination that fails.
4
- */
5
- /** `x-mcp-destination` is not a destination name. Its message names the header, never the value. */
6
- export declare class DestinationHeaderError extends Error {
7
- constructor(message: string);
8
- }
9
- /**
10
- * The destination `x-mcp-destination` names — only when the server allows
11
- * the header, and only when the value is a name, not a path. Checked here,
12
- * before anything is looked up for it.
13
- */
14
- export declare function destinationFromHeader(headers: Record<string, string | string[] | undefined>, allowDestinationHeader: boolean): string | undefined;
15
- /**
16
- * How a request whose destination failed is answered: a refused header is
17
- * the client's (400); an authentication error the server knows is answered
18
- * in its own words (`describeAuthError`: field names and vetted vocabulary
19
- * only); anything else as before, without its message.
20
- */
21
- export declare function destinationFailureAnswer(error: unknown): {
22
- status: number;
23
- text: string;
24
- /** Whether the text is the error's own vetted words. */
25
- known: boolean;
26
- };
27
- /**
28
- * Per destination, one request at a time sets its connection context, and
29
- * the first one also connects — presents the credential, which is the first
30
- * login — before the next starts. Two first logins never run at once.
31
- * A failed first connect leaves the next request to connect again.
32
- */
33
- export declare class FirstConnectLock {
34
- private readonly queues;
35
- private readonly connected;
36
- run(destination: string, setContext: () => Promise<void>, connect: () => Promise<unknown>): Promise<void>;
37
- }
38
- //# sourceMappingURL=destinationRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationRequest.d.ts","sourceRoot":"","sources":["../src/destinationRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,oGAAoG;AACpG,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,EACtD,sBAAsB,EAAE,OAAO,GAC9B,MAAM,GAAG,SAAS,CAapB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,KAAK,EAAE,OAAO,CAAC;CAChB,CAOA;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C,GAAG,CACD,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;CAoBjB"}
@@ -1,85 +0,0 @@
1
- "use strict";
2
- /**
3
- * What the HTTP and SSE transports share about a request's destination:
4
- * reading `x-mcp-destination`, and answering a destination that fails.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FirstConnectLock = exports.DestinationHeaderError = void 0;
8
- exports.destinationFromHeader = destinationFromHeader;
9
- exports.destinationFailureAnswer = destinationFailureAnswer;
10
- const auth_1 = require("@mcp-abap-adt/lib/auth");
11
- /** `x-mcp-destination` is not a destination name. Its message names the header, never the value. */
12
- class DestinationHeaderError extends Error {
13
- constructor(message) {
14
- super(message);
15
- this.name = 'DestinationHeaderError';
16
- }
17
- }
18
- exports.DestinationHeaderError = DestinationHeaderError;
19
- /**
20
- * The destination `x-mcp-destination` names — only when the server allows
21
- * the header, and only when the value is a name, not a path. Checked here,
22
- * before anything is looked up for it.
23
- */
24
- function destinationFromHeader(headers, allowDestinationHeader) {
25
- if (!allowDestinationHeader)
26
- return undefined;
27
- const raw = headers['x-mcp-destination'];
28
- if (raw === undefined)
29
- return undefined;
30
- const value = Array.isArray(raw) ? (raw[0] ?? '') : raw;
31
- try {
32
- (0, auth_1.assertDestinationName)(value, 'x-mcp-destination');
33
- }
34
- catch (error) {
35
- throw new DestinationHeaderError(error instanceof Error ? error.message : 'x-mcp-destination: refused.');
36
- }
37
- return value;
38
- }
39
- /**
40
- * How a request whose destination failed is answered: a refused header is
41
- * the client's (400); an authentication error the server knows is answered
42
- * in its own words (`describeAuthError`: field names and vetted vocabulary
43
- * only); anything else as before, without its message.
44
- */
45
- function destinationFailureAnswer(error) {
46
- if (error instanceof DestinationHeaderError) {
47
- return { status: 400, text: error.message, known: true };
48
- }
49
- const words = (0, auth_1.describeAuthError)(error);
50
- if (words !== undefined)
51
- return { status: 500, text: words, known: true };
52
- return { status: 500, text: 'Internal Server Error', known: false };
53
- }
54
- /**
55
- * Per destination, one request at a time sets its connection context, and
56
- * the first one also connects — presents the credential, which is the first
57
- * login — before the next starts. Two first logins never run at once.
58
- * A failed first connect leaves the next request to connect again.
59
- */
60
- class FirstConnectLock {
61
- queues = new Map();
62
- connected = new Set();
63
- run(destination, setContext, connect) {
64
- const previous = this.queues.get(destination) ?? Promise.resolve();
65
- const work = previous
66
- .catch(() => { })
67
- .then(async () => {
68
- await setContext();
69
- if (!this.connected.has(destination)) {
70
- await connect();
71
- this.connected.add(destination);
72
- }
73
- });
74
- const settled = work.finally(() => {
75
- if (this.queues.get(destination) === settled) {
76
- this.queues.delete(destination);
77
- }
78
- });
79
- // Set before any await: the next request queues behind this one.
80
- this.queues.set(destination, settled);
81
- return settled;
82
- }
83
- }
84
- exports.FirstConnectLock = FirstConnectLock;
85
- //# sourceMappingURL=destinationRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destinationRequest.js","sourceRoot":"","sources":["../src/destinationRequest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoBH,sDAgBC;AAQD,4DAYC;AAtDD,iDAGgC;AAEhC,oGAA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E,CAAC;IAC1E,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,MAAa,gBAAgB;IACV,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC1C,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/C,GAAG,CACD,WAAmB,EACnB,UAA+B,EAC/B,OAA+B;QAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACnE,MAAM,IAAI,GAAG,QAAQ;aAClB,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;aACf,IAAI,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,UAAU,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACrC,MAAM,OAAO,EAAE,CAAC;gBAChB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,OAAO,EAAE,CAAC;gBAC7C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,iEAAiE;QACjE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5BD,4CA4BC"}
@@ -1,21 +0,0 @@
1
- import type { NextFunction, Request, Response } from 'express';
2
- export interface DnsRebindingOptions {
3
- enable?: boolean;
4
- /** Exact raw Host header values, including port (e.g. "localhost:3000"). */
5
- allowedHosts?: string[];
6
- /** Exact raw Origin header values, including scheme (e.g. "https://app.example.com"). */
7
- allowedOrigins?: string[];
8
- }
9
- type RouteHandler = (req: Request, res: Response, next?: NextFunction) => void | Promise<void>;
10
- /** Returns a 403 descriptor if the request must be rejected, else null. */
11
- export declare function checkDnsRebinding(headers: {
12
- host?: string;
13
- origin?: string;
14
- }, opts: DnsRebindingOptions): {
15
- status: number;
16
- body: unknown;
17
- } | null;
18
- /** Wrap an MCP route handler so it validates Host/Origin before delegating. */
19
- export declare function withDnsRebindingProtection(handler: RouteHandler, opts: DnsRebindingOptions): RouteHandler;
20
- export {};
21
- //# sourceMappingURL=dnsRebindingProtection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dnsRebindingProtection.d.ts","sourceRoot":"","sources":["../src/dnsRebindingProtection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,yFAAyF;IACzF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,KAAK,YAAY,GAAG,CAClB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,CAAC,EAAE,YAAY,KAChB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAS1B,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3C,IAAI,EAAE,mBAAmB,GACxB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAiB1C;AAED,+EAA+E;AAC/E,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,mBAAmB,GACxB,YAAY,CAed"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkDnsRebinding = checkDnsRebinding;
4
- exports.withDnsRebindingProtection = withDnsRebindingProtection;
5
- function reject(message) {
6
- return {
7
- status: 403,
8
- body: { jsonrpc: '2.0', error: { code: -32000, message }, id: null },
9
- };
10
- }
11
- /** Returns a 403 descriptor if the request must be rejected, else null. */
12
- function checkDnsRebinding(headers, opts) {
13
- if (opts.enable !== true)
14
- return null;
15
- const hosts = opts.allowedHosts ?? [];
16
- const origins = opts.allowedOrigins ?? [];
17
- if (hosts.length > 0) {
18
- const host = headers.host;
19
- if (!host || !hosts.includes(host)) {
20
- return reject(`Invalid Host header: ${host ?? ''}`);
21
- }
22
- }
23
- if (origins.length > 0) {
24
- const origin = headers.origin;
25
- if (origin && !origins.includes(origin)) {
26
- return reject(`Invalid Origin header: ${origin}`);
27
- }
28
- }
29
- return null;
30
- }
31
- /** Wrap an MCP route handler so it validates Host/Origin before delegating. */
32
- function withDnsRebindingProtection(handler, opts) {
33
- return (req, res, next) => {
34
- const rejection = checkDnsRebinding({
35
- host: req.headers?.host,
36
- origin: req.headers?.origin,
37
- }, opts);
38
- if (rejection) {
39
- res.status(rejection.status).json(rejection.body);
40
- return;
41
- }
42
- return handler(req, res, next);
43
- };
44
- }
45
- //# sourceMappingURL=dnsRebindingProtection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dnsRebindingProtection.js","sourceRoot":"","sources":["../src/dnsRebindingProtection.ts"],"names":[],"mappings":";;AAwBA,8CAoBC;AAGD,gEAkBC;AAjDD,SAAS,MAAM,CAAC,OAAe;IAC7B,OAAO;QACL,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,E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AC;YACd,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * What a host awaits before it lets an instance go: the state is disposed,
3
- * and what could not be undone is raised, never swallowed. No timer.
4
- */
5
- export declare function closeInstanceState(instance: {
6
- shutdownState(): Promise<string[]>;
7
- }): Promise<void>;
8
- //# sourceMappingURL=stateClose.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateClose.d.ts","sourceRoot":"","sources":["../src/stateClose.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE;IACjD,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhB"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.closeInstanceState = closeInstanceState;
4
- /**
5
- * What a host awaits before it lets an instance go: the state is disposed,
6
- * and what could not be undone is raised, never swallowed. No timer.
7
- */
8
- async function closeInstanceState(instance) {
9
- const left = await instance.shutdownState();
10
- if (left.length) {
11
- throw new Error(`state cleanup failed: ${left.join('; ')}`);
12
- }
13
- }
14
- //# sourceMappingURL=stateClose.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateClose.js","sourceRoot":"","sources":["../src/stateClose.ts"],"names":[],"mappings":";;AAIA,gDAOC;AAXD;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CAAC,QAExC;IACC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,CAAC;IAC5C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
@@ -1,19 +0,0 @@
1
- import * as http from 'node:http';
2
- import * as https from 'node:https';
3
- import type { TlsConfig } from '@mcp-abap-adt/lib/config';
4
- /**
5
- * Create HTTP or HTTPS server based on TLS configuration.
6
- *
7
- * When `tls` is provided with cert + key paths, creates an HTTPS server.
8
- * Otherwise creates a plain HTTP server.
9
- *
10
- * @param app - Express application (or any http.RequestListener)
11
- * @param tls - Optional TLS configuration with file paths
12
- * @returns http.Server or https.Server
13
- */
14
- export declare function createServerListener(app: http.RequestListener, tls?: TlsConfig): http.Server | https.Server;
15
- /**
16
- * Returns the protocol string based on TLS configuration.
17
- */
18
- export declare function getProtocol(tls?: TlsConfig): 'https' | 'http';
19
- //# sourceMappingURL=tlsUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tlsUtils.d.ts","sourceRoot":"","sources":["../src/tlsUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,CAAC,EAAE,SAAS,GACd,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAsB5B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAE7D"}