@mcp-abap-adt/http 0.0.0-stage → 19.0.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.
@@ -0,0 +1,160 @@
1
+ import type { TlsConfig } from '@mcp-abap-adt/lib/config';
2
+ import type { IHttpApplication, RouteRegistrationOptions } from '@mcp-abap-adt/lib/embeddable';
3
+ import { BaseMcpServer, type IBackgroundRuns } from '@mcp-abap-adt/lib/embeddable';
4
+ import type { IHandlersRegistry } from '@mcp-abap-adt/lib/handlers';
5
+ import { type StateLogger } from '@mcp-abap-adt/lib/state';
6
+ import type { Logger } from '@mcp-abap-adt/logger';
7
+ export interface StreamableHttpServerOptions {
8
+ /**
9
+ * The idle bound on held state, in minutes: each instance's state ends
10
+ * after this long without a tool call. At least 30; default 30.
11
+ */
12
+ stateIdleMinutes?: number;
13
+ /** Where the state's lifecycle lines go; default stderr, always on. */
14
+ stateLogger?: StateLogger;
15
+ /**
16
+ * Batch mode: each pooled instance (`createPerRequestServer`) gets an
17
+ * `InstanceBatch` of its own, created with these settings (the
18
+ * launcher's). Absent: no instance has one, and the batch tools answer
19
+ * `batch_mode_unavailable`.
20
+ */
21
+ batch?: {
22
+ keepRawParts: boolean;
23
+ };
24
+ /**
25
+ * Host to bind to (only used when no external app is provided)
26
+ * @default "127.0.0.1"
27
+ */
28
+ host?: string;
29
+ /**
30
+ * Port to listen on (only used when no external app is provided)
31
+ * @default 3000
32
+ */
33
+ port?: number;
34
+ /**
35
+ * Whether to return JSON responses (vs SSE streams)
36
+ * @default true
37
+ */
38
+ enableJsonResponse?: boolean;
39
+ /**
40
+ * Path for the MCP endpoint
41
+ * @default "/mcp/stream/http"
42
+ */
43
+ path?: string;
44
+ /**
45
+ * Logger instance
46
+ */
47
+ logger?: Logger;
48
+ /**
49
+ * Server version
50
+ */
51
+ version?: string;
52
+ /**
53
+ * External HTTP application to register routes on
54
+ * When provided, start() will only register routes without creating a server
55
+ * This enables integration with existing Express/CDS/CAP servers
56
+ */
57
+ app?: IHttpApplication;
58
+ /**
59
+ * TLS configuration for HTTPS support
60
+ */
61
+ tls?: TlsConfig;
62
+ /** Allowed Host header values (DNS-rebinding protection; exact, incl. port) */
63
+ allowedHosts?: string[];
64
+ /** Allowed Origin header values (DNS-rebinding protection; exact, incl. scheme) */
65
+ allowedOrigins?: string[];
66
+ /** Enable DNS-rebinding protection (requires allowedHosts and/or allowedOrigins) */
67
+ enableDnsRebindingProtection?: boolean;
68
+ /**
69
+ * Where background runs and their answers are kept, handed to every
70
+ * instance (the launcher's `InMemoryBackgroundRuns` of
71
+ * `@mcp-abap-adt/background-runs-memory`). Absent:
72
+ * `background: true` is refused.
73
+ */
74
+ backgroundRuns?: IBackgroundRuns;
75
+ }
76
+ /**
77
+ * The Streamable HTTP server. Each HTTP POST is an MCP session of its own, on
78
+ * a new server instance or the pooled one its `state_handle` names.
79
+ * Credentials come only from each request's `x-sap-*` headers, through
80
+ * lib's `headerSource`: nothing is stored, shared or cached across requests,
81
+ * except the connections held state opened. A request without them is
82
+ * answered `400` (`ping` excepted), and so is one carrying
83
+ * `x-mcp-destination` — destinations are core's (stdio).
84
+ *
85
+ * Supports two modes:
86
+ * 1. Standalone mode: Creates its own Express server (when no app option provided)
87
+ * 2. Embedded mode: Registers routes on external app (when app option provided)
88
+ */
89
+ export declare class StreamableHttpServer extends BaseMcpServer {
90
+ private readonly handlersRegistry;
91
+ private readonly host;
92
+ private readonly port;
93
+ private readonly enableJsonResponse;
94
+ private readonly path;
95
+ private readonly externalApp?;
96
+ private readonly version;
97
+ private standaloneServer?;
98
+ /** The listener stopped, until its last connections are closed after the last step. */
99
+ private stoppedListener?;
100
+ private readonly tls?;
101
+ private readonly allowedHosts?;
102
+ private readonly allowedOrigins?;
103
+ private readonly enableDnsRebindingProtection?;
104
+ /** The instances that hold state between requests (spec D9). */
105
+ private readonly pool;
106
+ private readonly stateIdleMinutes?;
107
+ private readonly stateLogger;
108
+ private readonly backgroundRunsStore;
109
+ private readonly batchSettings;
110
+ constructor(handlersRegistry: IHandlersRegistry, opts?: StreamableHttpServerOptions);
111
+ /**
112
+ * Creates the request handler function
113
+ * Can be used to register on external app or internal Express
114
+ */
115
+ private createRequestHandler;
116
+ /**
117
+ * Register routes on an external HTTP application
118
+ * Use this when integrating with existing Express/CDS/CAP server
119
+ *
120
+ * @param app - External HTTP application (Express, CDS, etc.)
121
+ * @param options - Route registration options
122
+ */
123
+ registerRoutes(app: IHttpApplication, _options?: RouteRegistrationOptions): void;
124
+ /**
125
+ * Get the configured endpoint path
126
+ */
127
+ getPath(): string;
128
+ /**
129
+ * Start the server
130
+ *
131
+ * In standalone mode (no external app): Creates Express server and starts listening
132
+ * In embedded mode (external app provided): Only registers routes on external app
133
+ */
134
+ start(): Promise<void>;
135
+ /**
136
+ * The shutdown's first step, in the latch's tick: the pool stops
137
+ * admitting — every later request is answered `503`.
138
+ */
139
+ beginShutdown(): void;
140
+ /** Stops taking connections. Embedded on an external app there is no listener of its own. */
141
+ stopListening(): void;
142
+ /**
143
+ * The launcher's shutdown, after the logoffs (lib's
144
+ * `installTransportShutdown`), and `stop()`: nothing is answered any more —
145
+ * the connections still open on the stopped listener (a request whose tool
146
+ * was interrupted, a client's idle keep-alive) are closed, so none keeps
147
+ * the process alive.
148
+ */
149
+ releaseConnections(): void;
150
+ /**
151
+ * For a host that stops the server itself (embedded): admission stops, the
152
+ * listener closes, then the pool's shutdown (no timer). Rejects with what
153
+ * could not be undone. A launcher's shutdown does not run this: it logs
154
+ * every owned connection off at once and interrupts the running tools
155
+ * (lib's `installTransportShutdown`).
156
+ */
157
+ stop(): Promise<void>;
158
+ private createPerRequestServer;
159
+ }
160
+ //# sourceMappingURL=StreamableHttpServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamableHttpServer.d.ts","sourceRoot":"","sources":["../src/StreamableHttpServer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CA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;;;;;;OAMG;IACH,kBAAkB,IAAI,IAAI;IAK1B;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,OAAO,CAAC,sBAAsB;CAqE/B"}
@@ -0,0 +1,403 @@
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 http_transport_1 = require("@mcp-abap-adt/lib/http-transport");
10
+ const logger_1 = require("@mcp-abap-adt/lib/logger");
11
+ const request_context_1 = require("@mcp-abap-adt/lib/request-context");
12
+ const state_1 = require("@mcp-abap-adt/lib/state");
13
+ const responsible_rules_1 = require("@mcp-abap-adt/responsible-rules");
14
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
15
+ const express_1 = __importDefault(require("express"));
16
+ const httpVersion_js_1 = require("./httpVersion.js");
17
+ const InstancePool_js_1 = require("./InstancePool.js");
18
+ /** Whether a request body is, or holds, a `tools/call`: a JSON-RPC batch counts by its elements. */
19
+ function carriesToolCall(body) {
20
+ const isCall = (m) => m?.method === 'tools/call';
21
+ return Array.isArray(body) ? body.some(isCall) : isCall(body);
22
+ }
23
+ /** One tool error per request (an element with an id), in the body's shape; none: nothing to answer. */
24
+ function notAvailableAnswers(body) {
25
+ const answerOf = (m) => {
26
+ const id = m?.id;
27
+ return id === undefined
28
+ ? undefined
29
+ : {
30
+ jsonrpc: '2.0',
31
+ id,
32
+ result: {
33
+ content: [{ type: 'text', text: state_1.STATE_UNAVAILABLE_WORDS }],
34
+ isError: true,
35
+ },
36
+ };
37
+ };
38
+ if (!Array.isArray(body))
39
+ return answerOf(body);
40
+ const answers = body.map(answerOf).filter((a) => a !== undefined);
41
+ return answers.length > 0 ? answers : undefined;
42
+ }
43
+ /**
44
+ * The Streamable HTTP server. Each HTTP POST is an MCP session of its own, on
45
+ * a new server instance or the pooled one its `state_handle` names.
46
+ * Credentials come only from each request's `x-sap-*` headers, through
47
+ * lib's `headerSource`: nothing is stored, shared or cached across requests,
48
+ * except the connections held state opened. A request without them is
49
+ * answered `400` (`ping` excepted), and so is one carrying
50
+ * `x-mcp-destination` — destinations are core's (stdio).
51
+ *
52
+ * Supports two modes:
53
+ * 1. Standalone mode: Creates its own Express server (when no app option provided)
54
+ * 2. Embedded mode: Registers routes on external app (when app option provided)
55
+ */
56
+ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
57
+ handlersRegistry;
58
+ host;
59
+ port;
60
+ enableJsonResponse;
61
+ path;
62
+ externalApp;
63
+ version;
64
+ standaloneServer;
65
+ /** The listener stopped, until its last connections are closed after the last step. */
66
+ stoppedListener;
67
+ tls;
68
+ allowedHosts;
69
+ allowedOrigins;
70
+ enableDnsRebindingProtection;
71
+ /** The instances that hold state between requests (spec D9). */
72
+ pool = new InstancePool_js_1.InstancePool();
73
+ stateIdleMinutes;
74
+ stateLogger;
75
+ backgroundRunsStore;
76
+ batchSettings;
77
+ constructor(handlersRegistry, opts) {
78
+ super({
79
+ name: 'mcp-abap-adt',
80
+ version: opts?.version ?? httpVersion_js_1.HTTP_VERSION,
81
+ logger: opts?.logger ?? logger_1.noopLogger,
82
+ // Validated by the base: a misconfiguration stops the start.
83
+ stateIdleMinutes: opts?.stateIdleMinutes,
84
+ // From the options as given: the silent default above is never the state's.
85
+ stateLogger: (0, state_1.stateLoggerOf)(opts ?? {}),
86
+ // The responsible rules, once per connection, when it is created.
87
+ systemContextResolver: request_context_1.defaultSystemContextResolver,
88
+ systemContextRules: responsible_rules_1.responsibleRules,
89
+ });
90
+ this.handlersRegistry = handlersRegistry;
91
+ this.stateIdleMinutes = opts?.stateIdleMinutes;
92
+ this.stateLogger = (0, state_1.stateLoggerOf)(opts ?? {});
93
+ this.backgroundRunsStore = opts?.backgroundRuns;
94
+ this.batchSettings =
95
+ opts?.batch === undefined
96
+ ? undefined
97
+ : { keepRawParts: opts.batch.keepRawParts === true };
98
+ this.version = opts?.version ?? httpVersion_js_1.HTTP_VERSION;
99
+ this.host = opts?.host ?? '127.0.0.1';
100
+ this.port = opts?.port ?? 3000;
101
+ this.enableJsonResponse = opts?.enableJsonResponse ?? true;
102
+ this.path = opts?.path ?? '/mcp/stream/http';
103
+ this.externalApp = opts?.app;
104
+ this.tls = opts?.tls;
105
+ this.allowedHosts = opts?.allowedHosts;
106
+ this.allowedOrigins = opts?.allowedOrigins;
107
+ this.enableDnsRebindingProtection = opts?.enableDnsRebindingProtection;
108
+ // Register handlers once for shared MCP server
109
+ this.registerHandlers(this.handlersRegistry);
110
+ }
111
+ /**
112
+ * Creates the request handler function
113
+ * Can be used to register on external app or internal Express
114
+ */
115
+ createRequestHandler() {
116
+ return async (req, res) => {
117
+ const clientId = `${req.socket.remoteAddress}:${req.socket.remotePort}`;
118
+ const mcpMethod = req.body?.method;
119
+ const mcpId = req.body?.id;
120
+ const toolName = mcpMethod === 'tools/call'
121
+ ? req.body?.params?.name
122
+ : undefined;
123
+ const methodInfo = toolName
124
+ ? `${mcpMethod} -> ${toolName}`
125
+ : (mcpMethod ?? 'unknown');
126
+ const isPing = mcpMethod === 'ping';
127
+ if (!isPing) {
128
+ console.error(`[StreamableHttpServer] ${req.method} ${req.path} from ${clientId} | ${methodInfo} (id=${mcpId ?? '-'})`);
129
+ }
130
+ try {
131
+ // A header this server no longer serves is refused, never ignored.
132
+ (0, http_transport_1.refuseDestinationHeader)(req.headers);
133
+ // The request's own source, from its x-sap-* headers alone; `ping`
134
+ // is a protocol-level check and answers without them.
135
+ const context = isPing ? undefined : (0, http_transport_1.headerContext)(req.headers);
136
+ // The handle: the `x-mcp-state-handle` header first, else the
137
+ // `tools/call` argument. A bearer value: never logged.
138
+ let handle;
139
+ try {
140
+ handle = (0, InstancePool_js_1.handleFrom)(req.headers, req.body);
141
+ }
142
+ catch (err) {
143
+ if (err instanceof InstancePool_js_1.BatchWithHandleError) {
144
+ res.status(400).send(InstancePool_js_1.BATCH_WITH_HANDLE_WORDS);
145
+ return;
146
+ }
147
+ throw err;
148
+ }
149
+ if (!isPing) {
150
+ console.error(`[StreamableHttpServer] ${methodInfo} | auth: x-sap-* headers`);
151
+ }
152
+ await this.pool.serve({ handle, refuseUnknown: carriesToolCall(req.body) }, () => this.createPerRequestServer(), async (server) => {
153
+ // A client that left while this request waited for the lease gets nothing.
154
+ if (res.destroyed)
155
+ return;
156
+ const transport = new streamableHttp_js_1.StreamableHTTPServerTransport({
157
+ sessionIdGenerator: undefined, // stateless mode to avoid ID collisions
158
+ enableJsonResponse: this.enableJsonResponse,
159
+ });
160
+ let transportClosed;
161
+ const closeTransport = () => {
162
+ transportClosed ??= transport.close().catch(() => undefined);
163
+ return transportClosed;
164
+ };
165
+ const disconnected = new Promise((resolve) => res.once('close', () => {
166
+ void closeTransport();
167
+ resolve();
168
+ }));
169
+ try {
170
+ // The request's own credentials, every time — also on a kept
171
+ // instance: its tool calls build their connections from them.
172
+ if (context)
173
+ server.useConnectionContext(context);
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(InstancePool_js_1.POOL_CLOSED_WORDS);
208
+ return;
209
+ }
210
+ // A tool call whose handle names no state: the pool's answer, as a
211
+ // tool's — no instance was made, nothing logged on.
212
+ if (err instanceof state_1.StateUnavailableError) {
213
+ if (!res.headersSent) {
214
+ const answered = notAvailableAnswers(req.body);
215
+ if (answered === undefined)
216
+ res.status(202).end();
217
+ else
218
+ res.status(200).json(answered);
219
+ }
220
+ return;
221
+ }
222
+ const answer = (0, http_transport_1.requestFailureAnswer)(err);
223
+ if (answer.logLine !== undefined)
224
+ console.error(answer.logLine);
225
+ if (!answer.known) {
226
+ // No words for it: its class only — a message may quote a file (H4).
227
+ console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) FAILED: ${(0, auth_1.errorClassOf)(err)}`);
228
+ }
229
+ else {
230
+ console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) FAILED: ${answer.text}`);
231
+ }
232
+ if (!res.headersSent) {
233
+ res.status(answer.status).send(answer.text);
234
+ }
235
+ }
236
+ };
237
+ }
238
+ /**
239
+ * Register routes on an external HTTP application
240
+ * Use this when integrating with existing Express/CDS/CAP server
241
+ *
242
+ * @param app - External HTTP application (Express, CDS, etc.)
243
+ * @param options - Route registration options
244
+ */
245
+ registerRoutes(app, _options) {
246
+ const handler = this.createRequestHandler();
247
+ // Health check endpoint — lightweight, no MCP protocol logic
248
+ app.get('/mcp/health', (_req, res) => {
249
+ res.json({
250
+ status: 'ok',
251
+ uptime: Math.floor(process.uptime()),
252
+ version: this.version,
253
+ transport: 'http',
254
+ });
255
+ });
256
+ const dnsOpts = {
257
+ enable: this.enableDnsRebindingProtection,
258
+ allowedHosts: this.allowedHosts,
259
+ allowedOrigins: this.allowedOrigins,
260
+ };
261
+ // Only handle POST requests - GET SSE streams cause abort errors on disconnect
262
+ app.post(this.path, (0, http_transport_1.withDnsRebindingProtection)(handler, dnsOpts));
263
+ // Return 405 for other methods to avoid SSE stream issues
264
+ app.all(this.path, (0, http_transport_1.withDnsRebindingProtection)((_req, res) => {
265
+ res.status(405).send('Method Not Allowed');
266
+ }, dnsOpts));
267
+ console.error(`[StreamableHttpServer] Routes registered on external app at ${this.path}`);
268
+ console.error(`[StreamableHttpServer] JSON response mode: ${this.enableJsonResponse}`);
269
+ }
270
+ /**
271
+ * Get the configured endpoint path
272
+ */
273
+ getPath() {
274
+ return this.path;
275
+ }
276
+ /**
277
+ * Start the server
278
+ *
279
+ * In standalone mode (no external app): Creates Express server and starts listening
280
+ * In embedded mode (external app provided): Only registers routes on external app
281
+ */
282
+ async start() {
283
+ // If external app was provided in constructor, register routes on it
284
+ if (this.externalApp) {
285
+ this.registerRoutes(this.externalApp);
286
+ return;
287
+ }
288
+ // Standalone mode: create own Express server
289
+ const app = (0, express_1.default)();
290
+ app.use(express_1.default.json());
291
+ this.registerRoutes(app);
292
+ await new Promise((resolve, reject) => {
293
+ const protocol = (0, http_transport_1.getProtocol)(this.tls);
294
+ const server = (0, http_transport_1.createServerListener)(app, this.tls);
295
+ this.standaloneServer = server;
296
+ server.listen(this.port, this.host);
297
+ server.once('listening', () => {
298
+ console.error(`[StreamableHttpServer] Server started on ${this.host}:${this.port}`);
299
+ console.error(`[StreamableHttpServer] Endpoint: ${protocol}://${this.host}:${this.port}${this.path}`);
300
+ resolve();
301
+ });
302
+ server.once('error', reject);
303
+ });
304
+ }
305
+ /**
306
+ * The shutdown's first step, in the latch's tick: the pool stops
307
+ * admitting — every later request is answered `503`.
308
+ */
309
+ beginShutdown() {
310
+ this.pool.stopAdmitting();
311
+ }
312
+ /** Stops taking connections. Embedded on an external app there is no listener of its own. */
313
+ stopListening() {
314
+ const server = this.standaloneServer;
315
+ if (server) {
316
+ this.standaloneServer = undefined;
317
+ this.stoppedListener = server;
318
+ server.close();
319
+ server.closeIdleConnections();
320
+ }
321
+ }
322
+ /**
323
+ * The launcher's shutdown, after the logoffs (lib's
324
+ * `installTransportShutdown`), and `stop()`: nothing is answered any more —
325
+ * the connections still open on the stopped listener (a request whose tool
326
+ * was interrupted, a client's idle keep-alive) are closed, so none keeps
327
+ * the process alive.
328
+ */
329
+ releaseConnections() {
330
+ this.stoppedListener?.closeAllConnections();
331
+ this.stoppedListener = undefined;
332
+ }
333
+ /**
334
+ * For a host that stops the server itself (embedded): admission stops, the
335
+ * listener closes, then the pool's shutdown (no timer). Rejects with what
336
+ * could not be undone. A launcher's shutdown does not run this: it logs
337
+ * every owned connection off at once and interrupts the running tools
338
+ * (lib's `installTransportShutdown`).
339
+ */
340
+ async stop() {
341
+ this.beginShutdown();
342
+ this.stopListening();
343
+ const failures = await this.pool.shutdown();
344
+ this.releaseConnections();
345
+ if (failures.length) {
346
+ throw new Error(`state cleanup failed: ${failures.join('; ')}`);
347
+ }
348
+ }
349
+ createPerRequestServer() {
350
+ class PerRequestServer extends embeddable_1.BaseMcpServer {
351
+ registry;
352
+ constructor(registry, version, logger, state) {
353
+ // A transport per request: the client's disconnect closes that
354
+ // transport and ends no call — an admitted call goes on to its end.
355
+ // The instance's calls end with its close or the process shutdown.
356
+ super({
357
+ name: 'mcp-abap-adt',
358
+ version,
359
+ logger,
360
+ ...state,
361
+ transportCloseEndsSession: false,
362
+ // The responsible rules, once, when the instance's connection is
363
+ // created: kept with it in the pool.
364
+ systemContextResolver: request_context_1.defaultSystemContextResolver,
365
+ systemContextRules: responsible_rules_1.responsibleRules,
366
+ });
367
+ this.registry = registry;
368
+ this.registerHandlers(this.registry);
369
+ }
370
+ useConnectionContext(context) {
371
+ this.setConnectionContext(context);
372
+ }
373
+ /**
374
+ * A pooled instance ends with its state: after the idle bound's stop,
375
+ * whatever its undo answered, every connection it owns is closed with
376
+ * a logoff — not only the state's own.
377
+ */
378
+ idleStopped() {
379
+ return this.terminalClose();
380
+ }
381
+ }
382
+ return new PerRequestServer(this.handlersRegistry, this.version, this.logger, {
383
+ stateIdleMinutes: this.stateIdleMinutes,
384
+ stateLogger: this.stateLogger,
385
+ ...(this.backgroundRunsStore !== undefined && {
386
+ backgroundRuns: this.backgroundRunsStore,
387
+ }),
388
+ // Batch mode: this pooled instance's own, never shared with another.
389
+ ...(this.batchSettings !== undefined && {
390
+ batch: new embeddable_1.InstanceBatch(this.batchSettings),
391
+ }),
392
+ // An instance lasts one request unless it holds state: a lock taken
393
+ // here is kept as state, so the write and the unlock under it reach
394
+ // this instance (and its SAP session) by its state_handle.
395
+ heldLocks: new state_1.HeldLocks(),
396
+ // The corrected header pairs: the process's, shared by every
397
+ // instance.
398
+ adtHeaderPairs: this.adtHeaderPairs,
399
+ });
400
+ }
401
+ }
402
+ exports.StreamableHttpServer = StreamableHttpServer;
403
+ //# sourceMappingURL=StreamableHttpServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamableHttpServer.js","sourceRoot":"","sources":["../src/StreamableHttpServer.ts"],"names":[],"mappings":";;;;;;AAEA,iDAAsD;AAOtD,6DAKsC;AAEtC,qEAO0C;AAC1C,qDAAsD;AACtD,uEAI2C;AAC3C,mDAMiC;AAEjC,uEAAmE;AACnE,0FAAmG;AACnG,sDAA+D;AAC/D,qDAAgD;AAChD,uDAQ2B;AA8E3B,oGAAoG;AACpG,SAAS,eAAe,CAAC,IAAa;IACpC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAE,EAAE,CAC3B,CAA6C,EAAE,MAAM,KAAK,YAAY,CAAC;IAC1E,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,wGAAwG;AACxG,SAAS,mBAA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AAiE;oBACjE,qCAAqC;oBACrC,qBAAqB,EAAE,8CAA4B;oBACnD,kBAAkB,EAAE,oCAAgB;iBACrC,CAAC,CAAC;gBAzBc,aAAQ,GAAR,QAAQ,CAAmB;gBA0B5C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvC,CAAC;YAEM,oBAAoB,CAAC,OAA0B;gBACpD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YAED;;;;eAIG;YACgB,WAAW;gBAC5B,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9B,CAAC;SACF;QACD,OAAO,IAAI,gBAAgB,CACzB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,MAAM,EACX;YACE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,GAAG,CAAC,IAAI,CAAC,mBAAmB,KAAK,SAAS,IAAI;gBAC5C,cAAc,EAAE,IAAI,CAAC,mBAAmB;aACzC,CAAC;YACF,qEAAqE;YACrE,GAAG,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI;gBACtC,KAAK,EAAE,IAAI,0BAAa,CAAC,IAAI,CAAC,aAAa,CAAC;aAC7C,CAAC;YACF,oEAAoE;YACpE,oEAAoE;YACpE,2DAA2D;YAC3D,SAAS,EAAE,IAAI,iBAAS,EAAE;YAC1B,6DAA6D;YAC7D,YAAY;YACZ,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CACF,CAAC;IACJ,CAAC;CACF;AA7ZD,oDA6ZC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `mcp-abap-adt-http`'s parameter table: the Streamable HTTP
3
+ * listener, beside lib's shared rows and the TLS rows. No destination,
4
+ * login or SSE option is here; the CLI or YAML form of one — or any form of
5
+ * `--transport`, which is gone — stops the start naming the binary that serves
6
+ * it. Their environment variables are not read.
7
+ */
8
+ import { type IServerConfig, type Parameter, type ParameterTable, type TlsConfig, type YamlConfig } from '@mcp-abap-adt/lib/config';
9
+ import { type ToolSet } from '@mcp-abap-adt/lib/tool-set';
10
+ /** The Streamable HTTP rows: today's names. */
11
+ export declare const HTTP_ROWS: readonly Parameter[];
12
+ /**
13
+ * http's table for a tool set: its rows, the shared rows, and what it
14
+ * refuses — the set's removed `--exposition` among them, naming the http
15
+ * binary its words asked for. `mcp-abap-adt-http-ro`, `mcp-abap-adt-compact-http`
16
+ * and `mcp-abap-adt-compact-http-ro` are this table with their own set,
17
+ * nothing else.
18
+ */
19
+ export declare function httpParameters(toolSet: ToolSet, program?: string): ParameterTable;
20
+ /** `mcp-abap-adt-http`'s table: http's, with the full tool set. */
21
+ export declare const HTTP_PARAMETERS: ParameterTable;
22
+ /** What `mcp-abap-adt-http` reads. */
23
+ export interface HttpConfig extends IServerConfig {
24
+ host?: string;
25
+ port?: number;
26
+ /** The MCP endpoint path */
27
+ httpPath?: string;
28
+ /** JSON responses rather than SSE streams */
29
+ httpJsonResponse?: boolean;
30
+ /** Allowed Host header values (DNS-rebinding protection; exact, incl. port) */
31
+ allowedHosts?: string[];
32
+ /** Allowed Origin header values (DNS-rebinding protection; exact, incl. scheme) */
33
+ allowedOrigins?: string[];
34
+ /** Enable DNS-rebinding protection */
35
+ enableDnsRebindingProtection?: boolean;
36
+ /** TLS: cert and key start HTTPS */
37
+ tls?: TlsConfig;
38
+ }
39
+ /**
40
+ * `mcp-abap-adt-http`'s configuration from the arguments, the environment
41
+ * and the loaded config file. A removed parameter, or an invalid value,
42
+ * throws a `ParameterRefusal` in its words.
43
+ */
44
+ export declare function readHttpConfig(argv: readonly string[], env: NodeJS.ProcessEnv, yaml?: YamlConfig | null, toolSet?: ToolSet): HttpConfig;
45
+ //# sourceMappingURL=httpParameters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpParameters.d.ts","sourceRoot":"","sources":["../../src/config/httpParameters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,cAAc,EAOnB,KAAK,SAAS,EAId,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKvE,+CAA+C;AAC/C,eAAO,MAAM,SAAS,EAAE,SAAS,SAAS,EAqEzC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,SAAsB,GAC5B,cAAc,CAmBhB;AAED,mEAAmE;AACnE,eAAO,MAAM,eAAe,EAAE,cAA4C,CAAC;AAE3E,sCAAsC;AACtC,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,sCAAsC;IACtC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,oCAAoC;IACpC,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAKD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,GAAE,UAAU,GAAG,IAAW,EAC9B,OAAO,GAAE,OAAqB,GAC7B,UAAU,CAoBZ"}