@mcp-abap-adt/sse 19.1.0 → 20.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 +14 -2
- package/bin/mcp-abap-adt-sse.js +5 -3
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/launcher.d.ts +19 -39
- package/dist/launcher.d.ts.map +1 -1
- package/dist/launcher.js +22 -125
- package/dist/launcher.js.map +1 -1
- package/dist/sseVersion.d.ts +2 -9
- package/dist/sseVersion.d.ts.map +1 -1
- package/dist/sseVersion.js +5 -2
- package/dist/sseVersion.js.map +1 -1
- package/package.json +8 -10
- package/dist/SseServer.d.ts +0 -180
- package/dist/SseServer.d.ts.map +0 -1
- package/dist/SseServer.js +0 -384
- package/dist/SseServer.js.map +0 -1
- package/dist/config/sseParameters.d.ts +0 -46
- package/dist/config/sseParameters.d.ts.map +0 -1
- package/dist/config/sseParameters.js +0 -140
- package/dist/config/sseParameters.js.map +0 -1
package/README.md
CHANGED
|
@@ -116,10 +116,22 @@ This server keeps no runtime session files, so nothing lists such a session
|
|
|
116
116
|
## Embedding
|
|
117
117
|
|
|
118
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`
|
|
119
|
+
your own Express (or CAP) application. `main({ toolSet, program, version, packageName })` is the binary's launcher
|
|
120
|
+
(`@mcp-abap-adt/sse/launcher`; `packageName`, the package a second copy of lib asks to reinstall,
|
|
121
|
+
is optional on this path and defaults to `@mcp-abap-adt/sse`, as 19.1.0's
|
|
122
|
+
`{ toolSet, program, version }` still compiles). An embedder that stops the server itself calls `stop()`: the listener
|
|
121
123
|
closes and every open connection gets the close above — its ADT sessions logged off at once, its
|
|
122
124
|
running tools interrupted, no state undo sent —, joined where one is already closing; it never
|
|
123
125
|
rejects. The binary's own shutdown calls `stopListening()`, logs every session of the process off
|
|
124
126
|
at once (lib's `installTransportShutdown`), then `releaseConnections()`, which closes the client
|
|
125
127
|
connections left.
|
|
128
|
+
|
|
129
|
+
**Where the code lives (19.2.0).** The launcher and `SseServer` live in
|
|
130
|
+
[`@mcp-abap-adt/server-runtime`](https://www.npmjs.com/package/@mcp-abap-adt/server-runtime),
|
|
131
|
+
which is installed with this package; this package holds the `mcp-abap-adt-sse` binary and its
|
|
132
|
+
version. Its exports are unchanged, as re-exports: `@mcp-abap-adt/sse` of
|
|
133
|
+
`server-runtime/sse/server` (its `SseServer` answers sse's version when constructed without one),
|
|
134
|
+
`@mcp-abap-adt/sse/launcher` of `server-runtime/sse`. No other server package depends on this one:
|
|
135
|
+
`compact-sse`, `sse-ro` and `compact-sse-ro` run the same launcher from `server-runtime`. The
|
|
136
|
+
runtime also carries the stdio destination layer, so `@mcp-abap-adt/auth-broker` and
|
|
137
|
+
`@mcp-abap-adt/auth-stores` are installed with this server; it never loads them.
|
package/bin/mcp-abap-adt-sse.js
CHANGED
|
@@ -6,16 +6,18 @@
|
|
|
6
6
|
* The launcher is required and started in this process; it starts nothing
|
|
7
7
|
* on import: `main` is called here with the tool set this command serves,
|
|
8
8
|
* and a sibling command (@mcp-abap-adt/compact-sse) calls the same `main`
|
|
9
|
-
* with its own.
|
|
9
|
+
* with its own. The launcher is @mcp-abap-adt/server-runtime's; the version
|
|
10
|
+
* is sse's own.
|
|
10
11
|
*/
|
|
11
|
-
const { main } = require('
|
|
12
|
-
const { SSE_VERSION } = require('../dist/sseVersion.js');
|
|
12
|
+
const { main } = require('@mcp-abap-adt/server-runtime/sse');
|
|
13
|
+
const { SSE_VERSION, SSE_PACKAGE } = require('../dist/sseVersion.js');
|
|
13
14
|
const { fullToolSet } = require('@mcp-abap-adt/lib/tool-set');
|
|
14
15
|
|
|
15
16
|
void main({
|
|
16
17
|
toolSet: fullToolSet,
|
|
17
18
|
program: 'mcp-abap-adt-sse',
|
|
18
19
|
version: SSE_VERSION,
|
|
20
|
+
packageName: SSE_PACKAGE,
|
|
19
21
|
}).catch(() => {
|
|
20
22
|
// Fixed words: an error's message may quote a file or a header.
|
|
21
23
|
console.error('[MCP] launcher failed');
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,19 @@
|
|
|
5
5
|
* Importing from here links AGPL code. If you are embedding ADT tools in your
|
|
6
6
|
* own application, you want `@mcp-abap-adt/lib` instead: it carries the
|
|
7
7
|
* handlers and the embeddable server under Apache-2.0, and no transport.
|
|
8
|
+
*
|
|
9
|
+
* The code lives in `@mcp-abap-adt/server-runtime` (19.2.0): this module
|
|
10
|
+
* re-exports its `sse/server` path, so an importer of `@mcp-abap-adt/sse`
|
|
11
|
+
* sees the names it saw before.
|
|
12
|
+
*/
|
|
13
|
+
import { SseServer as RuntimeSseServer } from '@mcp-abap-adt/server-runtime/sse/server';
|
|
14
|
+
export * from '@mcp-abap-adt/server-runtime/sse/server';
|
|
15
|
+
/**
|
|
16
|
+
* The runtime's HTTP+SSE server, answering sse's version when none is given —
|
|
17
|
+
* as a direct constructor call did before the code moved, even when the
|
|
18
|
+
* runtime is at another patch than sse.
|
|
8
19
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
20
|
+
export declare class SseServer extends RuntimeSseServer {
|
|
21
|
+
constructor(...[handlersRegistry, opts]: ConstructorParameters<typeof RuntimeSseServer>);
|
|
22
|
+
}
|
|
11
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAIxF,cAAc,yCAAyC,CAAC;AAExD;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,gBAAgB;gBAE3C,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,gBAAgB,CAAC;CAO9E"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* `@mcp-abap-adt/sse` — the HTTP+SSE transport of the MCP ABAP ADT server,
|
|
4
|
-
* AGPL-3.0-only.
|
|
5
|
-
*
|
|
6
|
-
* Importing from here links AGPL code. If you are embedding ADT tools in your
|
|
7
|
-
* own application, you want `@mcp-abap-adt/lib` instead: it carries the
|
|
8
|
-
* handlers and the embeddable server under Apache-2.0, and no transport.
|
|
9
|
-
*/
|
|
10
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
3
|
if (k2 === undefined) k2 = k;
|
|
12
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -22,7 +14,35 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
22
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
15
|
};
|
|
24
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
exports.SseServer = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* `@mcp-abap-adt/sse` — the HTTP+SSE transport of the MCP ABAP ADT server,
|
|
20
|
+
* AGPL-3.0-only.
|
|
21
|
+
*
|
|
22
|
+
* Importing from here links AGPL code. If you are embedding ADT tools in your
|
|
23
|
+
* own application, you want `@mcp-abap-adt/lib` instead: it carries the
|
|
24
|
+
* handlers and the embeddable server under Apache-2.0, and no transport.
|
|
25
|
+
*
|
|
26
|
+
* The code lives in `@mcp-abap-adt/server-runtime` (19.2.0): this module
|
|
27
|
+
* re-exports its `sse/server` path, so an importer of `@mcp-abap-adt/sse`
|
|
28
|
+
* sees the names it saw before.
|
|
29
|
+
*/
|
|
30
|
+
const server_1 = require("@mcp-abap-adt/server-runtime/sse/server");
|
|
31
|
+
const sseVersion_js_1 = require("./sseVersion.js");
|
|
32
|
+
// sse's parameter table and the server
|
|
33
|
+
__exportStar(require("@mcp-abap-adt/server-runtime/sse/server"), exports);
|
|
34
|
+
/**
|
|
35
|
+
* The runtime's HTTP+SSE server, answering sse's version when none is given —
|
|
36
|
+
* as a direct constructor call did before the code moved, even when the
|
|
37
|
+
* runtime is at another patch than sse.
|
|
38
|
+
*/
|
|
39
|
+
class SseServer extends server_1.SseServer {
|
|
40
|
+
constructor(...[handlersRegistry, opts]) {
|
|
41
|
+
super(handlersRegistry, {
|
|
42
|
+
...opts,
|
|
43
|
+
version: opts?.version ?? sseVersion_js_1.SSE_VERSION,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.SseServer = SseServer;
|
|
28
48
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;GAWG;AACH,oEAAwF;AACxF,mDAA8C;AAE9C,uCAAuC;AACvC,0EAAwD;AAExD;;;;GAIG;AACH,MAAa,SAAU,SAAQ,kBAAgB;IAC7C,YACE,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAiD;QAE3E,KAAK,CAAC,gBAAgB,EAAE;YACtB,GAAG,IAAI;YACP,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,2BAAW;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AATD,8BASC"}
|
package/dist/launcher.d.ts
CHANGED
|
@@ -1,43 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* `@mcp-abap-adt/sse/launcher` — the HTTP+SSE launcher. Its code lives in
|
|
3
|
+
* `@mcp-abap-adt/server-runtime` (19.2.0); this path re-exports
|
|
4
|
+
* `@mcp-abap-adt/server-runtime/sse`, so an importer sees the names it saw
|
|
5
|
+
* before.
|
|
6
|
+
*
|
|
7
|
+
* And it takes 19.1.0's options: `SseLauncherOptions`, `main` and `launch` here
|
|
8
|
+
* accept `{ toolSet, program, version }` as before. `packageName` — required
|
|
9
|
+
* on the runtime's own path — is optional here and defaults to
|
|
10
|
+
* `@mcp-abap-adt/sse`, the package a second copy of lib then asks to
|
|
11
|
+
* reinstall; a value given passes through.
|
|
6
12
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
import { type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
* serves, and its own name and version — nothing else. Everything the
|
|
15
|
-
* launcher does is sse's, the same for any tool set:
|
|
16
|
-
* `mcp-abap-adt-sse` passes `fullToolSet`, `mcp-abap-adt-sse-ro`
|
|
17
|
-
* `fullReadOnlyToolSet`, `mcp-abap-adt-compact-sse` and
|
|
18
|
-
* `mcp-abap-adt-compact-sse-ro` the compact sets.
|
|
19
|
-
*/
|
|
20
|
-
export interface SseLauncherOptions {
|
|
21
|
-
/** The tools served: fixed by the command, never by a flag. */
|
|
22
|
-
toolSet: ToolSet;
|
|
23
|
-
/** The command's own name: USAGE in `--help`, the `--conf` template's header. */
|
|
24
|
-
program: string;
|
|
25
|
-
/** The version `--version` and `initialize` report: the command's own package's. */
|
|
26
|
-
version: string;
|
|
27
|
-
}
|
|
28
|
-
/** What the launcher takes from the program: the process's edges. */
|
|
29
|
-
export interface SseLauncherDeps {
|
|
30
|
-
stderr: (line: string) => void;
|
|
31
|
-
exit: (code: number) => void;
|
|
32
|
-
/** Where the shutdown listens: `process` in the program. */
|
|
33
|
-
processLike: EventEmitter;
|
|
13
|
+
import type { LauncherEdges } from '@mcp-abap-adt/lib/config';
|
|
14
|
+
import { type SseLauncherOptions as RuntimeSseLauncherOptions, launch as runtimeLaunch, main as runtimeMain, type SseLauncherDeps } from '@mcp-abap-adt/server-runtime/sse';
|
|
15
|
+
export * from '@mcp-abap-adt/server-runtime/sse';
|
|
16
|
+
/** 19.1.0's options; `packageName` optional, `@mcp-abap-adt/sse` when not given. */
|
|
17
|
+
export interface SseLauncherOptions extends Omit<RuntimeSseLauncherOptions, 'packageName'> {
|
|
18
|
+
/** The command's own npm package: the one a second copy of lib asks to reinstall. Default `@mcp-abap-adt/sse`. */
|
|
19
|
+
packageName?: string | undefined;
|
|
34
20
|
}
|
|
35
|
-
|
|
36
|
-
export declare function
|
|
37
|
-
toolSet?: ToolSet;
|
|
38
|
-
program?: string;
|
|
39
|
-
}): string;
|
|
40
|
-
export declare function main(options: SseLauncherOptions, edges?: LauncherEdges): Promise<SseServer | undefined>;
|
|
41
|
-
/** Everything after the parameters are read: the tool list, the server, the shutdown. */
|
|
42
|
-
export declare function launch(config: SseConfig, options: SseLauncherOptions, deps: SseLauncherDeps): Promise<SseServer | undefined>;
|
|
21
|
+
export declare function main(options: SseLauncherOptions, edges?: LauncherEdges): ReturnType<typeof runtimeMain>;
|
|
22
|
+
export declare function launch(config: Parameters<typeof runtimeLaunch>[0], options: SseLauncherOptions, deps: SseLauncherDeps): ReturnType<typeof runtimeLaunch>;
|
|
43
23
|
//# sourceMappingURL=launcher.d.ts.map
|
package/dist/launcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EACL,KAAK,kBAAkB,IAAI,yBAAyB,EACpD,MAAM,IAAI,aAAa,EACvB,IAAI,IAAI,WAAW,EACnB,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAG1C,cAAc,kCAAkC,CAAC;AAEjD,oFAAoF;AACpF,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC;IACtD,kHAAkH;IAClH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAMD,wBAAsB,IAAI,CACxB,OAAO,EAAE,kBAAkB,EAC3B,KAAK,CAAC,EAAE,aAAa,GACpB,UAAU,CAAC,OAAO,WAAW,CAAC,CAEhC;AAED,wBAAsB,MAAM,CAC1B,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,EAC3C,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,eAAe,GACpB,UAAU,CAAC,OAAO,aAAa,CAAC,CAElC"}
|
package/dist/launcher.js
CHANGED
|
@@ -1,134 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
8
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.sseHelp = sseHelp;
|
|
10
17
|
exports.main = main;
|
|
11
18
|
exports.launch = launch;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const tool_set_1 = require("@mcp-abap-adt/lib/tool-set");
|
|
18
|
-
const responsible_rules_1 = require("@mcp-abap-adt/responsible-rules");
|
|
19
|
-
const sseParameters_js_1 = require("./config/sseParameters.js");
|
|
20
|
-
const SseServer_js_1 = require("./SseServer.js");
|
|
21
|
-
const HELP_SECTIONS = `
|
|
22
|
-
CREDENTIALS (the headers of the GET that opens each SSE connection; a POST is
|
|
23
|
-
routed by its sessionId alone, and its own x-sap-* headers are not read):
|
|
24
|
-
x-sap-url The system's URL (required)
|
|
25
|
-
x-sap-client The client (optional)
|
|
26
|
-
x-sap-jwt-token A token you hold, sent as a Bearer token
|
|
27
|
-
x-sap-login, x-sap-password A user and password (basic)
|
|
28
|
-
A GET without them is answered 400. x-mcp-destination, on a GET or a POST, is
|
|
29
|
-
refused with 400: destinations are served only by mcp-abap-adt (stdio).
|
|
30
|
-
Nothing is shared with another connection, and nothing outlives it.
|
|
31
|
-
|
|
32
|
-
System Context (the opening GET's headers, first found wins):
|
|
33
|
-
x-sap-responsible Responsible of created objects
|
|
34
|
-
x-sap-master-system Master system of created objects
|
|
35
|
-
x-sap-language Master/original language for created objects
|
|
36
|
-
x-sap-debug-terminal-id The debugger's terminal id (where the debugger is served)
|
|
37
|
-
x-sap-debug-ide-id The debugger's IDE id
|
|
38
|
-
x-sap-debug-breakpoint-conflict replace (default) or refuse-if-held: whether a take-over
|
|
39
|
-
of the debugger, and every later change of its breakpoints,
|
|
40
|
-
first asks if another debugger listens for the same SAP user
|
|
41
|
-
Then SAP_RESPONSIBLE, SAP_MASTER_SYSTEM, SAP_DEBUG_TERMINAL_ID, SAP_DEBUG_IDE_ID,
|
|
42
|
-
SAP_DEBUG_BREAKPOINT_CONFLICT of the environment; with x-sap-login, the login is the responsible when none is stated.
|
|
43
|
-
|
|
44
|
-
Held state (a debug session) lives in the connection's instance until the
|
|
45
|
-
connection closes; MCP_STATE_IDLE_MINUTES / --state-idle-minutes bound it.
|
|
46
|
-
|
|
47
|
-
A health check answers GET /mcp/health.
|
|
48
|
-
`;
|
|
49
|
-
/** sse's help: its own table, the set's TOOLS section, the headers. */
|
|
50
|
-
function sseHelp(options = {}) {
|
|
51
|
-
const toolSet = options.toolSet ?? tool_set_1.fullToolSet;
|
|
52
|
-
const program = options.program ?? 'mcp-abap-adt-sse';
|
|
53
|
-
return (0, config_1.generateHelp)((0, sseParameters_js_1.sseParameters)(toolSet, program), {
|
|
54
|
-
description: ' MCP server for SAP ABAP systems via ADT, over HTTP+SSE: credentials only from the\n x-sap-* headers of the GET that opens each SSE connection. stdio (destinations,\n logins) is mcp-abap-adt, Streamable HTTP mcp-abap-adt-http; a binary is its transport.',
|
|
55
|
-
sections: [
|
|
56
|
-
toolSet.toolsHelp('sse'),
|
|
57
|
-
HELP_SECTIONS,
|
|
58
|
-
`\nEXAMPLES:\n # Listen on port 3000\n ${program} --sse-port=3000\n`,
|
|
59
|
-
],
|
|
60
|
-
});
|
|
19
|
+
const sse_1 = require("@mcp-abap-adt/server-runtime/sse");
|
|
20
|
+
const sseVersion_js_1 = require("./sseVersion.js");
|
|
21
|
+
__exportStar(require("@mcp-abap-adt/server-runtime/sse"), exports);
|
|
22
|
+
function withPackage(options) {
|
|
23
|
+
return { ...options, packageName: options.packageName ?? sseVersion_js_1.SSE_PACKAGE };
|
|
61
24
|
}
|
|
62
|
-
async function main(options, edges
|
|
63
|
-
|
|
64
|
-
if ((0, config_1.answerVersionOrHelp)(edges, {
|
|
65
|
-
version: options.version,
|
|
66
|
-
help: () => sseHelp(options),
|
|
67
|
-
})) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
// sse's own table: an option of another binary, --transport, or the
|
|
71
|
-
// removed --exposition stops here.
|
|
72
|
-
const config = (0, config_1.readStartupConfig)((0, sseParameters_js_1.sseParameters)(options.toolSet, options.program), argv, process.env, { stderr, exit }, (args, env, yaml) => (0, sseParameters_js_1.readSseConfig)(args, env, yaml, options.toolSet));
|
|
73
|
-
if (config === undefined)
|
|
74
|
-
return undefined;
|
|
75
|
-
return launch(config, options, {
|
|
76
|
-
stderr,
|
|
77
|
-
exit,
|
|
78
|
-
processLike: edges.processLike,
|
|
79
|
-
});
|
|
25
|
+
async function main(options, edges) {
|
|
26
|
+
return (0, sse_1.main)(withPackage(options), edges);
|
|
80
27
|
}
|
|
81
|
-
/** Everything after the parameters are read: the tool list, the server, the shutdown. */
|
|
82
28
|
async function launch(config, options, deps) {
|
|
83
|
-
|
|
84
|
-
// SAP_SYSTEM_TYPE or YAML system-type (no request header states it).
|
|
85
|
-
// Without it the start ends here, before anything listens — so no tool
|
|
86
|
-
// list is filtered for a kind nobody stated.
|
|
87
|
-
if (config.systemType === undefined) {
|
|
88
|
-
deps.stderr(`[MCP] ${(0, responsible_rules_1.listenerSystemTypeRequiredWords)()}`);
|
|
89
|
-
deps.exit(1);
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
// The connector and the tool filter read the system kind from the
|
|
93
|
-
// environment (`resolveSystemKind`).
|
|
94
|
-
process.env.SAP_SYSTEM_TYPE = config.systemType;
|
|
95
|
-
const server = new SseServer_js_1.SseServer((0, tool_set_1.registryOf)(options.toolSet, 'sse'), {
|
|
96
|
-
version: options.version,
|
|
97
|
-
stateIdleMinutes: config.stateIdleMinutes,
|
|
98
|
-
// Batch mode: one InstanceBatch per SSE connection's instance.
|
|
99
|
-
batch: { keepRawParts: config.batchKeepRawParts === true },
|
|
100
|
-
// The state's lines go to stderr whatever the transport logger says.
|
|
101
|
-
stateLogger: state_1.stderrStateLogger,
|
|
102
|
-
host: config.host,
|
|
103
|
-
port: config.port,
|
|
104
|
-
ssePath: config.ssePath,
|
|
105
|
-
postPath: config.postPath,
|
|
106
|
-
logger: logger_1.noopLogger,
|
|
107
|
-
tls: config.tls,
|
|
108
|
-
allowedHosts: config.allowedHosts,
|
|
109
|
-
allowedOrigins: config.allowedOrigins,
|
|
110
|
-
enableDnsRebindingProtection: config.enableDnsRebindingProtection,
|
|
111
|
-
// No runtime session file and no leftover-session tool: one server holds
|
|
112
|
-
// the sessions of many users, so they are stdio's only.
|
|
113
|
-
// Background runs of the run tools, kept in this process's memory and
|
|
114
|
-
// handed to every SSE session's instance; they end with the process.
|
|
115
|
-
// Only where the set serves them: a -ro command has none, so a run's
|
|
116
|
-
// `background: true` is refused.
|
|
117
|
-
...(options.toolSet.backgroundRuns && {
|
|
118
|
-
backgroundRuns: new background_runs_memory_1.InMemoryBackgroundRuns(),
|
|
119
|
-
}),
|
|
120
|
-
});
|
|
121
|
-
(0, http_transport_1.installTransportShutdown)({
|
|
122
|
-
stopListening: () => server.stopListening(),
|
|
123
|
-
release: () => server.releaseConnections(),
|
|
124
|
-
shutdownTimeoutMs: config.shutdownTimeout === undefined
|
|
125
|
-
? undefined
|
|
126
|
-
: config.shutdownTimeout * 1000,
|
|
127
|
-
exit: deps.exit,
|
|
128
|
-
stderr: deps.stderr,
|
|
129
|
-
processLike: deps.processLike,
|
|
130
|
-
});
|
|
131
|
-
await server.start();
|
|
132
|
-
return server;
|
|
29
|
+
return (0, sse_1.launch)(config, withPackage(options), deps);
|
|
133
30
|
}
|
|
134
31
|
//# sourceMappingURL=launcher.js.map
|
package/dist/launcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.js","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcher.js","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAkCA,oBAKC;AAED,wBAMC;AAlCD,0DAK0C;AAC1C,mDAA8C;AAE9C,mEAAiD;AASjD,SAAS,WAAW,CAAC,OAA2B;IAC9C,OAAO,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,2BAAW,EAAE,CAAC;AACzE,CAAC;AAEM,KAAK,UAAU,IAAI,CACxB,OAA2B,EAC3B,KAAqB;IAErB,OAAO,IAAA,UAAW,EAAC,WAAW,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC;AAEM,KAAK,UAAU,MAAM,CAC1B,MAA2C,EAC3C,OAA2B,EAC3B,IAAqB;IAErB,OAAO,IAAA,YAAa,EAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/sseVersion.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@mcp-abap-adt/sse`'s own version, read from its own manifest: the version
|
|
3
|
-
* the transport reports in `serverInfo` and on `/health` when its caller
|
|
4
|
-
* passes none.
|
|
5
|
-
*
|
|
6
|
-
* One step up from this file is `sse/` in a checkout (`src/` under test,
|
|
7
|
-
* `dist/` when built) and the package root when installed — in every layout it
|
|
8
|
-
* is this package's `package.json`.
|
|
9
|
-
*/
|
|
10
1
|
export declare const SSE_VERSION: string;
|
|
2
|
+
/** `@mcp-abap-adt/sse`'s own package name, from the same manifest: what a second copy of lib asks to reinstall. */
|
|
3
|
+
export declare const SSE_PACKAGE: string;
|
|
11
4
|
//# sourceMappingURL=sseVersion.d.ts.map
|
package/dist/sseVersion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sseVersion.d.ts","sourceRoot":"","sources":["../src/sseVersion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sseVersion.d.ts","sourceRoot":"","sources":["../src/sseVersion.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,WAAW,EAAE,MAAyB,CAAC;AAEpD,mHAAmH;AACnH,eAAO,MAAM,WAAW,EAAE,MAAsB,CAAC"}
|
package/dist/sseVersion.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SSE_VERSION = void 0;
|
|
3
|
+
exports.SSE_PACKAGE = exports.SSE_VERSION = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
/**
|
|
@@ -12,5 +12,8 @@ const node_path_1 = require("node:path");
|
|
|
12
12
|
* `dist/` when built) and the package root when installed — in every layout it
|
|
13
13
|
* is this package's `package.json`.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
const manifest = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', 'package.json'), 'utf8'));
|
|
16
|
+
exports.SSE_VERSION = manifest.version;
|
|
17
|
+
/** `@mcp-abap-adt/sse`'s own package name, from the same manifest: what a second copy of lib asks to reinstall. */
|
|
18
|
+
exports.SSE_PACKAGE = manifest.name;
|
|
16
19
|
//# sourceMappingURL=sseVersion.js.map
|
package/dist/sseVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sseVersion.js","sourceRoot":"","sources":["../src/sseVersion.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,yCAAiC;AAEjC;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"sseVersion.js","sourceRoot":"","sources":["../src/sseVersion.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,yCAAiC;AAEjC;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAsC,IAAI,CAAC,KAAK,CAC5D,IAAA,sBAAY,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAC5D,CAAC;AAEW,QAAA,WAAW,GAAW,QAAQ,CAAC,OAAO,CAAC;AAEpD,mHAAmH;AACtG,QAAA,WAAW,GAAW,QAAQ,CAAC,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/sse",
|
|
3
3
|
"mcpName": "io.github.fr0ster/mcp-abap-adt-sse",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "20.0.0",
|
|
5
5
|
"description": "The HTTP+SSE transport of the MCP ABAP ADT server: an Express app serving the ADT tools of @mcp-abap-adt/lib over the MCP HTTP+SSE transport, with DNS rebinding protection and TLS.",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"publishConfig": {
|
|
@@ -57,19 +57,17 @@
|
|
|
57
57
|
],
|
|
58
58
|
"scripts": {
|
|
59
59
|
"prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
60
|
-
"build": "
|
|
60
|
+
"build": "tsc -p tsconfig.json",
|
|
61
61
|
"test": "npm --prefix .. test -- --roots sse/src",
|
|
62
|
-
"test:check": "
|
|
63
|
-
"lint:check": "
|
|
62
|
+
"test:check": "tsc --noEmit -p tsconfig.test.json",
|
|
63
|
+
"lint:check": "biome check src",
|
|
64
64
|
"prepublishOnly": "npm run build"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@mcp-abap-adt/background-runs-memory": "^
|
|
68
|
-
"@mcp-abap-adt/lib": "^
|
|
69
|
-
"@mcp-abap-adt/
|
|
70
|
-
"@mcp-abap-adt/
|
|
71
|
-
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
72
|
-
"express": "^5.2.1"
|
|
67
|
+
"@mcp-abap-adt/background-runs-memory": "^20.0.0",
|
|
68
|
+
"@mcp-abap-adt/lib": "^20.0.0",
|
|
69
|
+
"@mcp-abap-adt/responsible-rules": "^20.0.0",
|
|
70
|
+
"@mcp-abap-adt/server-runtime": "^20.0.0"
|
|
73
71
|
},
|
|
74
72
|
"devDependencies": {
|
|
75
73
|
"@types/express": "*",
|
package/dist/SseServer.d.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
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
|
package/dist/SseServer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;IAClC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,E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AAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA8B;IAC7D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwC;IACtE,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAwB;gBAGpC,gBAAgB,EAAE,iBAAiB,EACpD,IAAI,CAAC,EAAE,gBAAgB;IA2BzB;;;;;;OAMG;IACH,cAAc,CACZ,GAAG,EAAE,gBAAgB,EACrB,QAAQ,CAAC,EAAE,wBAAwB,GAClC,IAAI;IA4CP;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmC5B,6FAA6F;IAC7F,aAAa,IAAI,IAAI;IAUrB;;;;;;OAMG;IACH,kBAAkB,IAAI,IAAI;IAK1B;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B,6EAA6E;YAC/D,QAAQ;YAIR,SAAS;IAsHvB;;;;;;;OAOG;YACW,eAAe;YAcf,UAAU;IA4DxB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAKpB,0FAA0F;IAC1F,OAAO,CAAC,aAAa;CAatB"}
|
package/dist/SseServer.js
DELETED
|
@@ -1,384 +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.SseServer = 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 sse_js_1 = require("@modelcontextprotocol/sdk/server/sse.js");
|
|
15
|
-
const express_1 = __importDefault(require("express"));
|
|
16
|
-
const sseVersion_js_1 = require("./sseVersion.js");
|
|
17
|
-
/**
|
|
18
|
-
* The SSE server: a `GET` opens a connection and builds one
|
|
19
|
-
* `BaseMcpServer` for it, whose source is that `GET`'s `x-sap-*` headers
|
|
20
|
-
* (lib's `headerSource`) — one per connection, shared with no other and
|
|
21
|
-
* outliving none. A `POST` is routed by its `sessionId` alone: its own
|
|
22
|
-
* `x-sap-*` headers are not read. A `GET` without credentials, and a `GET` or
|
|
23
|
-
* a `POST` carrying `x-mcp-destination`, are answered `400`.
|
|
24
|
-
*
|
|
25
|
-
* Supports two modes:
|
|
26
|
-
* 1. Standalone mode: Creates its own Express server (when no app option provided)
|
|
27
|
-
* 2. Embedded mode: Registers routes on external app (when app option provided)
|
|
28
|
-
*/
|
|
29
|
-
class SseServer {
|
|
30
|
-
handlersRegistry;
|
|
31
|
-
host;
|
|
32
|
-
port;
|
|
33
|
-
ssePath;
|
|
34
|
-
postPath;
|
|
35
|
-
sessions = new Map();
|
|
36
|
-
/**
|
|
37
|
-
* Every connection from its `GET` until its close settled — being set up,
|
|
38
|
-
* open, or closing — with its one cleanup (the instance close): a
|
|
39
|
-
* shutdown runs it for the open ones and joins the ones already closing
|
|
40
|
-
* A close that settled before the shutdown is only logged.
|
|
41
|
-
*/
|
|
42
|
-
connections = new Map();
|
|
43
|
-
logger;
|
|
44
|
-
version;
|
|
45
|
-
externalApp;
|
|
46
|
-
standaloneServer;
|
|
47
|
-
/** The listener stopped, until its last connections are closed after the last step. */
|
|
48
|
-
stoppedListener;
|
|
49
|
-
tls;
|
|
50
|
-
allowedHosts;
|
|
51
|
-
allowedOrigins;
|
|
52
|
-
enableDnsRebindingProtection;
|
|
53
|
-
stateIdleMinutes;
|
|
54
|
-
stateLogger;
|
|
55
|
-
backgroundRuns;
|
|
56
|
-
batchSettings;
|
|
57
|
-
/** The corrected header pairs: the process's, shared by every stream's instance. */
|
|
58
|
-
adtHeaderPairs = new embeddable_1.AdtHeaderPairs();
|
|
59
|
-
constructor(handlersRegistry, opts) {
|
|
60
|
-
this.handlersRegistry = handlersRegistry;
|
|
61
|
-
this.host = opts?.host ?? '127.0.0.1';
|
|
62
|
-
this.port = opts?.port ?? 3001;
|
|
63
|
-
this.ssePath = opts?.ssePath ?? '/sse';
|
|
64
|
-
this.postPath = opts?.postPath ?? '/messages';
|
|
65
|
-
this.logger = opts?.logger ?? logger_1.noopLogger;
|
|
66
|
-
this.version = opts?.version ?? sseVersion_js_1.SSE_VERSION;
|
|
67
|
-
this.externalApp = opts?.app;
|
|
68
|
-
this.tls = opts?.tls;
|
|
69
|
-
this.allowedHosts = opts?.allowedHosts;
|
|
70
|
-
this.allowedOrigins = opts?.allowedOrigins;
|
|
71
|
-
this.enableDnsRebindingProtection = opts?.enableDnsRebindingProtection;
|
|
72
|
-
// Refused here, at startup, rather than at a session's first request.
|
|
73
|
-
this.stateIdleMinutes =
|
|
74
|
-
opts?.stateIdleMinutes === undefined
|
|
75
|
-
? undefined
|
|
76
|
-
: (0, state_1.parseStateIdleMinutes)(opts.stateIdleMinutes, 'stateIdleMinutes');
|
|
77
|
-
// From the options as given: the silent default of `this.logger` is never the state's.
|
|
78
|
-
this.stateLogger = (0, state_1.stateLoggerOf)(opts ?? {});
|
|
79
|
-
this.backgroundRuns = opts?.backgroundRuns;
|
|
80
|
-
this.batchSettings =
|
|
81
|
-
opts?.batch === undefined
|
|
82
|
-
? undefined
|
|
83
|
-
: { keepRawParts: opts.batch.keepRawParts === true };
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Register routes on an external HTTP application
|
|
87
|
-
* Use this when integrating with existing Express/CDS/CAP server
|
|
88
|
-
*
|
|
89
|
-
* @param app - External HTTP application (Express, CDS, etc.)
|
|
90
|
-
* @param options - Route registration options
|
|
91
|
-
*/
|
|
92
|
-
registerRoutes(app, _options) {
|
|
93
|
-
// Health check endpoint — lightweight, no MCP protocol logic
|
|
94
|
-
app.get('/mcp/health', ((_req, res) => {
|
|
95
|
-
res.json({
|
|
96
|
-
status: 'ok',
|
|
97
|
-
uptime: Math.floor(process.uptime()),
|
|
98
|
-
version: this.version,
|
|
99
|
-
transport: 'sse',
|
|
100
|
-
activeSessions: this.sessions.size,
|
|
101
|
-
});
|
|
102
|
-
}));
|
|
103
|
-
const dnsOpts = {
|
|
104
|
-
enable: this.enableDnsRebindingProtection,
|
|
105
|
-
allowedHosts: this.allowedHosts,
|
|
106
|
-
allowedOrigins: this.allowedOrigins,
|
|
107
|
-
};
|
|
108
|
-
app.get(this.ssePath, (0, http_transport_1.withDnsRebindingProtection)((async (req, res) => {
|
|
109
|
-
await this.handleGet(req, res);
|
|
110
|
-
}), dnsOpts));
|
|
111
|
-
app.post(this.postPath, (0, http_transport_1.withDnsRebindingProtection)((async (req, res) => {
|
|
112
|
-
const url = new URL(req.originalUrl, `http://${req.headers.host}`);
|
|
113
|
-
await this.handlePost(req, res, url);
|
|
114
|
-
}), dnsOpts));
|
|
115
|
-
console.error(`[SseServer] Routes registered on external app`);
|
|
116
|
-
console.error(`[SseServer] SSE endpoint: ${this.ssePath}`);
|
|
117
|
-
console.error(`[SseServer] POST endpoint: ${this.postPath}`);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get the configured SSE endpoint path
|
|
121
|
-
*/
|
|
122
|
-
getSsePath() {
|
|
123
|
-
return this.ssePath;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get the configured POST endpoint path
|
|
127
|
-
*/
|
|
128
|
-
getPostPath() {
|
|
129
|
-
return this.postPath;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Start the server
|
|
133
|
-
*
|
|
134
|
-
* In standalone mode (no external app): Creates Express server and starts listening
|
|
135
|
-
* In embedded mode (external app provided): Only registers routes on external app
|
|
136
|
-
*/
|
|
137
|
-
async start() {
|
|
138
|
-
// If external app was provided in constructor, register routes on it
|
|
139
|
-
if (this.externalApp) {
|
|
140
|
-
this.registerRoutes(this.externalApp);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
// Standalone mode: create own Express server
|
|
144
|
-
const app = (0, express_1.default)();
|
|
145
|
-
app.use(express_1.default.json());
|
|
146
|
-
this.registerRoutes(app);
|
|
147
|
-
await new Promise((resolve, reject) => {
|
|
148
|
-
const protocol = (0, http_transport_1.getProtocol)(this.tls);
|
|
149
|
-
const server = (0, http_transport_1.createServerListener)(app, this.tls);
|
|
150
|
-
this.standaloneServer = server;
|
|
151
|
-
server.listen(this.port, this.host);
|
|
152
|
-
server.once('listening', () => {
|
|
153
|
-
console.error(`[SseServer] Server started on ${this.host}:${this.port}`);
|
|
154
|
-
console.error(`[SseServer] SSE endpoint: ${protocol}://${this.host}:${this.port}${this.ssePath}`);
|
|
155
|
-
console.error(`[SseServer] POST endpoint: ${protocol}://${this.host}:${this.port}${this.postPath}`);
|
|
156
|
-
resolve();
|
|
157
|
-
});
|
|
158
|
-
server.once('error', reject);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/** Stops taking connections. Embedded on an external app there is no listener of its own. */
|
|
162
|
-
stopListening() {
|
|
163
|
-
const server = this.standaloneServer;
|
|
164
|
-
if (server) {
|
|
165
|
-
this.standaloneServer = undefined;
|
|
166
|
-
this.stoppedListener = server;
|
|
167
|
-
server.close();
|
|
168
|
-
server.closeIdleConnections();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The launcher's shutdown, after the logoffs (lib's
|
|
173
|
-
* `installTransportShutdown`), and `stop()`: nothing is answered any more —
|
|
174
|
-
* the connections still open on the stopped listener (a request whose tool
|
|
175
|
-
* was interrupted, a client's idle keep-alive) are closed, so none keeps
|
|
176
|
-
* the process alive.
|
|
177
|
-
*/
|
|
178
|
-
releaseConnections() {
|
|
179
|
-
this.stoppedListener?.closeAllConnections();
|
|
180
|
-
this.stoppedListener = undefined;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* For a host that stops the server itself (embedded): the listener
|
|
184
|
-
* closes, then every connection's instance close — its connections logged
|
|
185
|
-
* off at once, its calls interrupted (no tool awaited, no timer). A
|
|
186
|
-
* launcher's shutdown does not run this: it logs every connection the
|
|
187
|
-
* process owns off at once and interrupts every running tool (lib's
|
|
188
|
-
* `installTransportShutdown`).
|
|
189
|
-
*/
|
|
190
|
-
async stop() {
|
|
191
|
-
this.stopListening();
|
|
192
|
-
await this.closeAll();
|
|
193
|
-
this.releaseConnections();
|
|
194
|
-
}
|
|
195
|
-
/** The instance close of every connection, joined where one runs already. */
|
|
196
|
-
async closeAll() {
|
|
197
|
-
await Promise.all([...this.connections.values()].map((c) => c.close()));
|
|
198
|
-
}
|
|
199
|
-
async handleGet(req, res) {
|
|
200
|
-
// The shutdown began: no new connection (embedded hosts keep their
|
|
201
|
-
// listener; a launcher's is closed already).
|
|
202
|
-
if ((0, state_1.isLatched)()) {
|
|
203
|
-
if (!res.headersSent)
|
|
204
|
-
res.writeHead(503).end('the server is shutting down');
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
// The connection's source, from this GET's x-sap-* headers alone; a
|
|
208
|
-
// header this server no longer serves is refused, never ignored.
|
|
209
|
-
let context;
|
|
210
|
-
try {
|
|
211
|
-
context = (0, http_transport_1.headerContext)(req.headers);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
this.answerFailure(res, error);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
this.logger.debug('SSE GET: credentials from x-sap-* headers');
|
|
218
|
-
class SessionServer extends embeddable_1.BaseMcpServer {
|
|
219
|
-
registry;
|
|
220
|
-
loggerImpl;
|
|
221
|
-
ver;
|
|
222
|
-
constructor(registry, loggerImpl, ver, state) {
|
|
223
|
-
super({
|
|
224
|
-
name: 'mcp-abap-adt-sse',
|
|
225
|
-
version: ver,
|
|
226
|
-
logger: loggerImpl,
|
|
227
|
-
...state,
|
|
228
|
-
// The responsible rules, once per stream, when its connection is
|
|
229
|
-
// created.
|
|
230
|
-
systemContextResolver: request_context_1.defaultSystemContextResolver,
|
|
231
|
-
systemContextRules: responsible_rules_1.responsibleRules,
|
|
232
|
-
});
|
|
233
|
-
this.registry = registry;
|
|
234
|
-
this.loggerImpl = loggerImpl;
|
|
235
|
-
this.ver = ver;
|
|
236
|
-
}
|
|
237
|
-
init(connectionContext) {
|
|
238
|
-
this.setConnectionContext(connectionContext);
|
|
239
|
-
this.registerHandlers(this.registry);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
const server = new SessionServer(this.handlersRegistry, this.logger, this.version, {
|
|
243
|
-
stateIdleMinutes: this.stateIdleMinutes,
|
|
244
|
-
stateLogger: this.stateLogger,
|
|
245
|
-
...(this.backgroundRuns !== undefined && {
|
|
246
|
-
backgroundRuns: this.backgroundRuns,
|
|
247
|
-
}),
|
|
248
|
-
// Batch mode: this connection's own, never shared with another.
|
|
249
|
-
...(this.batchSettings !== undefined && {
|
|
250
|
-
batch: new embeddable_1.InstanceBatch(this.batchSettings),
|
|
251
|
-
}),
|
|
252
|
-
adtHeaderPairs: this.adtHeaderPairs,
|
|
253
|
-
});
|
|
254
|
-
server.init(context);
|
|
255
|
-
const transport = new sse_js_1.SSEServerTransport(this.postPath, res);
|
|
256
|
-
const sessionId = transport.sessionId;
|
|
257
|
-
console.error(`[SSE GET] Created session ${sessionId}`);
|
|
258
|
-
// Capture what the session states (x-sap-language, x-sap-responsible,
|
|
259
|
-
// x-sap-master-system) once at connection time; it is scoped around each
|
|
260
|
-
// POST dispatch below so it never leaks into other sessions via a
|
|
261
|
-
// process-global cache (#110).
|
|
262
|
-
const requestContext = (0, request_context_1.requestContextFromHeaders)(req.headers);
|
|
263
|
-
// The close tracking comes first, before the first setup await: the response's close, the stream's failure and a rejected
|
|
264
|
-
// connect all reach this one cleanup — the instance close, once.
|
|
265
|
-
let cleanup;
|
|
266
|
-
const close = () => {
|
|
267
|
-
cleanup ??= this.closeConnection(sessionId, server);
|
|
268
|
-
return cleanup;
|
|
269
|
-
};
|
|
270
|
-
this.connections.set(server, { sessionId, close });
|
|
271
|
-
res.on('close', () => {
|
|
272
|
-
console.error(`[SSE CLOSE] Connection closed for session ${sessionId}`);
|
|
273
|
-
void close();
|
|
274
|
-
});
|
|
275
|
-
res.on('error', () => {
|
|
276
|
-
void close();
|
|
277
|
-
});
|
|
278
|
-
try {
|
|
279
|
-
await server.connect(transport);
|
|
280
|
-
this.logger.debug(`SSE GET: server connected for session ${sessionId}`);
|
|
281
|
-
}
|
|
282
|
-
catch (error) {
|
|
283
|
-
this.logger.error(`SSE GET: failed to connect for session ${sessionId}: ${this.failureWords(error)}`);
|
|
284
|
-
if (!res.headersSent) {
|
|
285
|
-
res.writeHead(500).end('Internal Server Error');
|
|
286
|
-
}
|
|
287
|
-
void close();
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
// An instance whose connection closed during setup is never published.
|
|
291
|
-
if (cleanup !== undefined)
|
|
292
|
-
return;
|
|
293
|
-
this.sessions.set(sessionId, { server, transport, requestContext });
|
|
294
|
-
console.error(`[SSE GET] Session stored, total sessions: ${this.sessions.size}`);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* One connection's cleanup — the client closed its stream, as a
|
|
298
|
-
* stdio client closes stdin: the session leaves the routing map first
|
|
299
|
-
* (main's: a later `POST` for it is an unknown session), then the instance
|
|
300
|
-
* close — the instance latch, its connections logged off at once and its
|
|
301
|
-
* running and queued calls interrupted in the same tick (no tool awaited),
|
|
302
|
-
* its state let go, its MCP server and stream closed.
|
|
303
|
-
*/
|
|
304
|
-
async closeConnection(sessionId, server) {
|
|
305
|
-
if (this.sessions.get(sessionId)?.server === server) {
|
|
306
|
-
this.sessions.delete(sessionId);
|
|
307
|
-
}
|
|
308
|
-
try {
|
|
309
|
-
await (0, embeddable_1.closeInstance)(server);
|
|
310
|
-
}
|
|
311
|
-
finally {
|
|
312
|
-
this.connections.delete(server);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
async handlePost(req, res, url) {
|
|
316
|
-
// A header this server no longer serves is refused on a POST too; the
|
|
317
|
-
// POST's own x-sap-* headers are not read (the connection's are its GET's).
|
|
318
|
-
try {
|
|
319
|
-
(0, http_transport_1.refuseDestinationHeader)(req.headers);
|
|
320
|
-
}
|
|
321
|
-
catch (error) {
|
|
322
|
-
this.answerFailure(res, error);
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const sessionId = (url?.searchParams.get('sessionId') ||
|
|
326
|
-
req.headers['x-session-id'] ||
|
|
327
|
-
'');
|
|
328
|
-
const mcpMethod = req.body?.method;
|
|
329
|
-
const isPing = mcpMethod === 'ping';
|
|
330
|
-
if (!isPing) {
|
|
331
|
-
console.error(`[SSE POST] sessionId=${sessionId}, activeSessions=${this.sessions.size}, keys=[${Array.from(this.sessions.keys()).join(', ')}]`);
|
|
332
|
-
}
|
|
333
|
-
const entry = this.sessions.get(sessionId);
|
|
334
|
-
if (!entry) {
|
|
335
|
-
console.error(`[SSE POST] Invalid session ${sessionId} - session not found!`);
|
|
336
|
-
res.writeHead(400).end('Invalid session');
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
// Pass pre-parsed body from express.json() middleware (like reference implementation)
|
|
340
|
-
// express.json() already read and parsed the body into req.body
|
|
341
|
-
if (!isPing) {
|
|
342
|
-
console.error(`[SSE POST] Calling handlePostMessage with req.body for session ${sessionId}`);
|
|
343
|
-
}
|
|
344
|
-
try {
|
|
345
|
-
await (0, request_context_1.runWithRequestContext)({ ...entry.requestContext }, () => entry.transport.handlePostMessage(req, res, req.body));
|
|
346
|
-
if (!isPing) {
|
|
347
|
-
console.error(`[SSE POST] Successfully processed for session ${sessionId}`);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
catch (error) {
|
|
351
|
-
// Fixed words and what the reader makes of it — never its message.
|
|
352
|
-
console.error(`[SSE POST] FAILED for session ${sessionId}: ${this.failureWords(error)}`);
|
|
353
|
-
if (!res.headersSent) {
|
|
354
|
-
res.writeHead(500).end('Internal Server Error');
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* What a log line says of a thrown value: `logFields` of the failure the
|
|
360
|
-
* reader knows, else its class only — a message may quote a file.
|
|
361
|
-
*/
|
|
362
|
-
failureWords(error) {
|
|
363
|
-
const answer = (0, http_transport_1.requestFailureAnswer)(error);
|
|
364
|
-
return answer.logLine ?? (0, auth_1.errorClassOf)(error);
|
|
365
|
-
}
|
|
366
|
-
/** A request refused or failed: the refusal's words (400), the reader's, or as before. */
|
|
367
|
-
answerFailure(res, error) {
|
|
368
|
-
const answer = (0, http_transport_1.requestFailureAnswer)(error);
|
|
369
|
-
if (answer.logLine !== undefined)
|
|
370
|
-
console.error(answer.logLine);
|
|
371
|
-
if (answer.known) {
|
|
372
|
-
console.error(`[SSE] FAILED: ${answer.text}`);
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
// No words for it: its class only — a message may quote a file (H4).
|
|
376
|
-
console.error(`[SSE] FAILED: ${(0, auth_1.errorClassOf)(error)}`);
|
|
377
|
-
}
|
|
378
|
-
if (!res.headersSent) {
|
|
379
|
-
res.status(answer.status).send(answer.text);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
exports.SseServer = SseServer;
|
|
384
|
-
//# sourceMappingURL=SseServer.js.map
|
package/dist/SseServer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SseServer.js","sourceRoot":"","sources":["../src/SseServer.ts"],"names":[],"mappings":";;;;;;AAEA,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-
*. No destination, login or Streamable HTTP option is here; the CLI or
|
|
5
|
-
* YAML form of one — or any form of `--transport`, which is gone — stops the
|
|
6
|
-
* start naming the binary that serves it. Their environment variables
|
|
7
|
-
* are not read.
|
|
8
|
-
*/
|
|
9
|
-
import { type IServerConfig, type Parameter, type ParameterTable, type TlsConfig, type YamlConfig } from '@mcp-abap-adt/lib/config';
|
|
10
|
-
import { type ToolSet } from '@mcp-abap-adt/lib/tool-set';
|
|
11
|
-
/** The SSE rows: today's names. */
|
|
12
|
-
export declare const SSE_ROWS: readonly Parameter[];
|
|
13
|
-
/**
|
|
14
|
-
* sse's table for a tool set: its rows, the shared rows, and what it
|
|
15
|
-
* refuses — the set's removed `--exposition` among them, naming the sse
|
|
16
|
-
* binary its words asked for. `mcp-abap-adt-sse-ro`, `mcp-abap-adt-compact-sse`
|
|
17
|
-
* and `mcp-abap-adt-compact-sse-ro` are this table with their own set,
|
|
18
|
-
* nothing else.
|
|
19
|
-
*/
|
|
20
|
-
export declare function sseParameters(toolSet: ToolSet, program?: string): ParameterTable;
|
|
21
|
-
/** `mcp-abap-adt-sse`'s table: sse's, with the full tool set. */
|
|
22
|
-
export declare const SSE_PARAMETERS: ParameterTable;
|
|
23
|
-
/** What `mcp-abap-adt-sse` reads. */
|
|
24
|
-
export interface SseConfig extends IServerConfig {
|
|
25
|
-
host?: string;
|
|
26
|
-
port?: number;
|
|
27
|
-
/** The path of the GET that opens an SSE connection */
|
|
28
|
-
ssePath?: string;
|
|
29
|
-
/** The path of a connection's POST messages */
|
|
30
|
-
postPath?: string;
|
|
31
|
-
/** Allowed Host header values (DNS-rebinding protection; exact, incl. port) */
|
|
32
|
-
allowedHosts?: string[];
|
|
33
|
-
/** Allowed Origin header values (DNS-rebinding protection; exact, incl. scheme) */
|
|
34
|
-
allowedOrigins?: string[];
|
|
35
|
-
/** Enable DNS-rebinding protection */
|
|
36
|
-
enableDnsRebindingProtection?: boolean;
|
|
37
|
-
/** TLS: cert and key start HTTPS */
|
|
38
|
-
tls?: TlsConfig;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* `mcp-abap-adt-sse`'s configuration from the arguments, the environment and
|
|
42
|
-
* the loaded config file. A removed parameter, or an invalid value, throws a
|
|
43
|
-
* `ParameterRefusal` in its words.
|
|
44
|
-
*/
|
|
45
|
-
export declare function readSseConfig(argv: readonly string[], env: NodeJS.ProcessEnv, yaml?: YamlConfig | null, toolSet?: ToolSet): SseConfig;
|
|
46
|
-
//# sourceMappingURL=sseParameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sseParameters.d.ts","sourceRoot":"","sources":["../../src/config/sseParameters.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,cAAc,EAMnB,KAAK,SAAS,EAId,KAAK,UAAU,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKvE,mCAAmC;AACnC,eAAO,MAAM,QAAQ,EAAE,SAAS,SAAS,EAiExC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,SAAqB,GAC3B,cAAc,CAmBhB;AAED,iEAAiE;AACjE,eAAO,MAAM,cAAc,EAAE,cAA2C,CAAC;AAEzE,qCAAqC;AACrC,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+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,aAAa,CAC3B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,GAAE,UAAU,GAAG,IAAW,EAC9B,OAAO,GAAE,OAAqB,GAC7B,SAAS,CAoBX"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* `mcp-abap-adt-sse`'s parameter table: every SSE
|
|
4
|
-
* option of today under its name, beside lib's shared rows and the TLS rows
|
|
5
|
-
*. No destination, login or Streamable HTTP option is here; the CLI or
|
|
6
|
-
* YAML form of one — or any form of `--transport`, which is gone — stops the
|
|
7
|
-
* start naming the binary that serves it. Their environment variables
|
|
8
|
-
* are not read.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.SSE_PARAMETERS = exports.SSE_ROWS = void 0;
|
|
12
|
-
exports.sseParameters = sseParameters;
|
|
13
|
-
exports.readSseConfig = readSseConfig;
|
|
14
|
-
const config_1 = require("@mcp-abap-adt/lib/config");
|
|
15
|
-
const tool_set_1 = require("@mcp-abap-adt/lib/tool-set");
|
|
16
|
-
const responsible_rules_1 = require("@mcp-abap-adt/responsible-rules");
|
|
17
|
-
const SSE = 'SSE';
|
|
18
|
-
/** The SSE rows: today's names. */
|
|
19
|
-
exports.SSE_ROWS = [
|
|
20
|
-
{
|
|
21
|
-
key: 'host',
|
|
22
|
-
cli: '--sse-host',
|
|
23
|
-
env: 'MCP_SSE_HOST',
|
|
24
|
-
yaml: 'sse.host',
|
|
25
|
-
kind: 'string',
|
|
26
|
-
default: '127.0.0.1',
|
|
27
|
-
valueHint: '=<host>',
|
|
28
|
-
section: SSE,
|
|
29
|
-
help: 'Host to listen on (default 127.0.0.1, this machine only; 0.0.0.0 for every interface)',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
key: 'port',
|
|
33
|
-
cli: '--sse-port',
|
|
34
|
-
env: 'MCP_SSE_PORT',
|
|
35
|
-
yaml: 'sse.port',
|
|
36
|
-
kind: 'port',
|
|
37
|
-
default: 3001,
|
|
38
|
-
section: SSE,
|
|
39
|
-
help: 'Port to listen on, 1-65535 (default 3001)',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
key: 'ssePath',
|
|
43
|
-
cli: '--sse-path',
|
|
44
|
-
kind: 'string',
|
|
45
|
-
valueHint: '=<path>',
|
|
46
|
-
section: SSE,
|
|
47
|
-
help: 'The path of the GET that opens an SSE connection (default /sse)',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
key: 'postPath',
|
|
51
|
-
cli: '--post-path',
|
|
52
|
-
kind: 'string',
|
|
53
|
-
valueHint: '=<path>',
|
|
54
|
-
section: SSE,
|
|
55
|
-
help: "The path of a connection's POST messages (default /messages)",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
key: 'allowedHosts',
|
|
59
|
-
cli: '--sse-allowed-hosts',
|
|
60
|
-
env: 'MCP_SSE_ALLOWED_HOSTS',
|
|
61
|
-
yaml: 'sse.allowed-hosts',
|
|
62
|
-
kind: 'list',
|
|
63
|
-
section: SSE,
|
|
64
|
-
help: 'Host header values accepted with DNS-rebinding protection (exact, with the port), comma-separated',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: 'allowedOrigins',
|
|
68
|
-
cli: '--sse-allowed-origins',
|
|
69
|
-
env: 'MCP_SSE_ALLOWED_ORIGINS',
|
|
70
|
-
yaml: 'sse.allowed-origins',
|
|
71
|
-
kind: 'list',
|
|
72
|
-
section: SSE,
|
|
73
|
-
help: 'Origin header values accepted with DNS-rebinding protection (exact, with the scheme), comma-separated',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
key: 'enableDnsRebindingProtection',
|
|
77
|
-
cli: '--sse-enable-dns-protection',
|
|
78
|
-
env: 'MCP_SSE_ENABLE_DNS_PROTECTION',
|
|
79
|
-
yaml: 'sse.enable-dns-protection',
|
|
80
|
-
kind: 'flag',
|
|
81
|
-
section: SSE,
|
|
82
|
-
help: 'Enable DNS-rebinding protection (with --sse-allowed-hosts and/or --sse-allowed-origins)',
|
|
83
|
-
},
|
|
84
|
-
];
|
|
85
|
-
/**
|
|
86
|
-
* sse's table for a tool set: its rows, the shared rows, and what it
|
|
87
|
-
* refuses — the set's removed `--exposition` among them, naming the sse
|
|
88
|
-
* binary its words asked for. `mcp-abap-adt-sse-ro`, `mcp-abap-adt-compact-sse`
|
|
89
|
-
* and `mcp-abap-adt-compact-sse-ro` are this table with their own set,
|
|
90
|
-
* nothing else.
|
|
91
|
-
*/
|
|
92
|
-
function sseParameters(toolSet, program = 'mcp-abap-adt-sse') {
|
|
93
|
-
return {
|
|
94
|
-
program,
|
|
95
|
-
rows: [
|
|
96
|
-
config_1.CONF_ROW,
|
|
97
|
-
responsible_rules_1.SYSTEM_TYPE_ROW,
|
|
98
|
-
...exports.SSE_ROWS,
|
|
99
|
-
...(0, config_1.tlsRows)('sse'),
|
|
100
|
-
config_1.STATE_IDLE_ROW,
|
|
101
|
-
config_1.BATCH_KEEP_RAW_PARTS_ROW,
|
|
102
|
-
config_1.SHUTDOWN_TIMEOUT_ROW,
|
|
103
|
-
],
|
|
104
|
-
removed: [
|
|
105
|
-
toolSet.expositionRemoved('sse'),
|
|
106
|
-
(0, config_1.transportRemoved)('sse'),
|
|
107
|
-
config_1.DESTINATION_OPTIONS_REMOVED,
|
|
108
|
-
config_1.HTTP_OPTIONS_REMOVED,
|
|
109
|
-
],
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
/** `mcp-abap-adt-sse`'s table: sse's, with the full tool set. */
|
|
113
|
-
exports.SSE_PARAMETERS = sseParameters(tool_set_1.fullToolSet);
|
|
114
|
-
const list = (v) => Array.isArray(v) ? [...v] : undefined;
|
|
115
|
-
/**
|
|
116
|
-
* `mcp-abap-adt-sse`'s configuration from the arguments, the environment and
|
|
117
|
-
* the loaded config file. A removed parameter, or an invalid value, throws a
|
|
118
|
-
* `ParameterRefusal` in its words.
|
|
119
|
-
*/
|
|
120
|
-
function readSseConfig(argv, env, yaml = null, toolSet = tool_set_1.fullToolSet) {
|
|
121
|
-
const table = sseParameters(toolSet);
|
|
122
|
-
const values = (0, config_1.readParameters)(table, argv, env, yaml);
|
|
123
|
-
return {
|
|
124
|
-
configFile: values.configFile,
|
|
125
|
-
systemType: values.systemType,
|
|
126
|
-
systemTypeSource: (0, config_1.parameterSource)(table, 'systemType', argv, env, yaml),
|
|
127
|
-
stateIdleMinutes: values.stateIdleMinutes,
|
|
128
|
-
batchKeepRawParts: values.batchKeepRawParts === true,
|
|
129
|
-
shutdownTimeout: values.shutdownTimeout,
|
|
130
|
-
host: values.host,
|
|
131
|
-
port: values.port,
|
|
132
|
-
ssePath: values.ssePath,
|
|
133
|
-
postPath: values.postPath,
|
|
134
|
-
allowedHosts: list(values.allowedHosts),
|
|
135
|
-
allowedOrigins: list(values.allowedOrigins),
|
|
136
|
-
enableDnsRebindingProtection: values.enableDnsRebindingProtection ?? false,
|
|
137
|
-
tls: (0, config_1.tlsConfigOf)(values),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
//# sourceMappingURL=sseParameters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sseParameters.js","sourceRoot":"","sources":["../../src/config/sseParameters.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAqGH,sCAsBC;AA+BD,sCAyBC;AAjLD,qDAkBkC;AAClC,yDAAuE;AACvE,uEAAkE;AAElE,MAAM,GAAG,GAAG,KAAK,CAAC;AAElB,mCAAmC;AACtB,QAAA,QAAQ,GAAyB;IAC5C;QACE,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,YAAY;QACjB,GAAG,EAAE,cAAc;QACnB,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