@mcp-abap-adt/core 15.1.0 → 16.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,45 @@
1
+ /**
2
+ * The program's shutdown (spec §7). Installed by the launcher only — the
3
+ * program, not the library — so an embedder's process is never taken over.
4
+ *
5
+ * Triggers: `SIGTERM`, `SIGINT` and, for stdio, the end of stdin (the client
6
+ * went away). The first trigger runs the sequence; later ones wait for it:
7
+ *
8
+ * 1. `close()` every server: HTTP and SSE stop accepting connections. That
9
+ * does not stop requests already running — the gate in step 2 is what holds;
10
+ * 2. `settle(30_000)`: the factory closes its provider gate, waits for the
11
+ * provider calls already running, then flushes every broker;
12
+ * 3. exit `0` when everything is stored and nothing was abandoned; otherwise
13
+ * one stderr line per fact, and exit `1`.
14
+ *
15
+ * Nothing is written to stdout (H3), and no line carries an error's message:
16
+ * a class name, a destination and a count only (H4).
17
+ */
18
+ import type { EventEmitter } from 'node:events';
19
+ import { type SettleReport } from '@mcp-abap-adt/lib/auth';
20
+ /** The callback strategy's login timeout: a login waiting on a browser ends by then. */
21
+ export declare const SHUTDOWN_DEADLINE_MS = 30000;
22
+ export interface Closable {
23
+ close(): Promise<void> | void;
24
+ }
25
+ /** What the shutdown listens on: the process, or a test's stand-in. */
26
+ export type ShutdownProcess = EventEmitter & {
27
+ stdin?: EventEmitter;
28
+ };
29
+ export interface ShutdownOptions {
30
+ factory: {
31
+ settle(deadlineMs: number): Promise<SettleReport>;
32
+ };
33
+ servers: Closable[];
34
+ /** Whether the end of stdin is a trigger (stdio). */
35
+ onStdinEnd?: boolean;
36
+ exit: (code: number) => void;
37
+ stderr: (line: string) => void;
38
+ processLike: ShutdownProcess;
39
+ }
40
+ /**
41
+ * Installs the triggers and answers the sequence itself, for a caller that
42
+ * shuts down for its own reason. Every call answers the same run.
43
+ */
44
+ export declare function installShutdown(options: ShutdownOptions): () => Promise<void>;
45
+ //# sourceMappingURL=shutdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEzE,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/B;AAED,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IAAE,KAAK,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE;QAAE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;KAAE,CAAC;IAC/D,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,WAAW,EAAE,eAAe,CAAC;CAC9B;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CA+C7E"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * The program's shutdown (spec §7). Installed by the launcher only — the
4
+ * program, not the library — so an embedder's process is never taken over.
5
+ *
6
+ * Triggers: `SIGTERM`, `SIGINT` and, for stdio, the end of stdin (the client
7
+ * went away). The first trigger runs the sequence; later ones wait for it:
8
+ *
9
+ * 1. `close()` every server: HTTP and SSE stop accepting connections. That
10
+ * does not stop requests already running — the gate in step 2 is what holds;
11
+ * 2. `settle(30_000)`: the factory closes its provider gate, waits for the
12
+ * provider calls already running, then flushes every broker;
13
+ * 3. exit `0` when everything is stored and nothing was abandoned; otherwise
14
+ * one stderr line per fact, and exit `1`.
15
+ *
16
+ * Nothing is written to stdout (H3), and no line carries an error's message:
17
+ * a class name, a destination and a count only (H4).
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.SHUTDOWN_DEADLINE_MS = void 0;
21
+ exports.installShutdown = installShutdown;
22
+ const auth_1 = require("@mcp-abap-adt/lib/auth");
23
+ /** The callback strategy's login timeout: a login waiting on a browser ends by then. */
24
+ exports.SHUTDOWN_DEADLINE_MS = 30_000;
25
+ function abandonedLine(count) {
26
+ return count === 1
27
+ ? '[MCP] 1 authorization still running at shutdown, its result is lost'
28
+ : `[MCP] ${count} authorizations still running at shutdown, their results are lost`;
29
+ }
30
+ /**
31
+ * Installs the triggers and answers the sequence itself, for a caller that
32
+ * shuts down for its own reason. Every call answers the same run.
33
+ */
34
+ function installShutdown(options) {
35
+ const { factory, servers, exit, stderr, processLike } = options;
36
+ let running;
37
+ const sequence = async () => {
38
+ let failed = false;
39
+ await Promise.all(servers.map(async (server) => {
40
+ try {
41
+ await server.close();
42
+ }
43
+ catch (error) {
44
+ failed = true;
45
+ stderr(`[MCP] A server did not close at shutdown: ${(0, auth_1.errorClassOf)(error)}`);
46
+ }
47
+ }));
48
+ try {
49
+ const report = await factory.settle(exports.SHUTDOWN_DEADLINE_MS);
50
+ for (const entry of report.notStored) {
51
+ stderr(`[MCP] Session secrets not stored: ${entry}`);
52
+ }
53
+ if (report.abandoned > 0)
54
+ stderr(abandonedLine(report.abandoned));
55
+ if (report.notStored.length > 0 || report.abandoned > 0)
56
+ failed = true;
57
+ }
58
+ catch (error) {
59
+ failed = true;
60
+ stderr(`[MCP] Shutdown did not settle: ${(0, auth_1.errorClassOf)(error)}`);
61
+ }
62
+ exit(failed ? 1 : 0);
63
+ };
64
+ const run = () => {
65
+ running ??= sequence();
66
+ return running;
67
+ };
68
+ const trigger = () => {
69
+ void run();
70
+ };
71
+ processLike.on('SIGTERM', trigger);
72
+ processLike.on('SIGINT', trigger);
73
+ if (options.onStdinEnd) {
74
+ processLike.stdin?.on('end', trigger);
75
+ processLike.stdin?.on('close', trigger);
76
+ }
77
+ return run;
78
+ }
79
+ //# sourceMappingURL=shutdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAmCH,0CA+CC;AA/ED,iDAAyE;AAEzE,wFAAwF;AAC3E,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAmB3C,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK,KAAK,CAAC;QAChB,CAAC,CAAC,qEAAqE;QACvE,CAAC,CAAC,SAAS,KAAK,mEAAmE,CAAC;AACxF,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,OAAwB;IACtD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChE,IAAI,OAAkC,CAAC;IAEvC,MAAM,QAAQ,GAAG,KAAK,IAAmB,EAAE;QACzC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAC3B,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,IAAI,CAAC;gBACd,MAAM,CACJ,6CAA6C,IAAA,mBAAY,EAAC,KAAK,CAAC,EAAE,CACnE,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CACH,CAAC;QACF,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,M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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/core",
3
- "version": "15.1.0",
3
+ "version": "16.0.0",
4
4
  "description": "Standalone MCP server for SAP ABAP ADT: stdio, SSE and streamable HTTP transports.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "publishConfig": {
@@ -63,6 +63,7 @@
63
63
  "prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
64
64
  "build": "npx tsc -p tsconfig.json",
65
65
  "test": "jest --passWithNoTests",
66
+ "test:check": "npx tsc --noEmit -p tsconfig.test.json",
66
67
  "lint:check": "npx biome check src",
67
68
  "prepublishOnly": "npm run build",
68
69
  "start": "node ./bin/mcp-abap-adt.js",
@@ -92,9 +93,8 @@
92
93
  "docker:rebuild:headerless": "npm run docker:down:headerless && npm run docker:build:headerless && npm run docker:up:headerless"
93
94
  },
94
95
  "dependencies": {
95
- "@mcp-abap-adt/auth-broker": "^3.0.0",
96
96
  "@mcp-abap-adt/interfaces-utils": "^1.1.0",
97
- "@mcp-abap-adt/lib": "^15.1.0",
97
+ "@mcp-abap-adt/lib": "^16.0.0",
98
98
  "@mcp-abap-adt/logger": "^0.4.0",
99
99
  "@modelcontextprotocol/sdk": "^1.29.0",
100
100
  "dotenv": "^18.0.3",
@@ -108,7 +108,26 @@
108
108
  ],
109
109
  "testMatch": [
110
110
  "**/__tests__/**/*.test.ts"
111
- ]
111
+ ],
112
+ "transform": {
113
+ "^.+\\.ts$": [
114
+ "ts-jest",
115
+ {
116
+ "tsconfig": "tsconfig.test.json"
117
+ }
118
+ ]
119
+ },
120
+ "moduleNameMapper": {
121
+ "^@mcp-abap-adt/lib$": "<rootDir>/../src/index.ts",
122
+ "^@mcp-abap-adt/lib/handlers$": "<rootDir>/../src/lib/handlers/index.ts",
123
+ "^@mcp-abap-adt/lib/utils$": "<rootDir>/../src/lib/utils.ts",
124
+ "^@mcp-abap-adt/lib/embeddable$": "<rootDir>/../src/embeddable/index.ts",
125
+ "^@mcp-abap-adt/lib/config$": "<rootDir>/../src/lib/config/index.ts",
126
+ "^@mcp-abap-adt/lib/auth$": "<rootDir>/../src/lib/auth/index.ts",
127
+ "^@mcp-abap-adt/lib/logger$": "<rootDir>/../src/lib/handlerLogger.ts",
128
+ "^@mcp-abap-adt/lib/request-context$": "<rootDir>/../src/lib/requestContext.ts",
129
+ "^(\\.{1,2}/.*)\\.js$": "$1"
130
+ }
112
131
  },
113
132
  "devDependencies": {
114
133
  "@types/express": "*",
@@ -1,22 +0,0 @@
1
- /**
2
- * V2 Server configuration adapter for AuthBrokerFactory
3
- * Maps v2 ServerConfig to IAuthBrokerFactoryConfig
4
- */
5
- import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
6
- import type { IAuthBrokerFactoryConfig } from '@mcp-abap-adt/lib/auth';
7
- import type { IServerConfig } from '@mcp-abap-adt/lib/config';
8
- export declare class AuthBrokerConfig implements IAuthBrokerFactoryConfig {
9
- defaultMcpDestination?: string;
10
- defaultDestination?: string;
11
- envFilePath?: string;
12
- authBrokerPath?: string;
13
- unsafe: boolean;
14
- transportType: string;
15
- useAuthBroker?: boolean;
16
- browserAuthPort?: number;
17
- browser?: string;
18
- logger?: ILogger;
19
- constructor(serverConfig: IServerConfig, logger?: ILogger);
20
- static fromServerConfig(config: IServerConfig, logger?: ILogger): AuthBrokerConfig;
21
- }
22
- //# sourceMappingURL=AuthBrokerConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthBrokerConfig.d.ts","sourceRoot":"","sources":["../src/AuthBrokerConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,qBAAa,gBAAiB,YAAW,wBAAwB;IAC/D,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;gBAEL,YAAY,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,OAAO;IAqBzD,MAAM,CAAC,gBAAgB,CACrB,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,OAAO,GACf,gBAAgB;CAGpB"}
@@ -1,43 +0,0 @@
1
- "use strict";
2
- /**
3
- * V2 Server configuration adapter for AuthBrokerFactory
4
- * Maps v2 ServerConfig to IAuthBrokerFactoryConfig
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.AuthBrokerConfig = void 0;
8
- class AuthBrokerConfig {
9
- defaultMcpDestination;
10
- defaultDestination;
11
- envFilePath;
12
- authBrokerPath;
13
- unsafe;
14
- transportType;
15
- useAuthBroker;
16
- browserAuthPort;
17
- browser;
18
- logger;
19
- constructor(serverConfig, logger) {
20
- this.defaultMcpDestination = serverConfig.mcpDestination;
21
- this.defaultDestination = serverConfig.mcpDestination;
22
- this.envFilePath = serverConfig.envFile || serverConfig.envFilePath;
23
- this.authBrokerPath = serverConfig.authBrokerPath;
24
- this.unsafe = serverConfig.unsafe ?? false;
25
- this.transportType = serverConfig.transport || 'stdio';
26
- this.useAuthBroker = serverConfig.useAuthBroker;
27
- this.browser = serverConfig.browser;
28
- if (serverConfig.browserAuthPort) {
29
- this.browserAuthPort = serverConfig.browserAuthPort;
30
- }
31
- else {
32
- // Use random port from high range (30000-39999) to avoid conflicts
33
- // with other services and parallel MCP instances
34
- this.browserAuthPort = 30000 + Math.floor(Math.random() * 10000);
35
- }
36
- this.logger = logger;
37
- }
38
- static fromServerConfig(config, logger) {
39
- return new AuthBrokerConfig(config, logger);
40
- }
41
- }
42
- exports.AuthBrokerConfig = AuthBrokerConfig;
43
- //# sourceMappingURL=AuthBrokerConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthBrokerConfig.js","sourceRoot":"","sources":["../src/AuthBrokerConfig.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,MAAa,gBAAgB;IAC3B,qBAAqB,CAAU;IAC/B,kBAAkB,CAAU;IAC5B,WAAW,CAAU;IACrB,cAAc,CAAU;IACxB,MAAM,CAAU;IAChB,aAAa,CAAS;IACtB,aAAa,CAAW;IACxB,eAAe,CAAU;IACzB,OAAO,CAAU;IACjB,MAAM,CAAW;IAEjB,YAAY,YAA2B,EAAE,MAAgB;QACvD,IAAI,CAAC,qBAAqB,GAAG,YAAY,CAAC,cAAc,CAAC;QACzD,IAAI,CAAC,kBAAkB,GAAG,YAAY,CAAC,cAAc,CAAC;QACtD,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC;QACpE,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC,cAAc,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,KAAK,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC,SAAS,IAAI,OAAO,CAAC;QACvD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC,aAAa,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;QAEpC,IAAI,YAAY,CAAC,eAAe,EAAE,CAAC;YACjC,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,mEAAmE;YACnE,iDAAiD;YACjD,IAAI,CAAC,eAAe,GAAG,KAAK,GAAG,IAAI,CAAC,KA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