@mcp-abap-adt/core 19.1.0 → 19.2.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 +13 -1
- package/bin/mcp-abap-adt.js +7 -2
- package/dist/auth/index.d.ts +5 -12
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +20 -34
- package/dist/auth/index.js.map +1 -1
- package/dist/coreVersion.d.ts +2 -12
- package/dist/coreVersion.d.ts.map +1 -1
- package/dist/coreVersion.js +5 -2
- package/dist/coreVersion.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -17
- package/dist/index.js.map +1 -1
- package/dist/launcher.d.ts +18 -134
- package/dist/launcher.d.ts.map +1 -1
- package/dist/launcher.js +32 -689
- package/dist/launcher.js.map +1 -1
- package/package.json +5 -15
- package/dist/StdioServer.d.ts +0 -87
- package/dist/StdioServer.d.ts.map +0 -1
- package/dist/StdioServer.js +0 -132
- package/dist/StdioServer.js.map +0 -1
- package/dist/auth/IAuthBrokerFactory.d.ts +0 -62
- package/dist/auth/IAuthBrokerFactory.d.ts.map +0 -1
- package/dist/auth/IAuthBrokerFactory.js +0 -8
- package/dist/auth/IAuthBrokerFactory.js.map +0 -1
- package/dist/auth/IAuthBrokerFactoryConfig.d.ts +0 -90
- package/dist/auth/IAuthBrokerFactoryConfig.d.ts.map +0 -1
- package/dist/auth/IAuthBrokerFactoryConfig.js +0 -8
- package/dist/auth/IAuthBrokerFactoryConfig.js.map +0 -1
- package/dist/auth/brokerFactory.d.ts +0 -93
- package/dist/auth/brokerFactory.d.ts.map +0 -1
- package/dist/auth/brokerFactory.js +0 -341
- package/dist/auth/brokerFactory.js.map +0 -1
- package/dist/auth/browser.d.ts +0 -60
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js +0 -116
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/countedProvider.d.ts +0 -43
- package/dist/auth/countedProvider.d.ts.map +0 -1
- package/dist/auth/countedProvider.js +0 -105
- package/dist/auth/countedProvider.js.map +0 -1
- package/dist/auth/destinationFailure.d.ts +0 -69
- package/dist/auth/destinationFailure.d.ts.map +0 -1
- package/dist/auth/destinationFailure.js +0 -183
- package/dist/auth/destinationFailure.js.map +0 -1
- package/dist/auth/destinationStores.d.ts +0 -55
- package/dist/auth/destinationStores.d.ts.map +0 -1
- package/dist/auth/destinationStores.js +0 -158
- package/dist/auth/destinationStores.js.map +0 -1
- package/dist/auth/handlers/basic.d.ts +0 -3
- package/dist/auth/handlers/basic.d.ts.map +0 -1
- package/dist/auth/handlers/basic.js +0 -8
- package/dist/auth/handlers/basic.js.map +0 -1
- package/dist/auth/handlers/index.d.ts +0 -15
- package/dist/auth/handlers/index.d.ts.map +0 -1
- package/dist/auth/handlers/index.js +0 -32
- package/dist/auth/handlers/index.js.map +0 -1
- package/dist/auth/handlers/jwtAuthorizationCode.d.ts +0 -8
- package/dist/auth/handlers/jwtAuthorizationCode.d.ts.map +0 -1
- package/dist/auth/handlers/jwtAuthorizationCode.js +0 -32
- package/dist/auth/handlers/jwtAuthorizationCode.js.map +0 -1
- package/dist/auth/handlers/snc.d.ts +0 -3
- package/dist/auth/handlers/snc.d.ts.map +0 -1
- package/dist/auth/handlers/snc.js +0 -14
- package/dist/auth/handlers/snc.js.map +0 -1
- package/dist/auth/handlers/types.d.ts +0 -30
- package/dist/auth/handlers/types.d.ts.map +0 -1
- package/dist/auth/handlers/types.js +0 -3
- package/dist/auth/handlers/types.js.map +0 -1
- package/dist/auth/serverLogin.d.ts +0 -75
- package/dist/auth/serverLogin.d.ts.map +0 -1
- package/dist/auth/serverLogin.js +0 -138
- package/dist/auth/serverLogin.js.map +0 -1
- package/dist/auth/serverSentences.d.ts +0 -39
- package/dist/auth/serverSentences.d.ts.map +0 -1
- package/dist/auth/serverSentences.js +0 -49
- package/dist/auth/serverSentences.js.map +0 -1
- package/dist/auth/vocabulary.d.ts +0 -28
- package/dist/auth/vocabulary.d.ts.map +0 -1
- package/dist/auth/vocabulary.js +0 -67
- package/dist/auth/vocabulary.js.map +0 -1
- package/dist/config/coreParameters.d.ts +0 -125
- package/dist/config/coreParameters.d.ts.map +0 -1
- package/dist/config/coreParameters.js +0 -331
- package/dist/config/coreParameters.js.map +0 -1
- package/dist/config/envFileContext.d.ts +0 -26
- package/dist/config/envFileContext.d.ts.map +0 -1
- package/dist/config/envFileContext.js +0 -90
- package/dist/config/envFileContext.js.map +0 -1
- package/dist/config/envResolver.d.ts +0 -6
- package/dist/config/envResolver.d.ts.map +0 -1
- package/dist/config/envResolver.js +0 -81
- package/dist/config/envResolver.js.map +0 -1
- package/dist/config/platformPaths.d.ts +0 -28
- package/dist/config/platformPaths.d.ts.map +0 -1
- package/dist/config/platformPaths.js +0 -152
- package/dist/config/platformPaths.js.map +0 -1
- package/dist/destinationSource.d.ts +0 -26
- package/dist/destinationSource.d.ts.map +0 -1
- package/dist/destinationSource.js +0 -43
- package/dist/destinationSource.js.map +0 -1
- package/dist/shutdown.d.ts +0 -97
- package/dist/shutdown.d.ts.map +0 -1
- package/dist/shutdown.js +0 -136
- package/dist/shutdown.js.map +0 -1
package/dist/launcher.js
CHANGED
|
@@ -1,700 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
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
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stateLoggerForTransport = exports.AUTH_DEBUG_WARNING = void 0;
|
|
4
|
-
exports.coreHelp = coreHelp;
|
|
5
17
|
exports.main = main;
|
|
6
|
-
exports.effectiveConnectionType = effectiveConnectionType;
|
|
7
|
-
exports.effectiveMessageServer = effectiveMessageServer;
|
|
8
|
-
exports.effectiveSystemType = effectiveSystemType;
|
|
9
|
-
exports.factoryConfigFrom = factoryConfigFrom;
|
|
10
|
-
exports.startLookupFailedWords = startLookupFailedWords;
|
|
11
|
-
exports.startSystemTypeRequiredWords = startSystemTypeRequiredWords;
|
|
12
|
-
exports.startCloudWithoutSystemInformationWords = startCloudWithoutSystemInformationWords;
|
|
13
|
-
exports.startSystemUserUnknownWords = startSystemUserUnknownWords;
|
|
14
|
-
exports.startConnectionWords = startConnectionWords;
|
|
15
18
|
exports.launch = launch;
|
|
16
|
-
exports.launcherFailedLine = launcherFailedLine;
|
|
17
|
-
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
18
|
-
const background_runs_memory_1 = require("@mcp-abap-adt/background-runs-memory");
|
|
19
|
-
const auth_1 = require("@mcp-abap-adt/lib/auth");
|
|
20
|
-
const config_1 = require("@mcp-abap-adt/lib/config");
|
|
21
|
-
const embeddable_1 = require("@mcp-abap-adt/lib/embeddable");
|
|
22
|
-
const state_1 = require("@mcp-abap-adt/lib/state");
|
|
23
|
-
const tool_set_1 = require("@mcp-abap-adt/lib/tool-set");
|
|
24
|
-
const utils_1 = require("@mcp-abap-adt/lib/utils");
|
|
25
|
-
const auth_2 = require("./auth");
|
|
26
|
-
const coreParameters_1 = require("./config/coreParameters");
|
|
27
|
-
const envFileContext_1 = require("./config/envFileContext");
|
|
28
|
-
const platformPaths_1 = require("./config/platformPaths");
|
|
29
|
-
const StdioServer_js_1 = require("./StdioServer.js");
|
|
30
|
-
const shutdown_js_1 = require("./shutdown.js");
|
|
31
|
-
const stderrLogger = {
|
|
32
|
-
info: (...args) => console.error(...args),
|
|
33
|
-
warn: (...args) => console.error(...args),
|
|
34
|
-
error: (...args) => console.error(...args),
|
|
35
|
-
debug: (...args) => console.error(...args),
|
|
36
|
-
};
|
|
37
|
-
const silentLogger = {
|
|
38
|
-
info: () => { },
|
|
39
|
-
warn: () => { },
|
|
40
|
-
error: () => { },
|
|
41
|
-
debug: () => { },
|
|
42
|
-
};
|
|
43
|
-
const loggerForTransport = process.env.DEBUG_AUTH_LOG === 'true' ? stderrLogger : silentLogger;
|
|
44
|
-
/** The one line `--auth-debug` prints at the start. */
|
|
45
|
-
exports.AUTH_DEBUG_WARNING = "[MCP] --auth-debug is on: a refused token request's debug line on stderr names the first and last four characters of each secret it sent";
|
|
46
19
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
exports.stateLoggerForTransport = state_1.stderrStateLogger;
|
|
52
|
-
// Keep strong reference to running server instance to avoid premature GC/exit
|
|
53
|
-
let activeServer;
|
|
54
|
-
/**
|
|
55
|
-
* Additional help sections specific to v2 server
|
|
56
|
-
*/
|
|
57
|
-
const V2_HELP_SECTIONS = `
|
|
58
|
-
ENVIRONMENT VARIABLES:
|
|
59
|
-
|
|
60
|
-
MCP Server Configuration:
|
|
61
|
-
MCP_ENV_PATH Explicit .env file path (same as --env-path)
|
|
62
|
-
MCP_UNSAFE Write named destinations' sessions to disk (true|false)
|
|
63
|
-
MCP_BROWSER Browser for a login: system|auto|chrome|edge|firefox|none|headless
|
|
64
|
-
MCP_BROWSER_PROGRAM The program that opens the login URL (excludes MCP_BROWSER)
|
|
65
|
-
MCP_RENEWAL refresh-then-login (default) | refresh-only (never a login)
|
|
66
|
-
MCP_BROWSER_AUTH_PORT Login callback port, 1-65535 (default: 61001)
|
|
67
|
-
MCP_STATE_IDLE_MINUTES Held state (a debug session) ends after this many minutes
|
|
68
|
-
without a tool call: at least 30 (default: 30)
|
|
69
|
-
|
|
70
|
-
Auth-Broker:
|
|
71
|
-
DEBUG_AUTH_LOG Enable debug logging for auth-broker (true|false)
|
|
72
|
-
DEBUG_AUTH_BROKER Alias for DEBUG_AUTH_LOG
|
|
73
|
-
AUTH_BROKER_PATH Base directory of service-keys/ and sessions/
|
|
74
|
-
|
|
75
|
-
Debug Options:
|
|
76
|
-
DEBUG_HANDLERS Enable handler debug logging (true|false)
|
|
77
|
-
DEBUG_CONNECTORS Enable connector debug logging (true|false)
|
|
78
|
-
DEBUG_CONNECTION_MANAGER Enable connection manager debug logging (true|false)
|
|
79
|
-
HANDLER_LOG_SILENT Disable all handler logs (true|false)
|
|
80
|
-
|
|
81
|
-
AUTHENTICATIONS (exactly three; a .env or service key stating another is refused):
|
|
82
|
-
basic SAP_AUTH_TYPE=basic user and password, HTTP or RFC
|
|
83
|
-
snc SAP_AUTH_TYPE=snc RFC only, no user, no password
|
|
84
|
-
jwt SAP_AUTH_TYPE=jwt, SAP_GRANT_TYPE=authorization_code browser login
|
|
85
|
-
A token you hold (SAP_GRANT_TYPE=none) is not served over stdio: send it in the
|
|
86
|
-
x-sap-jwt-token header to mcp-abap-adt-http or mcp-abap-adt-sse, or create the
|
|
87
|
-
session with mcp-auth.
|
|
88
|
-
|
|
89
|
-
SAP CONNECTION (.env file; secrets and the session live here, never in YAML):
|
|
90
|
-
|
|
91
|
-
Basic Authentication (on-premise):
|
|
92
|
-
SAP_URL SAP system URL (required)
|
|
93
|
-
SAP_CLIENT SAP client number (required for basic auth)
|
|
94
|
-
SAP_AUTH_TYPE Authentication type: basic|snc|jwt (required)
|
|
95
|
-
SAP_CONNECTION_TYPE Connection type: http|rfc (default: http)
|
|
96
|
-
Precedence: --connection-type, then the environment
|
|
97
|
-
(this file joins it, never over a value set), then YAML
|
|
98
|
-
SAP_SYSTEM_TYPE SAP system type: cloud | onprem | legacy (same as --system-type)
|
|
99
|
-
Required for a destination: no default, never guessed (not
|
|
100
|
-
from the auth type, not from the URL); it decides the tools
|
|
101
|
-
offered (e.g. Programs need onprem), the connector and how
|
|
102
|
-
the system's answers are read
|
|
103
|
-
SAP_USERNAME SAP username (required for basic auth)
|
|
104
|
-
SAP_PASSWORD SAP password (required for basic auth)
|
|
105
|
-
SAP_LANGUAGE SAP language (optional, e.g., EN, DE)
|
|
106
|
-
|
|
107
|
-
SNC (passwordless logon over RFC; no SAP_USERNAME, no SAP_PASSWORD):
|
|
108
|
-
SAP_AUTH_TYPE=snc with SAP_CONNECTION_TYPE=rfc (or --connection-type=rfc)
|
|
109
|
-
SAP_SNC_PARTNERNAME The system's SNC name (required)
|
|
110
|
-
SAP_SNC_QOP, SAP_SNC_LIB, SAP_SNC_MYNAME Optional
|
|
111
|
-
|
|
112
|
-
JWT/OAuth2 Authentication (SAP_GRANT_TYPE is required with jwt):
|
|
113
|
-
SAP_GRANT_TYPE authorization_code (browser login)
|
|
114
|
-
SAP_JWT_TOKEN The session's token (written by mcp-auth or the server)
|
|
115
|
-
SAP_REFRESH_TOKEN Refresh token (the server stores the one it obtains)
|
|
116
|
-
SAP_UAA_URL UAA URL for OAuth2
|
|
117
|
-
SAP_UAA_CLIENT_ID UAA Client ID
|
|
118
|
-
SAP_UAA_CLIENT_SECRET UAA Client Secret
|
|
119
|
-
An XSUAA service key needs XSUAA_MCP_URL (the system's URL) in sessions/<destination>.env
|
|
120
|
-
|
|
121
|
-
RFC Connection (any system with SAP NW RFC SDK):
|
|
122
|
-
--connection-type=rfc Enables RFC transport via SADT_REST_RFC_ENDPOINT
|
|
123
|
-
(or SAP_CONNECTION_TYPE=rfc in the .env or the environment)
|
|
124
|
-
SAP_URL SAP system URL (host:port used to derive RFC params)
|
|
125
|
-
SAP_USERNAME SAP username
|
|
126
|
-
SAP_PASSWORD SAP password
|
|
127
|
-
SAP_CLIENT SAP client number
|
|
128
|
-
Through a message server and a logon group (load-balanced logon); each also
|
|
129
|
-
--mshost, --msserv, --sysid, --group, --saprouter, or the YAML key of that name.
|
|
130
|
-
Precedence: the CLI, then the environment (this file joins it), then YAML:
|
|
131
|
-
SAP_MSHOST Message server host. With it, the URL gives no RFC host
|
|
132
|
-
and no system number (SAP_SYSNR is not read)
|
|
133
|
-
SAP_MSSERV Message server service (name or port)
|
|
134
|
-
SAP_SYSID System id; SAP_MSSERV or SAP_SYSID is required with
|
|
135
|
-
SAP_MSHOST (refused naming both otherwise)
|
|
136
|
-
SAP_GROUP Logon group (connection default: PUBLIC)
|
|
137
|
-
SAP_SAPROUTER SAProuter string, with either addressing
|
|
138
|
-
Requires: SAP NW RFC SDK + @mcp-abap-adt/sap-rfc-lite (an optional dependency,
|
|
139
|
-
compiled by npm install: SAPNWRFC_HOME and a C++ toolchain must be there before it;
|
|
140
|
-
npm ls -g @mcp-abap-adt/sap-rfc-lite shows (empty) when it was left out)
|
|
141
|
-
|
|
142
|
-
System Context (first found wins; reads are unaffected):
|
|
143
|
-
SAP_RESPONSIBLE Responsible person of created objects, always sent. First
|
|
144
|
-
found: the tool's argument; SAP_RESPONSIBLE in the
|
|
145
|
-
destination's own .env (--env / --env-path file, or
|
|
146
|
-
sessions/<destination>.env), then in the environment. Else
|
|
147
|
-
the login: on-premise the destination's SAP_USERNAME, the
|
|
148
|
-
environment's SAP_USERNAME; on a cloud system only the
|
|
149
|
-
system's user. A create that finds none is refused (SNC, a
|
|
150
|
-
token), a message class included.
|
|
151
|
-
SAP_MASTER_SYSTEM Master system of created objects (no tool takes it as an
|
|
152
|
-
argument). First found: the destination's .env; the
|
|
153
|
-
environment; on a cloud system, the system id.
|
|
154
|
-
Otherwise left out of the request, never refused
|
|
155
|
-
The environment is read once: later changes are not picked up
|
|
156
|
-
SAP_DEBUG_TERMINAL_ID The debugger's terminal id and IDE id (where the debugger is served),
|
|
157
|
-
SAP_DEBUG_IDE_ID each on its own. First found: the destination's .env; the
|
|
158
|
-
environment. Else random per instance. A shared IDE id shares
|
|
159
|
-
the user's catches without the system's listener conflict
|
|
160
|
-
SAP_DEBUG_BREAKPOINT_CONFLICT replace (default) or refuse-if-held: whether a take-over of
|
|
161
|
-
the debugger, and every later change of its breakpoints, first
|
|
162
|
-
asks if another debugger listens for the same SAP user, and
|
|
163
|
-
refuses if so (a start without take-over always asks). First
|
|
164
|
-
found: the destination's .env; the environment
|
|
165
|
-
|
|
166
|
-
Streamable HTTP and SSE are served by mcp-abap-adt-http (@mcp-abap-adt/http) and
|
|
167
|
-
mcp-abap-adt-sse (@mcp-abap-adt/sse), with credentials from each request's x-sap-* headers.
|
|
168
|
-
|
|
169
|
-
GENERATING A .ENV:
|
|
170
|
-
Install the CLI: npm install -g @mcp-abap-adt/auth-broker-cli
|
|
171
|
-
Generate .env: mcp-auth --service-key <key.json> --output <file.env> --type abap|xsuaa
|
|
172
|
-
or: mcp-auth --destination <name> --type abap|xsuaa (mcp-auth --help lists the rest)
|
|
173
|
-
A jwt .env must state SAP_GRANT_TYPE.
|
|
174
|
-
`;
|
|
175
|
-
/** The examples of core's help: stdio only, under the command's own name. */
|
|
176
|
-
function examples(program) {
|
|
177
|
-
return `
|
|
178
|
-
EXAMPLES:
|
|
179
|
-
# A named destination (for MCP clients)
|
|
180
|
-
${program} --mcp=TRIAL
|
|
181
|
-
|
|
182
|
-
# An env file by destination name, from the sessions store
|
|
183
|
-
${program} --env=trial
|
|
184
|
-
|
|
185
|
-
# An explicit env file (a .env in the working directory is read only when named)
|
|
186
|
-
${program} --env-path=./.env
|
|
187
|
-
|
|
188
|
-
# RFC connection (any system with SAP NW RFC SDK)
|
|
189
|
-
# (or SAP_CONNECTION_TYPE=rfc in the .env file)
|
|
190
|
-
${program} --env-path=my-system.env --connection-type=rfc
|
|
191
|
-
|
|
192
|
-
# RFC through a message server and a logon group
|
|
193
|
-
${program} --env-path=my-system.env --connection-type=rfc --mshost=<host> --sysid=<SID> --group=<group>
|
|
194
|
-
|
|
195
|
-
# Explicit system type (required: onprem, cloud or legacy)
|
|
196
|
-
${program} --env-path=<system>.env --system-type=onprem
|
|
197
|
-
|
|
198
|
-
# A YAML config file (a template is written when it does not exist)
|
|
199
|
-
${program} --conf=my-config.yaml
|
|
200
|
-
`;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* core's help: its own table (no HTTP or SSE option), the set's TOOLS
|
|
204
|
-
* section, the environment. A sibling command (`mcp-abap-adt-ro`,
|
|
205
|
-
* `mcp-abap-adt-compact`, `mcp-abap-adt-compact-ro`) passes its own set and
|
|
206
|
-
* name.
|
|
207
|
-
*/
|
|
208
|
-
function coreHelp(options = {}) {
|
|
209
|
-
const toolSet = options.toolSet ?? tool_set_1.fullToolSet;
|
|
210
|
-
const program = options.program ?? 'mcp-abap-adt';
|
|
211
|
-
return (0, config_1.generateHelp)((0, coreParameters_1.coreParameters)(toolSet, program), {
|
|
212
|
-
description: ' MCP server for SAP ABAP systems via ADT (ABAP Development Tools), over stdio:\n' +
|
|
213
|
-
' one destination through the auth broker. Streamable HTTP is mcp-abap-adt-http,\n' +
|
|
214
|
-
' SSE mcp-abap-adt-sse; a binary is its transport.',
|
|
215
|
-
sections: [toolSet.toolsHelp('stdio'), V2_HELP_SECTIONS, examples(program)],
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
async function main(options, edges = (0, config_1.processEdges)()) {
|
|
219
|
-
const { argv, stderr, exit } = edges;
|
|
220
|
-
if ((0, config_1.answerVersionOrHelp)(edges, {
|
|
221
|
-
version: options.version,
|
|
222
|
-
help: () => coreHelp(options),
|
|
223
|
-
})) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
// core's own table: an option of another binary, --transport, or the
|
|
227
|
-
// removed --exposition stops here.
|
|
228
|
-
const config = (0, config_1.readStartupConfig)((0, coreParameters_1.coreParameters)(options.toolSet, options.program), argv, process.env, { stderr, exit }, (args, env, yaml) => (0, coreParameters_1.readCoreConfig)(args, env, yaml, options.toolSet));
|
|
229
|
-
if (config === undefined)
|
|
230
|
-
return;
|
|
231
|
-
await launch(config, options, {
|
|
232
|
-
browserStrategy: auth_1.browserCallbackStrategy,
|
|
233
|
-
stderr,
|
|
234
|
-
exit,
|
|
235
|
-
processLike: edges.processLike,
|
|
236
|
-
...(edges.transport !== undefined && { transport: edges.transport }),
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* The env file and the parameter it came from. `envFilePath` is
|
|
241
|
-
* `CoreConfig`'s alias of `envFile`; `readCoreConfig` sets both and
|
|
242
|
-
* states the source. A config made by hand names the field it set.
|
|
243
|
-
*/
|
|
244
|
-
function envFileOf(config) {
|
|
245
|
-
const field = config.envFile
|
|
246
|
-
? 'envFile'
|
|
247
|
-
: config.envFilePath
|
|
248
|
-
? 'envFilePath'
|
|
249
|
-
: undefined;
|
|
250
|
-
if (!field)
|
|
251
|
-
return {};
|
|
252
|
-
return {
|
|
253
|
-
envFile: {
|
|
254
|
-
path: config[field],
|
|
255
|
-
source: config.envFileSource ?? `CoreConfig.${field}`,
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
/** A start the launcher refuses, in words that name parameters only. */
|
|
260
|
-
class LauncherRefusal extends Error {
|
|
261
|
-
words;
|
|
262
|
-
constructor(words) {
|
|
263
|
-
super(words);
|
|
264
|
-
this.name = 'LauncherRefusal';
|
|
265
|
-
this.words = words;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* A parameter the env file may state: the CLI, then the process environment
|
|
270
|
-
* — which by now holds what the env file states, never over a value set
|
|
271
|
-
* before — then YAML. A config made by hand, with no source, is taken as it
|
|
272
|
-
* is. A word in the environment that is not one of `values` is refused naming
|
|
273
|
-
* the key, never quoting it: it may come from a file.
|
|
274
|
-
*/
|
|
275
|
-
function effectiveFromEnvironment(value, source, key, values, env) {
|
|
276
|
-
const overridable = source === key ||
|
|
277
|
-
(source?.endsWith('(config file)') ?? false) ||
|
|
278
|
-
value === undefined;
|
|
279
|
-
if (!overridable)
|
|
280
|
-
return value;
|
|
281
|
-
const raw = env[key]?.trim().toLowerCase();
|
|
282
|
-
if (!raw)
|
|
283
|
-
return value;
|
|
284
|
-
if (!values.includes(raw)) {
|
|
285
|
-
const words = values.length === 2
|
|
286
|
-
? values.join(' or ')
|
|
287
|
-
: `${values.slice(0, -1).join(', ')} or ${values[values.length - 1]}`;
|
|
288
|
-
throw new LauncherRefusal(`${key} (environment or env file) must be ${words}`);
|
|
289
|
-
}
|
|
290
|
-
return raw;
|
|
291
|
-
}
|
|
292
|
-
/** `config` without its message-server fields: they are read again after the env file. */
|
|
293
|
-
function withoutMessageServer(config) {
|
|
294
|
-
const rest = { ...config };
|
|
295
|
-
for (const field of config_1.MESSAGE_SERVER_FIELDS)
|
|
296
|
-
delete rest[field];
|
|
297
|
-
return rest;
|
|
298
|
-
}
|
|
299
|
-
/** The connection type: see {@link effectiveFromEnvironment}. */
|
|
300
|
-
function effectiveConnectionType(config, env) {
|
|
301
|
-
return effectiveFromEnvironment(config.connectionType, config.connectionTypeSource, 'SAP_CONNECTION_TYPE', ['http', 'rfc'], env);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* The message server's fields (RFC, connection 18), each as
|
|
305
|
-
* {@link effectiveFromEnvironment} reads the connection type: the CLI, then
|
|
306
|
-
* the process environment — which by now holds what the env file states,
|
|
307
|
-
* never over a value set before — then YAML. Taken as given, trimmed; no
|
|
308
|
-
* default, no check: connection refuses what it cannot dial.
|
|
309
|
-
*/
|
|
310
|
-
function effectiveMessageServer(config, env) {
|
|
311
|
-
const out = {};
|
|
312
|
-
for (const field of config_1.MESSAGE_SERVER_FIELDS) {
|
|
313
|
-
const value = config[field];
|
|
314
|
-
const source = config.messageServerSource?.[field];
|
|
315
|
-
const fromCli = value !== undefined && (source?.startsWith('--') ?? true);
|
|
316
|
-
const stated = fromCli
|
|
317
|
-
? value
|
|
318
|
-
: env[config_1.MESSAGE_SERVER_ENV[field]]?.trim() || value;
|
|
319
|
-
if (stated)
|
|
320
|
-
out[field] = stated;
|
|
321
|
-
}
|
|
322
|
-
return out;
|
|
323
|
-
}
|
|
324
|
-
/** The message-server fields set on `config`, as `SapConfig` takes them. */
|
|
325
|
-
function messageServerOf(config) {
|
|
326
|
-
const out = {};
|
|
327
|
-
for (const field of config_1.MESSAGE_SERVER_FIELDS) {
|
|
328
|
-
const value = config[field];
|
|
329
|
-
if (value !== undefined)
|
|
330
|
-
out[field] = value;
|
|
331
|
-
}
|
|
332
|
-
return out;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* The system type: see {@link effectiveFromEnvironment}. The parser no longer
|
|
336
|
-
* writes it into the environment, where it used to sit before the env file
|
|
337
|
-
* was read and so beat the file's SAP_SYSTEM_TYPE even from YAML.
|
|
338
|
-
*/
|
|
339
|
-
function effectiveSystemType(config, env) {
|
|
340
|
-
return effectiveFromEnvironment(config.systemType, config.systemTypeSource, 'SAP_SYSTEM_TYPE', ['onprem', 'cloud', 'legacy'], env);
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* The factory's configuration, read from the parameters and the browser the
|
|
344
|
-
* launcher mapped (`browserFor`). The callback port is left to the strategy
|
|
345
|
-
* (61001) when none is given; the env file carries the parameter it came
|
|
346
|
-
* from, as the user gave it.
|
|
347
|
-
*/
|
|
348
|
-
function factoryConfigFrom(config, collaborators) {
|
|
349
|
-
return {
|
|
350
|
-
...envFileOf(config),
|
|
351
|
-
...(config.mcpDestination && { mcpDestination: config.mcpDestination }),
|
|
352
|
-
...(config.authBrokerPath && { authBrokerPath: config.authBrokerPath }),
|
|
353
|
-
unsafe: config.unsafe ?? false,
|
|
354
|
-
...(collaborators.browser !== undefined && {
|
|
355
|
-
browser: collaborators.browser,
|
|
356
|
-
}),
|
|
357
|
-
...(collaborators.browserUnavailable !== undefined && {
|
|
358
|
-
browserUnavailable: collaborators.browserUnavailable,
|
|
359
|
-
}),
|
|
360
|
-
...(config.browserAuthPort !== undefined && {
|
|
361
|
-
browserAuthPort: config.browserAuthPort,
|
|
362
|
-
}),
|
|
363
|
-
...(config.connectionType && { connectionType: config.connectionType }),
|
|
364
|
-
...messageServerOf(config),
|
|
365
|
-
...(config.renewal && { renewal: config.renewal }),
|
|
366
|
-
...(config.authDebug === true && { authDebug: true }),
|
|
367
|
-
...(config.loginTimeout !== undefined && {
|
|
368
|
-
loginTimeoutMs: config.loginTimeout * 1000,
|
|
369
|
-
loginTimeoutStated: (0, coreParameters_1.statedLoginTimeout)(config.loginTimeout, config.loginTimeoutSource),
|
|
370
|
-
}),
|
|
371
|
-
browserStrategy: collaborators.browserStrategy,
|
|
372
|
-
promptLogger: collaborators.promptLogger,
|
|
373
|
-
...(collaborators.logger && { logger: collaborators.logger }),
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* The words a startup failure is reported in: what the failure reader makes
|
|
378
|
-
* of it (`destinationFailureWords`: the failure message, its hint, the server's
|
|
379
|
-
* sentence), else the destination and the error's class — never its
|
|
380
|
-
* message, which may quote a file it could not parse.
|
|
381
|
-
*/
|
|
382
|
-
function startupWords(error, destination, factory, platform) {
|
|
383
|
-
return (0, auth_2.destinationFailureWords)(error, destination, {
|
|
384
|
-
platform,
|
|
385
|
-
sentenceFor: (e) => factory.sentenceFor(e),
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* The start's words for a system that gave no information where it must
|
|
390
|
-
* (ABAP Cloud): a problem of the ABAP system with a valid configuration.
|
|
391
|
-
*/
|
|
392
|
-
function startLookupFailedWords(destination) {
|
|
393
|
-
return `Destination "${destination}": the ABAP system gave no session user and system id: systeminformation answered without them or with an error, a problem of the ABAP system with a valid configuration; the server did not start`;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* The start's words for a destination whose system kind no parameter states.
|
|
397
|
-
*/
|
|
398
|
-
function startSystemTypeRequiredWords(destination) {
|
|
399
|
-
return `Destination "${destination}": the SAP system type is required — set --system-type, SAP_SYSTEM_TYPE (the environment or the --env file) or system-type (YAML) to onprem, cloud or legacy; the server did not start`;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* The start's words for an ABAP Cloud destination whose system has no
|
|
403
|
-
* systeminformation endpoint (`404`): the configuration is inconsistent.
|
|
404
|
-
*/
|
|
405
|
-
function startCloudWithoutSystemInformationWords(destination) {
|
|
406
|
-
return `Destination "${destination}": the destination is stated as ABAP Cloud, but its system has no systeminformation endpoint, which every ABAP Cloud system has: the configuration is inconsistent; the server did not start`;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* The start's words for an on-premise system that gave no information
|
|
410
|
-
* whose destination states no user.
|
|
411
|
-
*/
|
|
412
|
-
function startSystemUserUnknownWords(destination) {
|
|
413
|
-
return `Destination "${destination}": the system gave no session user (systeminformation) and the destination states no user: set SAP_RESPONSIBLE or SAP_USERNAME in the destination or the environment, so the session user is known; the server did not start`;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* The words the connection at start failed in: what the failure reader
|
|
417
|
-
* makes of it (a chain failure, the server's own refusal — a system lookup
|
|
418
|
-
* that failed — or the destination layer's), else the destination, the
|
|
419
|
-
* error's class and the status SAP answered — never its message.
|
|
420
|
-
*/
|
|
421
|
-
function startConnectionWords(error, destination, factory, platform) {
|
|
422
|
-
const options = {
|
|
423
|
-
platform,
|
|
424
|
-
sentenceFor: (e) => factory.sentenceFor(e),
|
|
425
|
-
};
|
|
426
|
-
const read = (0, auth_2.destinationFailureOf)(error, { ...options, destination });
|
|
427
|
-
if (read?.error === 'system_lookup_failed') {
|
|
428
|
-
return startLookupFailedWords(destination);
|
|
429
|
-
}
|
|
430
|
-
if (read?.error === 'cloud_without_systeminformation') {
|
|
431
|
-
return startCloudWithoutSystemInformationWords(destination);
|
|
432
|
-
}
|
|
433
|
-
if (read?.error === 'system_user_unknown') {
|
|
434
|
-
return startSystemUserUnknownWords(destination);
|
|
435
|
-
}
|
|
436
|
-
if (read !== undefined) {
|
|
437
|
-
return (0, auth_2.destinationFailureWords)(error, destination, options);
|
|
438
|
-
}
|
|
439
|
-
// connection's refusal of an RFC address it cannot dial (a message server
|
|
440
|
-
// with neither msserv nor sysid): its own fixed words, as it came.
|
|
441
|
-
const address = (0, config_1.rfcAddressRefusalOf)(error);
|
|
442
|
-
if (address !== undefined) {
|
|
443
|
-
return `Destination "${destination}" could not be connected at start: ${address}`;
|
|
444
|
-
}
|
|
445
|
-
const sap = (0, embeddable_1.sapAnswerOf)(error);
|
|
446
|
-
return `Destination "${destination}" could not be connected at start: ${(0, auth_1.errorClassOf)(error)}${sap === undefined ? '' : `, SAP answered ${sap.status}`}`;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* The startup check, then the summary. The destination's settings are
|
|
450
|
-
* read and its provider is built — `getProvider(destination, { signal })`
|
|
451
|
-
* with the start's own signal, aborted once the check ends — so a
|
|
452
|
-
* destination the broker refuses stops the start; building sends nothing.
|
|
453
|
-
* Then what its stores hold, masked as before (H4's one exception).
|
|
454
|
-
*/
|
|
455
|
-
async function checkAndSummarise(factory, destination, config, stderr, platform) {
|
|
456
|
-
const settings = await factory.settingsFor(destination);
|
|
457
|
-
const startup = new AbortController();
|
|
458
|
-
try {
|
|
459
|
-
await factory.getProvider(destination, { signal: startup.signal });
|
|
460
|
-
}
|
|
461
|
-
finally {
|
|
462
|
-
startup.abort();
|
|
463
|
-
}
|
|
464
|
-
try {
|
|
465
|
-
const broker = await factory.getBroker(destination);
|
|
466
|
-
const connConfig = await broker.getConnectionConfig(destination);
|
|
467
|
-
const displayConfig = {
|
|
468
|
-
serviceUrl: settings.url,
|
|
469
|
-
sapClient: settings.client,
|
|
470
|
-
authType: settings.authType,
|
|
471
|
-
username: connConfig?.username,
|
|
472
|
-
password: connConfig?.password,
|
|
473
|
-
jwtToken: connConfig?.authorizationToken,
|
|
474
|
-
};
|
|
475
|
-
try {
|
|
476
|
-
const authConfig = await broker.getAuthorizationConfig(destination);
|
|
477
|
-
if (authConfig) {
|
|
478
|
-
displayConfig.uaaUrl = authConfig.uaaUrl;
|
|
479
|
-
displayConfig.uaaClientId = authConfig.uaaClientId;
|
|
480
|
-
displayConfig.uaaClientSecret = authConfig.uaaClientSecret;
|
|
481
|
-
displayConfig.refreshToken = authConfig.refreshToken;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
catch {
|
|
485
|
-
// The client is optional: a destination without one shows none.
|
|
486
|
-
}
|
|
487
|
-
const source = config.mcpDestination
|
|
488
|
-
? `service-key: ${config.mcpDestination}`
|
|
489
|
-
: (config.envFile ?? config.envFilePath ?? 'unknown');
|
|
490
|
-
stderr((0, utils_1.formatAuthConfigForDisplay)(displayConfig, source));
|
|
491
|
-
}
|
|
492
|
-
catch (error) {
|
|
493
|
-
// The summary is information: it never stops a start the settings allowed.
|
|
494
|
-
stderr(`[MCP] Warning: Could not display auth config: ${startupWords(error, destination, factory, platform)}`);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Everything after the parameters are read: the tool list, one factory, the
|
|
499
|
-
* destination the process serves checked and summarised, the shutdown, the
|
|
500
|
-
* connection born (`connectAtStart`: the destination's one leftover session
|
|
501
|
-
* taken up, or a logon — a browser login included — with the system
|
|
502
|
-
* information), and only then the transport. A destination that cannot be
|
|
503
|
-
* served, a logon or resume that fails, a system lookup that fails: each
|
|
504
|
-
* ends the process with exit `1` and the failure's words on stderr, before
|
|
505
|
-
* any transport opens.
|
|
20
|
+
* `@mcp-abap-adt/core/launcher` — the stdio launcher. Its code lives in
|
|
21
|
+
* `@mcp-abap-adt/server-runtime` (19.2.0); this path re-exports
|
|
22
|
+
* `@mcp-abap-adt/server-runtime/stdio`, so an importer sees the names it saw
|
|
23
|
+
* before.
|
|
506
24
|
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
* once it received the logoff whole.
|
|
25
|
+
* And it takes 19.1.0's options: `LauncherOptions`, `main` and `launch` here
|
|
26
|
+
* accept `{ toolSet, program, version }` as before. `packageName` — required
|
|
27
|
+
* on the runtime's own path — is optional here and defaults to
|
|
28
|
+
* `@mcp-abap-adt/core`, the package a second copy of lib then asks to
|
|
29
|
+
* reinstall; a value given passes through.
|
|
513
30
|
*/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
await (0, state_1.logOffAtOnce)();
|
|
520
|
-
throw error;
|
|
521
|
-
}
|
|
31
|
+
const stdio_1 = require("@mcp-abap-adt/server-runtime/stdio");
|
|
32
|
+
const coreVersion_js_1 = require("./coreVersion.js");
|
|
33
|
+
__exportStar(require("@mcp-abap-adt/server-runtime/stdio"), exports);
|
|
34
|
+
function withPackage(options) {
|
|
35
|
+
return { ...options, packageName: options.packageName ?? coreVersion_js_1.CORE_PACKAGE };
|
|
522
36
|
}
|
|
523
|
-
async function
|
|
524
|
-
|
|
525
|
-
// a value already there — so its SAP_CONNECTION_TYPE and SAP_SYSTEM_TYPE
|
|
526
|
-
// count (as in 15.x).
|
|
527
|
-
(0, envFileContext_1.hydrateSystemContextFromEnvFile)(config.envFile ?? config.envFilePath);
|
|
528
|
-
let connectionType;
|
|
529
|
-
let systemType;
|
|
530
|
-
try {
|
|
531
|
-
connectionType = effectiveConnectionType(config, process.env);
|
|
532
|
-
systemType = effectiveSystemType(config, process.env);
|
|
533
|
-
}
|
|
534
|
-
catch (error) {
|
|
535
|
-
deps.stderr(`[MCP] ${error instanceof LauncherRefusal ? error.words : 'SAP_CONNECTION_TYPE or SAP_SYSTEM_TYPE: refused'}`);
|
|
536
|
-
deps.exit(1);
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
if (connectionType)
|
|
540
|
-
process.env.SAP_CONNECTION_TYPE = connectionType;
|
|
541
|
-
// The connector reads the system type from the environment.
|
|
542
|
-
if (systemType)
|
|
543
|
-
process.env.SAP_SYSTEM_TYPE = systemType;
|
|
544
|
-
config = {
|
|
545
|
-
...withoutMessageServer(config),
|
|
546
|
-
connectionType,
|
|
547
|
-
systemType,
|
|
548
|
-
...effectiveMessageServer(config, process.env),
|
|
549
|
-
};
|
|
550
|
-
// The command's tool set: fixed by the command, never by a flag.
|
|
551
|
-
const handlersRegistry = (0, tool_set_1.registryOf)(options.toolSet, 'stdio');
|
|
552
|
-
// The browser of a login, mapped by the platform; a choice that
|
|
553
|
-
// cannot be served stops the start before anything is read.
|
|
554
|
-
let browser;
|
|
555
|
-
let browserUnavailable;
|
|
556
|
-
try {
|
|
557
|
-
const mapping = (0, auth_2.browserFor)({ browser: config.browser, program: config.browserProgram }, deps.platform ?? process.platform);
|
|
558
|
-
// No browser on this platform refuses only a destination that logs in,
|
|
559
|
-
// at the startup check; the others start.
|
|
560
|
-
if (mapping.unavailable !== undefined) {
|
|
561
|
-
browserUnavailable = mapping.unavailable;
|
|
562
|
-
}
|
|
563
|
-
else {
|
|
564
|
-
browser = (0, auth_2.browserOf)(mapping);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
catch (error) {
|
|
568
|
-
if (!(error instanceof auth_2.BrowserChoiceError))
|
|
569
|
-
throw error;
|
|
570
|
-
deps.stderr(`[MCP] ${error.words}`);
|
|
571
|
-
deps.exit(1);
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
if (config.authDebug === true) {
|
|
575
|
-
deps.stderr(exports.AUTH_DEBUG_WARNING);
|
|
576
|
-
}
|
|
577
|
-
const factory = new auth_2.AuthBrokerFactory(factoryConfigFrom(config, {
|
|
578
|
-
browserStrategy: deps.browserStrategy,
|
|
579
|
-
browser,
|
|
580
|
-
browserUnavailable,
|
|
581
|
-
// A login prompts on stderr whatever DEBUG_AUTH_LOG says; the broker's
|
|
582
|
-
// diagnostics stay gated.
|
|
583
|
-
promptLogger: (0, auth_2.promptLogger)(deps.stderr, loggerForTransport),
|
|
584
|
-
// --auth-debug routes the providers' debug lines to stderr.
|
|
585
|
-
logger: config.authDebug === true ? stderrLogger : loggerForTransport,
|
|
586
|
-
}));
|
|
587
|
-
// The start is tracked, and the shutdown installed, before anything
|
|
588
|
-
// is read: a signal or the client closing stdin during the startup check
|
|
589
|
-
// is latched like one later — latch, every owned connection logged off at
|
|
590
|
-
// once and the running tools interrupted, the MCP server closed (none yet
|
|
591
|
-
// is nothing to close), then the gate, the logins, the drain and the
|
|
592
|
-
// flush. A shutdown during the start ends it with exit 1.
|
|
593
|
-
const birth = (0, shutdown_js_1.startBirth)();
|
|
594
|
-
(0, shutdown_js_1.installShutdown)({
|
|
595
|
-
factory,
|
|
596
|
-
instance: { close: async () => activeServer?.close() },
|
|
597
|
-
onStdinEnd: true,
|
|
598
|
-
exit: deps.exit,
|
|
599
|
-
stderr: deps.stderr,
|
|
600
|
-
processLike: deps.processLike,
|
|
601
|
-
shutdownTimeoutMs: config.shutdownTimeout === undefined
|
|
602
|
-
? undefined
|
|
603
|
-
: config.shutdownTimeout * 1000,
|
|
604
|
-
birth,
|
|
605
|
-
});
|
|
606
|
-
// --mcp=X → X; an --env file → default; neither → none (one destination either way).
|
|
607
|
-
const destination = factory.defaultDestination;
|
|
608
|
-
if (destination) {
|
|
609
|
-
try {
|
|
610
|
-
if (config.mcpDestination) {
|
|
611
|
-
(0, auth_1.assertDestinationName)(config.mcpDestination, '--mcp');
|
|
612
|
-
}
|
|
613
|
-
await checkAndSummarise(factory, destination, config, deps.stderr, deps.platform ?? process.platform);
|
|
614
|
-
}
|
|
615
|
-
catch (error) {
|
|
616
|
-
// A shutdown began meanwhile: its exit 1 is the process's one exit.
|
|
617
|
-
if (birth.shutdownBegan())
|
|
618
|
-
return;
|
|
619
|
-
deps.stderr(`[MCP] ${startupWords(error, destination, factory, deps.platform ?? process.platform)}`);
|
|
620
|
-
deps.exit(1);
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
// The shutdown began during the check: no connector is born, no transport
|
|
625
|
-
// opens.
|
|
626
|
-
if (birth.shutdownBegan())
|
|
627
|
-
return;
|
|
628
|
-
// A destination's system kind is required: never guessed. After the
|
|
629
|
-
// destination's own check (which sends nothing), the start ends here
|
|
630
|
-
// without it — before anything is sent and before the transport.
|
|
631
|
-
if (destination && systemType === undefined) {
|
|
632
|
-
deps.stderr(`[MCP] ${startSystemTypeRequiredWords(destination)}`);
|
|
633
|
-
deps.exit(1);
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
if (!destination) {
|
|
637
|
-
// Inspection-only mode: no connection parameters provided
|
|
638
|
-
deps.stderr('[MCP] Starting in inspection-only mode (no connection parameters).');
|
|
639
|
-
deps.stderr('[MCP] To connect to SAP system, use --mcp=<destination> or --env-path=<path>');
|
|
640
|
-
}
|
|
641
|
-
const server = new StdioServer_js_1.StdioServer(handlersRegistry, destination ? factory : undefined, {
|
|
642
|
-
version: options.version,
|
|
643
|
-
// The process's runtime session files, beside the destination's
|
|
644
|
-
// sessions (`--auth-broker-path` moves both).
|
|
645
|
-
leftoverSessions: new embeddable_1.LeftoverSessions({
|
|
646
|
-
directory: (0, embeddable_1.runtimeDirectory)((0, platformPaths_1.getPlatformPaths)(config.authBrokerPath)[0]),
|
|
647
|
-
}),
|
|
648
|
-
// Background runs of the run tools, kept in this process's memory;
|
|
649
|
-
// they end with the process. Only where the set serves them: a -ro
|
|
650
|
-
// command has none, so a run's `background: true` is refused.
|
|
651
|
-
...(options.toolSet.backgroundRuns && {
|
|
652
|
-
backgroundRuns: new background_runs_memory_1.InMemoryBackgroundRuns(),
|
|
653
|
-
}),
|
|
654
|
-
// Batch mode: the one instance's batch state, owned here.
|
|
655
|
-
batch: new embeddable_1.InstanceBatch({
|
|
656
|
-
keepRawParts: config.batchKeepRawParts === true,
|
|
657
|
-
}),
|
|
658
|
-
stateIdleMinutes: config.stateIdleMinutes,
|
|
659
|
-
stateLogger: exports.stateLoggerForTransport,
|
|
660
|
-
logger: loggerForTransport,
|
|
661
|
-
sentenceFor: (error) => factory.sentenceFor(error),
|
|
662
|
-
});
|
|
663
|
-
activeServer = server;
|
|
664
|
-
// The connection is born before the transport opens: nothing to retry,
|
|
665
|
-
// the process ends with what failed. A shutdown during the birth (stdin
|
|
666
|
-
// closed, a signal) ends it, and its exit — 1, the start failed — is the
|
|
667
|
-
// process's one exit.
|
|
668
|
-
if (destination) {
|
|
669
|
-
try {
|
|
670
|
-
await birth.joining(server.connectAtStart(destination));
|
|
671
|
-
}
|
|
672
|
-
catch (error) {
|
|
673
|
-
deps.stderr(`[MCP] ${startConnectionWords(error, destination, factory, deps.platform ?? process.platform)}`);
|
|
674
|
-
// The birth logged off what it logged on; the exit waits for SAP's
|
|
675
|
-
// answer to that logoff, so the session ends with the process.
|
|
676
|
-
if (!birth.shutdownBegan())
|
|
677
|
-
await (0, state_1.logOffAtOnce)();
|
|
678
|
-
if (!birth.shutdownBegan())
|
|
679
|
-
deps.exit(1);
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
// The shutdown began meanwhile: the transport never opens.
|
|
684
|
-
if (!birth.open())
|
|
685
|
-
return;
|
|
686
|
-
// stdio unless the edges carry a transport of their own (a test's).
|
|
687
|
-
await (deps.transport === undefined
|
|
688
|
-
? server.start(destination)
|
|
689
|
-
: server.start(destination, deps.transport));
|
|
37
|
+
async function main(options, edges) {
|
|
38
|
+
return (0, stdio_1.main)(withPackage(options), edges);
|
|
690
39
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
* `logFields` of what the value classifies as — never its message.
|
|
694
|
-
*/
|
|
695
|
-
function launcherFailedLine(thrown) {
|
|
696
|
-
return `[MCP] launcher failed: ${JSON.stringify((0, auth_errors_1.logFields)((0, auth_errors_1.classify)(thrown, 'unfamiliar-error')))}`;
|
|
40
|
+
async function launch(config, options, deps) {
|
|
41
|
+
return (0, stdio_1.launch)(config, withPackage(options), deps);
|
|
697
42
|
}
|
|
698
|
-
// The bin calls `main({ toolSet: fullToolSet, … })` itself, and a sibling
|
|
699
|
-
// command imports it with its own set — nothing starts a server on import.
|
|
700
43
|
//# sourceMappingURL=launcher.js.map
|