@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.
- package/dist/SseServer.d.ts +16 -3
- package/dist/SseServer.d.ts.map +1 -1
- package/dist/SseServer.js +80 -42
- package/dist/SseServer.js.map +1 -1
- package/dist/StdioServer.d.ts +11 -3
- package/dist/StdioServer.d.ts.map +1 -1
- package/dist/StdioServer.js +30 -4
- package/dist/StdioServer.js.map +1 -1
- package/dist/StreamableHttpServer.d.ts +14 -5
- package/dist/StreamableHttpServer.d.ts.map +1 -1
- package/dist/StreamableHttpServer.js +51 -52
- package/dist/StreamableHttpServer.js.map +1 -1
- package/dist/destinationRequest.d.ts +38 -0
- package/dist/destinationRequest.d.ts.map +1 -0
- package/dist/destinationRequest.js +85 -0
- package/dist/destinationRequest.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/launcher.d.ts +49 -1
- package/dist/launcher.d.ts.map +1 -1
- package/dist/launcher.js +308 -150
- package/dist/launcher.js.map +1 -1
- package/dist/shutdown.d.ts +45 -0
- package/dist/shutdown.d.ts.map +1 -0
- package/dist/shutdown.js +79 -0
- package/dist/shutdown.js.map +1 -0
- package/package.json +23 -4
- package/dist/AuthBrokerConfig.d.ts +0 -22
- package/dist/AuthBrokerConfig.d.ts.map +0 -1
- package/dist/AuthBrokerConfig.js +0 -43
- package/dist/AuthBrokerConfig.js.map +0 -1
|
@@ -4,11 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.StreamableHttpServer = void 0;
|
|
7
|
+
const auth_1 = require("@mcp-abap-adt/lib/auth");
|
|
7
8
|
const embeddable_1 = require("@mcp-abap-adt/lib/embeddable");
|
|
8
9
|
const logger_1 = require("@mcp-abap-adt/lib/logger");
|
|
9
10
|
const request_context_1 = require("@mcp-abap-adt/lib/request-context");
|
|
10
11
|
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
11
12
|
const express_1 = __importDefault(require("express"));
|
|
13
|
+
const destinationRequest_js_1 = require("./destinationRequest.js");
|
|
12
14
|
const dnsRebindingProtection_js_1 = require("./dnsRebindingProtection.js");
|
|
13
15
|
const tlsUtils_js_1 = require("./tlsUtils.js");
|
|
14
16
|
const DEFAULT_VERSION = process.env.npm_package_version ?? '1.0.0';
|
|
@@ -23,7 +25,7 @@ const DEFAULT_VERSION = process.env.npm_package_version ?? '1.0.0';
|
|
|
23
25
|
*/
|
|
24
26
|
class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
25
27
|
handlersRegistry;
|
|
26
|
-
|
|
28
|
+
destinations;
|
|
27
29
|
host;
|
|
28
30
|
port;
|
|
29
31
|
enableJsonResponse;
|
|
@@ -37,16 +39,18 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
37
39
|
allowedHosts;
|
|
38
40
|
allowedOrigins;
|
|
39
41
|
enableDnsRebindingProtection;
|
|
40
|
-
/** Per-destination lock
|
|
41
|
-
|
|
42
|
-
constructor(handlersRegistry,
|
|
42
|
+
/** Per-destination lock around the first connect: it serialises the first login. */
|
|
43
|
+
firstConnect = new destinationRequest_js_1.FirstConnectLock();
|
|
44
|
+
constructor(handlersRegistry,
|
|
45
|
+
/** The destinations: settings and the counted provider, nothing else. */
|
|
46
|
+
destinations, opts) {
|
|
43
47
|
super({
|
|
44
48
|
name: 'mcp-abap-adt',
|
|
45
49
|
version: opts?.version ?? DEFAULT_VERSION,
|
|
46
50
|
logger: opts?.logger ?? logger_1.noopLogger,
|
|
47
51
|
});
|
|
48
52
|
this.handlersRegistry = handlersRegistry;
|
|
49
|
-
this.
|
|
53
|
+
this.destinations = destinations;
|
|
50
54
|
this.version = opts?.version ?? DEFAULT_VERSION;
|
|
51
55
|
this.host = opts?.host ?? '127.0.0.1';
|
|
52
56
|
this.port = opts?.port ?? 3000;
|
|
@@ -84,23 +88,16 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
84
88
|
try {
|
|
85
89
|
const server = this.createPerRequestServer();
|
|
86
90
|
let destination;
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
const destinationHeader = this.allowDestinationHeader
|
|
90
|
-
|
|
91
|
-
req.headers['X-MCP-Destination'])
|
|
92
|
-
: undefined;
|
|
93
|
-
if (destinationHeader) {
|
|
91
|
+
// Priority 1: x-mcp-destination (only with --allow-destination-header),
|
|
92
|
+
// refused when it is not a destination name
|
|
93
|
+
const destinationHeader = (0, destinationRequest_js_1.destinationFromHeader)(req.headers, this.allowDestinationHeader);
|
|
94
|
+
if (destinationHeader !== undefined) {
|
|
94
95
|
destination = destinationHeader;
|
|
95
|
-
broker =
|
|
96
|
-
await this.authBrokerFactory.getOrCreateAuthBroker(destination);
|
|
97
96
|
}
|
|
98
97
|
// Priority 2: Check SAP connection headers (x-sap-url + auth params)
|
|
99
|
-
//
|
|
98
|
+
// The settings and the credential come from the headers, no destination
|
|
100
99
|
else if (this.hasSapConnectionHeaders(req.headers)) {
|
|
101
|
-
// No destination, no broker - create connection directly from headers
|
|
102
100
|
destination = undefined;
|
|
103
|
-
broker = undefined;
|
|
104
101
|
if (!isPing) {
|
|
105
102
|
server.setConnectionContextFromHeadersPublic(req.headers);
|
|
106
103
|
}
|
|
@@ -108,9 +105,6 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
108
105
|
// Priority 3: Use default destination
|
|
109
106
|
else if (this.defaultDestination) {
|
|
110
107
|
destination = this.defaultDestination;
|
|
111
|
-
// Initialize broker for the selected default destination
|
|
112
|
-
broker =
|
|
113
|
-
await this.authBrokerFactory.getOrCreateAuthBroker(destination);
|
|
114
108
|
}
|
|
115
109
|
// Priority 4: No auth params at all -> reject request
|
|
116
110
|
else {
|
|
@@ -119,27 +113,13 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
119
113
|
.send('Missing SAP connection context. Provide x-mcp-destination header, configure default destination (--mcp/--env-path), or pass x-sap-* headers.');
|
|
120
114
|
return;
|
|
121
115
|
}
|
|
122
|
-
if (destination && !broker) {
|
|
123
|
-
throw new Error(`Auth broker not initialized for destination: ${destination}`);
|
|
124
|
-
}
|
|
125
116
|
// Skip SAP connection setup for ping — it's a protocol-level check,
|
|
126
117
|
// no need to acquire JWT tokens or contact the SAP system
|
|
127
|
-
if (!isPing && destination
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
await existingLock;
|
|
133
|
-
}
|
|
134
|
-
const authPromise = server
|
|
135
|
-
.setConnectionContextPublic(destination, broker)
|
|
136
|
-
.finally(() => {
|
|
137
|
-
if (this.authLocks.get(destination) === authPromise) {
|
|
138
|
-
this.authLocks.delete(destination);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
this.authLocks.set(destination, authPromise);
|
|
142
|
-
await authPromise;
|
|
118
|
+
if (!isPing && destination) {
|
|
119
|
+
// The first request of a destination connects inside the lock:
|
|
120
|
+
// two first logins must not race for the same callback port
|
|
121
|
+
const chosen = destination;
|
|
122
|
+
await this.firstConnect.run(chosen, () => server.setConnectionContextPublic(chosen, this.destinations), () => server.connectPublic());
|
|
143
123
|
}
|
|
144
124
|
const authSource = destination
|
|
145
125
|
? `destination=${destination}`
|
|
@@ -157,20 +137,25 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
157
137
|
void transport.close();
|
|
158
138
|
});
|
|
159
139
|
await server.connect(transport);
|
|
160
|
-
// Scope the
|
|
161
|
-
// request's dispatch so it cannot
|
|
162
|
-
// a process-global cache (#110).
|
|
163
|
-
|
|
164
|
-
const masterLanguage = Array.isArray(rawLang) ? rawLang[0] : rawLang;
|
|
165
|
-
await (0, request_context_1.runWithRequestContext)({ masterLanguage }, () => transport.handleRequest(req, res, req.body));
|
|
140
|
+
// Scope what the request states — x-sap-language, x-sap-responsible,
|
|
141
|
+
// x-sap-master-system — to this request's dispatch, so it cannot
|
|
142
|
+
// leak into other requests/modes via a process-global cache (#110).
|
|
143
|
+
await (0, request_context_1.runWithRequestContext)((0, request_context_1.requestContextFromHeaders)(req.headers), () => transport.handleRequest(req, res, req.body));
|
|
166
144
|
if (!isPing) {
|
|
167
145
|
console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) completed`);
|
|
168
146
|
}
|
|
169
147
|
}
|
|
170
148
|
catch (err) {
|
|
171
|
-
|
|
149
|
+
const answer = (0, destinationRequest_js_1.destinationFailureAnswer)(err);
|
|
150
|
+
if (!answer.known) {
|
|
151
|
+
// No words for it: its class only — a message may quote a file (H4).
|
|
152
|
+
console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) FAILED: ${(0, auth_1.errorClassOf)(err)}`);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
console.error(`[StreamableHttpServer] ${methodInfo} (id=${mcpId ?? '-'}) FAILED: ${answer.text}`);
|
|
156
|
+
}
|
|
172
157
|
if (!res.headersSent) {
|
|
173
|
-
res.status(
|
|
158
|
+
res.status(answer.status).send(answer.text);
|
|
174
159
|
}
|
|
175
160
|
}
|
|
176
161
|
};
|
|
@@ -245,6 +230,19 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
245
230
|
server.once('error', reject);
|
|
246
231
|
});
|
|
247
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Stops taking connections (shutdown, step 1). Requests already running are
|
|
235
|
+
* not waited for, nor is an open stream: the factory's gate holds them.
|
|
236
|
+
* Embedded on an external app, there is no listener of its own to stop.
|
|
237
|
+
*/
|
|
238
|
+
async stop() {
|
|
239
|
+
const server = this.standaloneServer;
|
|
240
|
+
if (!server)
|
|
241
|
+
return;
|
|
242
|
+
this.standaloneServer = undefined;
|
|
243
|
+
server.close();
|
|
244
|
+
server.closeIdleConnections();
|
|
245
|
+
}
|
|
248
246
|
/**
|
|
249
247
|
* Check if request has SAP connection headers
|
|
250
248
|
*/
|
|
@@ -263,11 +261,12 @@ class StreamableHttpServer extends embeddable_1.BaseMcpServer {
|
|
|
263
261
|
this.registry = registry;
|
|
264
262
|
this.registerHandlers(this.registry);
|
|
265
263
|
}
|
|
266
|
-
setConnectionContextPublic(destination,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
setConnectionContextPublic(destination, destinations) {
|
|
265
|
+
return this.setConnectionContext(destination, destinations);
|
|
266
|
+
}
|
|
267
|
+
/** The context's connection, connected (cached for this request). */
|
|
268
|
+
connectPublic() {
|
|
269
|
+
return this.getConnection();
|
|
271
270
|
}
|
|
272
271
|
setConnectionContextFromHeadersPublic(headers) {
|
|
273
272
|
this.setConnectionContextFromHeaders(headers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamableHttpServer.js","sourceRoot":"","sources":["../src/StreamableHttpServer.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"StreamableHttpServer.js","sourceRoot":"","sources":["../src/StreamableHttpServer.ts"],"names":[],"mappings":";;;;;;AAEA,iDAA0E;AAM1E,6DAA6D;AAE7D,qDAAsD;AACtD,uEAG2C;AAE3C,0FAAmG;AACnG,sDAA+D;AAC/D,mEAIiC;AACjC,2EAAyE;AACzE,+CAAkE;AAElE,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC;AA0DnE;;;;;;;;GAQG;AACH,MAAa,oBAAqB,SAAQ,0BAAa;IAkBlC;IAEA;IAnBF,IAAI,CAAS;IACb,IAAI,CAAS;IACb,kBAAkB,CAAU;IAC5B,kBAAkB,CAAU;IAC5B,IAAI,CAAS;IACb,WAAW,CAAoB;IAC/B,OAAO,CAAS;IACzB,gBAAgB,CAA4B;IACnC,GAAG,CAAa;IAChB,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AAC;YAC9D,CAAC;YAED,qEAAqE;YAC9D,aAAa;gBAClB,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9B,CAAC;YAEM,qCAAqC,CAC1C,OAAsD;gBAEtD,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAAC;YAChD,CAAC;SACF;QACD,OAAO,IAAI,gBAAgB,CACzB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;CACF;AAtVD,oDAsVC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the HTTP and SSE transports share about a request's destination:
|
|
3
|
+
* reading `x-mcp-destination`, and answering a destination that fails.
|
|
4
|
+
*/
|
|
5
|
+
/** `x-mcp-destination` is not a destination name. Its message names the header, never the value. */
|
|
6
|
+
export declare class DestinationHeaderError extends Error {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The destination `x-mcp-destination` names — only when the server allows
|
|
11
|
+
* the header, and only when the value is a name, not a path. Checked here,
|
|
12
|
+
* before anything is looked up for it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function destinationFromHeader(headers: Record<string, string | string[] | undefined>, allowDestinationHeader: boolean): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* How a request whose destination failed is answered: a refused header is
|
|
17
|
+
* the client's (400); an authentication error the server knows is answered
|
|
18
|
+
* in its own words (`describeAuthError`: field names and vetted vocabulary
|
|
19
|
+
* only); anything else as before, without its message.
|
|
20
|
+
*/
|
|
21
|
+
export declare function destinationFailureAnswer(error: unknown): {
|
|
22
|
+
status: number;
|
|
23
|
+
text: string;
|
|
24
|
+
/** Whether the text is the error's own vetted words. */
|
|
25
|
+
known: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Per destination, one request at a time sets its connection context, and
|
|
29
|
+
* the first one also connects — presents the credential, which is the first
|
|
30
|
+
* login — before the next starts. Two first logins never run at once.
|
|
31
|
+
* A failed first connect leaves the next request to connect again.
|
|
32
|
+
*/
|
|
33
|
+
export declare class FirstConnectLock {
|
|
34
|
+
private readonly queues;
|
|
35
|
+
private readonly connected;
|
|
36
|
+
run(destination: string, setContext: () => Promise<void>, connect: () => Promise<unknown>): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=destinationRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destinationRequest.d.ts","sourceRoot":"","sources":["../src/destinationRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,oGAAoG;AACpG,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,EACtD,sBAAsB,EAAE,OAAO,GAC9B,MAAM,GAAG,SAAS,CAapB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,KAAK,EAAE,OAAO,CAAC;CAChB,CAOA;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C,GAAG,CACD,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC/B,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;CAoBjB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What the HTTP and SSE transports share about a request's destination:
|
|
4
|
+
* reading `x-mcp-destination`, and answering a destination that fails.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FirstConnectLock = exports.DestinationHeaderError = void 0;
|
|
8
|
+
exports.destinationFromHeader = destinationFromHeader;
|
|
9
|
+
exports.destinationFailureAnswer = destinationFailureAnswer;
|
|
10
|
+
const auth_1 = require("@mcp-abap-adt/lib/auth");
|
|
11
|
+
/** `x-mcp-destination` is not a destination name. Its message names the header, never the value. */
|
|
12
|
+
class DestinationHeaderError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'DestinationHeaderError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.DestinationHeaderError = DestinationHeaderError;
|
|
19
|
+
/**
|
|
20
|
+
* The destination `x-mcp-destination` names — only when the server allows
|
|
21
|
+
* the header, and only when the value is a name, not a path. Checked here,
|
|
22
|
+
* before anything is looked up for it.
|
|
23
|
+
*/
|
|
24
|
+
function destinationFromHeader(headers, allowDestinationHeader) {
|
|
25
|
+
if (!allowDestinationHeader)
|
|
26
|
+
return undefined;
|
|
27
|
+
const raw = headers['x-mcp-destination'];
|
|
28
|
+
if (raw === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
const value = Array.isArray(raw) ? (raw[0] ?? '') : raw;
|
|
31
|
+
try {
|
|
32
|
+
(0, auth_1.assertDestinationName)(value, 'x-mcp-destination');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new DestinationHeaderError(error instanceof Error ? error.message : 'x-mcp-destination: refused.');
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How a request whose destination failed is answered: a refused header is
|
|
41
|
+
* the client's (400); an authentication error the server knows is answered
|
|
42
|
+
* in its own words (`describeAuthError`: field names and vetted vocabulary
|
|
43
|
+
* only); anything else as before, without its message.
|
|
44
|
+
*/
|
|
45
|
+
function destinationFailureAnswer(error) {
|
|
46
|
+
if (error instanceof DestinationHeaderError) {
|
|
47
|
+
return { status: 400, text: error.message, known: true };
|
|
48
|
+
}
|
|
49
|
+
const words = (0, auth_1.describeAuthError)(error);
|
|
50
|
+
if (words !== undefined)
|
|
51
|
+
return { status: 500, text: words, known: true };
|
|
52
|
+
return { status: 500, text: 'Internal Server Error', known: false };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Per destination, one request at a time sets its connection context, and
|
|
56
|
+
* the first one also connects — presents the credential, which is the first
|
|
57
|
+
* login — before the next starts. Two first logins never run at once.
|
|
58
|
+
* A failed first connect leaves the next request to connect again.
|
|
59
|
+
*/
|
|
60
|
+
class FirstConnectLock {
|
|
61
|
+
queues = new Map();
|
|
62
|
+
connected = new Set();
|
|
63
|
+
run(destination, setContext, connect) {
|
|
64
|
+
const previous = this.queues.get(destination) ?? Promise.resolve();
|
|
65
|
+
const work = previous
|
|
66
|
+
.catch(() => { })
|
|
67
|
+
.then(async () => {
|
|
68
|
+
await setContext();
|
|
69
|
+
if (!this.connected.has(destination)) {
|
|
70
|
+
await connect();
|
|
71
|
+
this.connected.add(destination);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const settled = work.finally(() => {
|
|
75
|
+
if (this.queues.get(destination) === settled) {
|
|
76
|
+
this.queues.delete(destination);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
// Set before any await: the next request queues behind this one.
|
|
80
|
+
this.queues.set(destination, settled);
|
|
81
|
+
return settled;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.FirstConnectLock = FirstConnectLock;
|
|
85
|
+
//# sourceMappingURL=destinationRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destinationRequest.js","sourceRoot":"","sources":["../src/destinationRequest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoBH,sDAgBC;AAQD,4DAYC;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want `@mcp-abap-adt/lib` instead: it carries the
|
|
6
6
|
* handlers and the embeddable server under Apache-2.0, and no transport.
|
|
7
7
|
*/
|
|
8
|
-
export * from './AuthBrokerConfig.js';
|
|
9
8
|
export * from './dnsRebindingProtection.js';
|
|
10
9
|
export * from './SseServer.js';
|
|
11
10
|
export * from './StdioServer.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
* own application, you want `@mcp-abap-adt/lib` instead: it carries the
|
|
22
22
|
* handlers and the embeddable server under Apache-2.0, and no transport.
|
|
23
23
|
*/
|
|
24
|
-
__exportStar(require("./AuthBrokerConfig.js"), exports);
|
|
25
24
|
__exportStar(require("./dnsRebindingProtection.js"), exports);
|
|
26
25
|
__exportStar(require("./SseServer.js"), exports);
|
|
27
26
|
__exportStar(require("./StdioServer.js"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,8DAA4C;AAC5C,iDAA+B;AAC/B,mDAAiC;AACjC,4DAA0C;AAC1C,gDAA8B"}
|
package/dist/launcher.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IAuthBrokerFactoryConfig } from '@mcp-abap-adt/lib/auth';
|
|
2
|
+
import type { HandlerSet, IServerConfig } from '@mcp-abap-adt/lib/config';
|
|
2
3
|
import type { HandlerContext, IHandlerGroup } from '@mcp-abap-adt/lib/handlers';
|
|
4
|
+
import type { ILogger } from '@mcp-abap-adt/interfaces-utils';
|
|
5
|
+
import { type ShutdownProcess } from './shutdown.js';
|
|
3
6
|
/**
|
|
4
7
|
* What a command may add to the tool list this launcher serves.
|
|
5
8
|
*
|
|
@@ -32,4 +35,49 @@ export interface LauncherOptions {
|
|
|
32
35
|
includeSearch?: boolean;
|
|
33
36
|
}
|
|
34
37
|
export declare function main(options?: LauncherOptions): Promise<void>;
|
|
38
|
+
/** What the launcher takes from the program: the process's edges, and the login strategy. */
|
|
39
|
+
export interface LauncherDeps {
|
|
40
|
+
/** auth-providers' `browserCallbackStrategy` in the program (Ruling 1). */
|
|
41
|
+
browserStrategy: IAuthBrokerFactoryConfig['browserStrategy'];
|
|
42
|
+
/** One line to stderr; nothing the launcher says goes to stdout (H3). */
|
|
43
|
+
stderr: (line: string) => void;
|
|
44
|
+
exit: (code: number) => void;
|
|
45
|
+
/** Where the shutdown listens: `process` in the program. */
|
|
46
|
+
processLike: ShutdownProcess;
|
|
47
|
+
}
|
|
48
|
+
/** The connection type: see {@link effectiveFromEnvironment}. */
|
|
49
|
+
export declare function effectiveConnectionType(config: IServerConfig, env: NodeJS.ProcessEnv): IServerConfig['connectionType'];
|
|
50
|
+
/**
|
|
51
|
+
* The system type: see {@link effectiveFromEnvironment}. The parser no longer
|
|
52
|
+
* writes it into the environment, where it used to sit before the env file
|
|
53
|
+
* was read and so beat the file's SAP_SYSTEM_TYPE even from YAML.
|
|
54
|
+
*/
|
|
55
|
+
export declare function effectiveSystemType(config: IServerConfig, env: NodeJS.ProcessEnv): IServerConfig['systemType'];
|
|
56
|
+
/**
|
|
57
|
+
* The login strategy, with prompts that reach the user. auth-providers'
|
|
58
|
+
* strategy speaks to the user through the request's logger — the URL to open
|
|
59
|
+
* under `--browser=none`/`headless`, or `auto` when it could not open one — and
|
|
60
|
+
* that logger is the broker's, silent unless DEBUG_AUTH_LOG is set. A prompt
|
|
61
|
+
* the user cannot see makes the login impassable: it times out.
|
|
62
|
+
*
|
|
63
|
+
* So the strategy gets its own logger: `info`, the level the strategy prompts
|
|
64
|
+
* at, is a line on stderr always; `warn`, `error` and `debug` stay the
|
|
65
|
+
* broker's — diagnostics, gated, and they may quote an error's message (H4).
|
|
66
|
+
* Not "no logger" (auth-providers then writes prompts to stderr itself): that
|
|
67
|
+
* would also drop those diagnostics under DEBUG_AUTH_LOG. Never stdout (H3).
|
|
68
|
+
*/
|
|
69
|
+
export declare function promptsOnStderr(browserStrategy: IAuthBrokerFactoryConfig['browserStrategy'], stderr: (line: string) => void, diagnostics: ILogger): IAuthBrokerFactoryConfig['browserStrategy'];
|
|
70
|
+
/**
|
|
71
|
+
* The factory's configuration, read from the parameters alone. The callback
|
|
72
|
+
* port is left to the strategy (61001) when none is given; the env file
|
|
73
|
+
* carries the parameter it came from, as the user gave it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function factoryConfigFrom(config: IServerConfig, collaborators: Pick<IAuthBrokerFactoryConfig, 'browserStrategy' | 'logger'>): IAuthBrokerFactoryConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Everything after the parameters are read: the tool list, one factory, the
|
|
78
|
+
* destination the process serves checked and summarised, the transport, and
|
|
79
|
+
* the shutdown. A destination that cannot be served stops the start before
|
|
80
|
+
* any transport does.
|
|
81
|
+
*/
|
|
82
|
+
export declare function launch(config: IServerConfig, options: LauncherOptions, deps: LauncherDeps): Promise<void>;
|
|
35
83
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,wBAAwB,EAE9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAM1E,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAiB9D,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAyKtE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,aAAa,EAAE,CAAC;IAC3D,iFAAiF;IACjF,UAAU,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACnC,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAsB,IAAI,CAAC,OAAO,GAAE,eAAoB,iBAqBvD;AAED,6FAA6F;AAC7F,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,eAAe,EAAE,wBAAwB,CAAC,iBAAiB,CAAC,CAAC;IAC7D,yEAAyE;IACzE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,4DAA4D;IAC5D,WAAW,EAAE,eAAe,CAAC;CAC9B;AAuDD,iEAAiE;AACjE,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,aA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