@mcp-abap-adt/sse 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.
package/README.md CHANGED
@@ -1,3 +1,125 @@
1
- # Temporary Holding Version
1
+ # @mcp-abap-adt/sse
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The HTTP+SSE server of MCP ABAP ADT: the binary `mcp-abap-adt-sse`, and `SseServer`, which serves
4
+ the ADT tools of [`@mcp-abap-adt/lib`](https://www.npmjs.com/package/@mcp-abap-adt/lib) over MCP's
5
+ HTTP+SSE transport on an Express app — a `GET` on the SSE path opens a connection, and that
6
+ connection's `POST`s are routed to it by `sessionId` — with DNS rebinding protection and optional
7
+ TLS. Licensed AGPL-3.0-only.
8
+
9
+ HTTP+SSE is deprecated in MCP since 2025-03-26; it is served for the clients that still speak only
10
+ SSE. A client that speaks Streamable HTTP wants
11
+ [`@mcp-abap-adt/http`](https://www.npmjs.com/package/@mcp-abap-adt/http).
12
+
13
+ **The binary fixes the tool set (19.0.0).** `mcp-abap-adt-sse` serves readonly (with system and search),
14
+ high, the debugger and background runs; the readonly
15
+ tools alone are [`@mcp-abap-adt/sse-ro`](https://www.npmjs.com/package/@mcp-abap-adt/sse-ro) (`mcp-abap-adt-sse-ro`). There is no
16
+ `--exposition`: passing it, or a config file's `exposition`, stops the start with a sentence naming
17
+ the binary to install instead.
18
+
19
+ **No leftover-session tools, no session files (19.0.0).** One server holds the sessions of many
20
+ users, so it writes no runtime session file and serves no leftover-session tool; those are the
21
+ stdio binaries' (`mcp-abap-adt`, `mcp-abap-adt-ro`). Resuming a SAP session here is yours to do if you hold what it takes;
22
+ otherwise SAP ends it on its own timeout, which releases its locks: [MIGRATION-19.0](https://github.com/fr0ster/mcp-abap-adt/blob/main/docs/MIGRATION-19.0.md#stdio-leftover-sap-sessions-of-a-killed-process).
23
+
24
+ **No low set (19.0.0).** `--exposition=…,low` stops the start with this sentence: *"the low set is gone from mcp-abap-adt / -http / -sse; use mcp-abap-adt-compact (or -compact-http / -compact-sse)"*. Its single-step operations are compact's — see [MIGRATION-19.0](https://github.com/fr0ster/mcp-abap-adt/blob/main/docs/MIGRATION-19.0.md#the-low-set-leaves-the-full-binaries).
25
+
26
+ ```bash
27
+ npm install -g @mcp-abap-adt/sse
28
+ mcp-abap-adt-sse --sse-port=3001 --system-type=onprem
29
+ ```
30
+
31
+ ## Credentials: the headers of the opening request
32
+
33
+ The `GET` that opens an SSE connection carries its credentials, and the server takes them from
34
+ nowhere else: no destination, no service key, no session file, no login, no auth broker.
35
+
36
+ | Header (on the `GET`) | |
37
+ |---|---|
38
+ | `x-sap-url` | the system's URL (required) |
39
+ | `x-sap-client` | the client (optional) |
40
+ | `x-sap-jwt-token` | a token you hold, presented as a Bearer token |
41
+ | `x-sap-login` + `x-sap-password` | a user and password (basic) |
42
+
43
+ - A `GET` without them is answered `400`: *this server takes credentials only from the request's
44
+ headers: send x-sap-url with x-sap-jwt-token, or with x-sap-login and x-sap-password*.
45
+ - A `GET` or a `POST` carrying `x-mcp-destination` is answered `400`: *destinations are served only
46
+ by mcp-abap-adt (stdio); send x-sap-* headers*. Destinations are
47
+ [`@mcp-abap-adt/core`](https://www.npmjs.com/package/@mcp-abap-adt/core)'s, over stdio.
48
+ - A `POST` is routed by its `sessionId` alone: its own `x-sap-*` headers are not read, so a
49
+ connection's credential is the one it opened with.
50
+ - Each connection has its own credential, instance and connection to the system; nothing is shared
51
+ with another connection, and nothing outlives it. Held state (a debug session)
52
+ lives in the connection's instance until the connection closes, its
53
+ stop tool runs or the idle bound (`--state-idle-minutes`) ends it.
54
+ - The system kind follows `--system-type` / `SAP_SYSTEM_TYPE` and is required — no request header
55
+ states it. Without it the binary does not start: exit `1` before anything listens, on stderr
56
+ `[MCP] The SAP system type is required — set --system-type, SAP_SYSTEM_TYPE (the environment)
57
+ or system-type (YAML) to onprem, cloud or legacy; the server did not start`. (An embedder's own host of the
58
+ exported server class reads `SAP_SYSTEM_TYPE` at each call: a call without it is refused
59
+ `system_type_required`, nothing sent.)
60
+
61
+ Beside the credential, the opening `GET` may state `x-sap-responsible`, `x-sap-master-system`,
62
+ `x-sap-language` and the debugger's `x-sap-debug-terminal-id` / `x-sap-debug-ide-id` (then the
63
+ environment's `SAP_*`).
64
+
65
+ The system is asked first, when the stream's connection is created (`systeminformation`, once per
66
+ stream, by `@mcp-abap-adt/responsible-rules`): its user and system id win over
67
+ these headers. They count only where an on-premise system gives no information — the responsible
68
+ if stated, else the login, else the call is refused `system_user_unknown`; on ABAP Cloud no
69
+ information is an error (`cloud_without_systeminformation` for a `404`, else
70
+ `system_lookup_failed`). See [MIGRATION-19.0](https://github.com/fr0ster/mcp-abap-adt/blob/main/docs/MIGRATION-19.0.md#every-transport-only-lock-and-unlock-are-sent-stateful-and-an-instances-calls-run-one-at-a-time).
71
+
72
+ ## Options
73
+
74
+ As before 19.0.0, under the same names: `--sse-host` / `MCP_SSE_HOST`, `--sse-port` /
75
+ `MCP_SSE_PORT` (default `3001`), `--sse-path` (default `/sse`), `--post-path` (default
76
+ `/messages`), `--sse-allowed-hosts` / `MCP_SSE_ALLOWED_HOSTS`, `--sse-allowed-origins` /
77
+ `MCP_SSE_ALLOWED_ORIGINS`, `--sse-enable-dns-protection` / `MCP_SSE_ENABLE_DNS_PROTECTION`,
78
+ `--tls-cert` / `--tls-key` / `--tls-ca` (`MCP_TLS_*`), `--system-type`, `--state-idle-minutes` / `MCP_STATE_IDLE_MINUTES`, `--conf`, `--help`, `--version`;
79
+ new in 19.0.0, `--shutdown-timeout` / `MCP_SHUTDOWN_TIMEOUT` (see [Shutdown](#shutdown)).
80
+
81
+ ## A closed connection disposes its instance
82
+
83
+ An SSE connection closes as a stdio client's transport does: it is one long stream with the
84
+ credentials of its opening `GET`, one instance per stream. When it closes — or fails while it is
85
+ being set up — its session leaves the routing map at once (a later `POST` for it is an unknown
86
+ session) and its instance is closed: no call of it starts any more, **its ADT sessions are logged
87
+ off at once** — its connection, the debugger's, a long read's own; the logoff releases a lock a
88
+ tool holds — and its running tools are interrupted: **nothing waits for a running tool**, a queued
89
+ call never starts, and no state undo is sent (the logoff ends the held state). A running tool
90
+ whose next step would open an ADT session of its own (a debugger start, a package lock over RFC)
91
+ is refused before it logs on: a closed connection's instance opens no new session. Then its MCP
92
+ server and stream are closed. A background run the connection started is cut with it — its
93
+ session logged off at once with the others; it ends in the store once its request settled. Another
94
+ connection's tools, instance and background runs are not touched.
95
+
96
+ ## Shutdown
97
+
98
+ On `SIGTERM` / `SIGINT` / `SIGHUP` / `SIGQUIT` (`SIGBREAK` on Windows), or a crash outside a
99
+ tool (then exit `1`), the server stops listening and takes no new call (a `POST` arriving after
100
+ it is answered "The server is shutting down." and reaches no tool), **logs off every ADT session
101
+ of the process at once** and interrupts the running tools — nothing waits for a running tool —,
102
+ lets each logoff finish (until SAP answered it or its connection failed), then ends every stream.
103
+ It exits `0`. There is no deadline. A killed process (`SIGKILL`, out of memory) sends no logoff:
104
+ SAP keeps its sessions until its own timeout. A second signal, or
105
+ `--shutdown-timeout=<seconds>` (no default), matters only while a logoff is still being written or
106
+ answered: exit `1` naming the requests still running. That forced close is the one end that does
107
+ not wait for SAP's answers, a deliberate exception: it exits once each logoff is written, so a
108
+ session whose logoff SAP had not received whole can stay until SAP's security-session timeout.
109
+ This server keeps no runtime session files, so nothing lists such a session
110
+ (`ListLeftoverSessions` is stdio's, where such a session keeps its file for the next process).
111
+
112
+ ## Health
113
+
114
+ `GET /mcp/health` answers `{ status: 'ok', uptime, version, transport: 'sse', activeSessions }`.
115
+
116
+ ## Embedding
117
+
118
+ `new SseServer(handlersRegistry, options)` — the same options, and `app` to register the routes on
119
+ your own Express (or CAP) application. `main({ program, version })` is the binary's launcher
120
+ (`@mcp-abap-adt/sse/launcher`). An embedder that stops the server itself calls `stop()`: the listener
121
+ closes and every open connection gets the close above — its ADT sessions logged off at once, its
122
+ running tools interrupted, no state undo sent —, joined where one is already closing; it never
123
+ rejects. The binary's own shutdown calls `stopListening()`, logs every session of the process off
124
+ at once (lib's `installTransportShutdown`), then `releaseConnections()`, which closes the client
125
+ connections left.
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * mcp-abap-adt-sse — the MCP ABAP ADT server over HTTP+SSE, with the full tool set.
5
+ *
6
+ * The launcher is required and started in this process; it starts nothing
7
+ * on import: `main` is called here with the tool set this command serves,
8
+ * and a sibling command (@mcp-abap-adt/compact-sse) calls the same `main`
9
+ * with its own.
10
+ */
11
+ const { main } = require('../dist/launcher.js');
12
+ const { SSE_VERSION } = require('../dist/sseVersion.js');
13
+ const { fullToolSet } = require('@mcp-abap-adt/lib/tool-set');
14
+
15
+ void main({
16
+ toolSet: fullToolSet,
17
+ program: 'mcp-abap-adt-sse',
18
+ version: SSE_VERSION,
19
+ }).catch(() => {
20
+ // Fixed words: an error's message may quote a file or a header.
21
+ console.error('[MCP] launcher failed');
22
+ process.exit(1);
23
+ });
@@ -0,0 +1,180 @@
1
+ import type { TlsConfig } from '@mcp-abap-adt/lib/config';
2
+ import type { IBackgroundRuns, IHttpApplication, RouteRegistrationOptions } from '@mcp-abap-adt/lib/embeddable';
3
+ import type { IHandlersRegistry } from '@mcp-abap-adt/lib/handlers';
4
+ import { type StateLogger } from '@mcp-abap-adt/lib/state';
5
+ import type { Logger } from '@mcp-abap-adt/logger';
6
+ export interface SseServerOptions {
7
+ /**
8
+ * The idle bound on held state, in minutes: each instance's state ends
9
+ * after this long without a tool call. At least 30; default 30.
10
+ */
11
+ stateIdleMinutes?: number;
12
+ /** Where the state's lifecycle lines go; default stderr, always on. */
13
+ stateLogger?: StateLogger;
14
+ /**
15
+ * Batch mode: each SSE connection's instance gets an `InstanceBatch` of
16
+ * its own, created with these settings (the launcher's). Absent: no
17
+ * instance has one, and the batch tools answer `batch_mode_unavailable`.
18
+ */
19
+ batch?: {
20
+ keepRawParts: boolean;
21
+ };
22
+ /**
23
+ * Host to bind to (only used when no external app is provided)
24
+ * @default "127.0.0.1"
25
+ */
26
+ host?: string;
27
+ /**
28
+ * Port to listen on (only used when no external app is provided)
29
+ * @default 3001
30
+ */
31
+ port?: number;
32
+ /**
33
+ * Path for SSE GET endpoint
34
+ * @default "/sse"
35
+ */
36
+ ssePath?: string;
37
+ /**
38
+ * Path for POST messages endpoint
39
+ * @default "/messages"
40
+ */
41
+ postPath?: string;
42
+ /**
43
+ * Logger instance
44
+ */
45
+ logger?: Logger;
46
+ /**
47
+ * Server version
48
+ */
49
+ version?: string;
50
+ /**
51
+ * External HTTP application to register routes on
52
+ * When provided, start() will only register routes without creating a server
53
+ * This enables integration with existing Express/CDS/CAP servers
54
+ */
55
+ app?: IHttpApplication;
56
+ /**
57
+ * TLS configuration for HTTPS support
58
+ */
59
+ tls?: TlsConfig;
60
+ /** Allowed Host header values (DNS-rebinding protection; exact, incl. port) */
61
+ allowedHosts?: string[];
62
+ /** Allowed Origin header values (DNS-rebinding protection; exact, incl. scheme) */
63
+ allowedOrigins?: string[];
64
+ /** Enable DNS-rebinding protection (requires allowedHosts and/or allowedOrigins) */
65
+ enableDnsRebindingProtection?: boolean;
66
+ /**
67
+ * Where background runs and their answers are kept, handed to every
68
+ * instance (the launcher's `InMemoryBackgroundRuns` of
69
+ * `@mcp-abap-adt/background-runs-memory`). Absent:
70
+ * `background: true` is refused.
71
+ */
72
+ backgroundRuns?: IBackgroundRuns;
73
+ }
74
+ /**
75
+ * The SSE server: a `GET` opens a connection and builds one
76
+ * `BaseMcpServer` for it, whose source is that `GET`'s `x-sap-*` headers
77
+ * (lib's `headerSource`) — one per connection, shared with no other and
78
+ * outliving none. A `POST` is routed by its `sessionId` alone: its own
79
+ * `x-sap-*` headers are not read. A `GET` without credentials, and a `GET` or
80
+ * a `POST` carrying `x-mcp-destination`, are answered `400`.
81
+ *
82
+ * Supports two modes:
83
+ * 1. Standalone mode: Creates its own Express server (when no app option provided)
84
+ * 2. Embedded mode: Registers routes on external app (when app option provided)
85
+ */
86
+ export declare class SseServer {
87
+ private readonly handlersRegistry;
88
+ private readonly host;
89
+ private readonly port;
90
+ private readonly ssePath;
91
+ private readonly postPath;
92
+ private readonly sessions;
93
+ /**
94
+ * Every connection from its `GET` until its close settled — being set up,
95
+ * open, or closing — with its one cleanup (the instance close): a
96
+ * shutdown runs it for the open ones and joins the ones already closing
97
+ * A close that settled before the shutdown is only logged.
98
+ */
99
+ private readonly connections;
100
+ private readonly logger;
101
+ private readonly version;
102
+ private readonly externalApp?;
103
+ private standaloneServer?;
104
+ /** The listener stopped, until its last connections are closed after the last step. */
105
+ private stoppedListener?;
106
+ private readonly tls?;
107
+ private readonly allowedHosts?;
108
+ private readonly allowedOrigins?;
109
+ private readonly enableDnsRebindingProtection?;
110
+ private readonly stateIdleMinutes?;
111
+ private readonly stateLogger;
112
+ private readonly backgroundRuns;
113
+ private readonly batchSettings;
114
+ /** The corrected header pairs: the process's, shared by every stream's instance. */
115
+ private readonly adtHeaderPairs;
116
+ constructor(handlersRegistry: IHandlersRegistry, opts?: SseServerOptions);
117
+ /**
118
+ * Register routes on an external HTTP application
119
+ * Use this when integrating with existing Express/CDS/CAP server
120
+ *
121
+ * @param app - External HTTP application (Express, CDS, etc.)
122
+ * @param options - Route registration options
123
+ */
124
+ registerRoutes(app: IHttpApplication, _options?: RouteRegistrationOptions): void;
125
+ /**
126
+ * Get the configured SSE endpoint path
127
+ */
128
+ getSsePath(): string;
129
+ /**
130
+ * Get the configured POST endpoint path
131
+ */
132
+ getPostPath(): string;
133
+ /**
134
+ * Start the server
135
+ *
136
+ * In standalone mode (no external app): Creates Express server and starts listening
137
+ * In embedded mode (external app provided): Only registers routes on external app
138
+ */
139
+ start(): Promise<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): the listener
152
+ * closes, then every connection's instance close — its connections logged
153
+ * off at once, its calls interrupted (no tool awaited, no timer). A
154
+ * launcher's shutdown does not run this: it logs every connection the
155
+ * process owns off at once and interrupts every running tool (lib's
156
+ * `installTransportShutdown`).
157
+ */
158
+ stop(): Promise<void>;
159
+ /** The instance close of every connection, joined where one runs already. */
160
+ private closeAll;
161
+ private handleGet;
162
+ /**
163
+ * One connection's cleanup — the client closed its stream, as a
164
+ * stdio client closes stdin: the session leaves the routing map first
165
+ * (main's: a later `POST` for it is an unknown session), then the instance
166
+ * close — the instance latch, its connections logged off at once and its
167
+ * running and queued calls interrupted in the same tick (no tool awaited),
168
+ * its state let go, its MCP server and stream closed.
169
+ */
170
+ private closeConnection;
171
+ private handlePost;
172
+ /**
173
+ * What a log line says of a thrown value: `logFields` of the failure the
174
+ * reader knows, else its class only — a message may quote a file.
175
+ */
176
+ private failureWords;
177
+ /** A request refused or failed: the refusal's words (400), the reader's, or as before. */
178
+ private answerFailure;
179
+ }
180
+ //# sourceMappingURL=SseServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SseServer.d.ts","sourceRoot":"","sources":["../src/SseServer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAEV,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAOtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAgBpE,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAMnD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,gBAAgB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