@jini-ai/mcp 0.7.1 → 0.7.3-next.1
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/CHANGELOG.md +1 -1
- package/dist/agent-install/antigravity/install.d.ts +15 -0
- package/dist/agent-install/antigravity/install.js +15 -0
- package/dist/agent-install/claude/install.d.ts +4 -0
- package/dist/agent-install/claude/install.js +11 -0
- package/dist/agent-install/cline/install.d.ts +4 -0
- package/dist/agent-install/cline/install.js +7 -0
- package/dist/agent-install/codex/install.d.ts +4 -0
- package/dist/agent-install/codex/install.js +10 -0
- package/dist/agent-install/cursor/install.d.ts +4 -0
- package/dist/agent-install/cursor/install.js +4 -0
- package/dist/agent-install/hermes/install.d.ts +4 -0
- package/dist/agent-install/hermes/install.js +26 -0
- package/dist/agent-install/index.d.ts +1 -1
- package/dist/agent-install/install.d.ts +1 -11
- package/dist/agent-install/install.js +29 -167
- package/dist/agent-install/kimi/install.d.ts +4 -0
- package/dist/agent-install/kimi/install.js +10 -0
- package/dist/agent-install/openclaw/install.d.ts +4 -0
- package/dist/agent-install/openclaw/install.js +4 -0
- package/dist/agent-install/opencode/install.d.ts +4 -0
- package/dist/agent-install/opencode/install.js +7 -0
- package/dist/agent-install/owned-json-install.d.ts +7 -0
- package/dist/agent-install/owned-json-install.js +4 -4
- package/dist/agent-install/pi/install.d.ts +4 -0
- package/dist/agent-install/pi/install.js +13 -0
- package/dist/agent-install/planner-shared.d.ts +40 -0
- package/dist/agent-install/planner-shared.js +52 -0
- package/dist/agent-install/trae/install.d.ts +4 -0
- package/dist/agent-install/trae/install.js +7 -0
- package/dist/agent-install/vibe/install.d.ts +4 -0
- package/dist/agent-install/vibe/install.js +30 -0
- package/dist/bin/serve.js +5 -3
- package/dist/client/client.js +11 -7
- package/dist/core/claude/config.d.ts +21 -0
- package/dist/core/claude/config.js +29 -0
- package/dist/core/config-shared.d.ts +27 -0
- package/dist/core/config-shared.js +64 -0
- package/dist/core/config.d.ts +60 -81
- package/dist/core/config.js +33 -192
- package/dist/core/opencode/config.d.ts +39 -0
- package/dist/core/opencode/config.js +74 -0
- package/dist/core/tokens.d.ts +38 -25
- package/dist/core/tokens.js +23 -54
- package/dist/federation/adapter.http.d.ts +8 -5
- package/dist/federation/adapter.http.js +12 -8
- package/dist/federation/admissions.d.ts +36 -0
- package/dist/federation/admissions.js +34 -0
- package/dist/federation/approvals/call-confirmation.js +2 -2
- package/dist/federation/approvals/remembered-approval.d.ts +11 -2
- package/dist/federation/approvals/remembered-approval.js +11 -8
- package/dist/federation/approvals/revocation-reason.d.ts +3 -1
- package/dist/federation/approvals/revocation-reason.js +1 -1
- package/dist/federation/approvals/revocation.js +3 -3
- package/dist/federation/approvals/scope-option.d.ts +3 -1
- package/dist/federation/approvals/scope-option.js +1 -1
- package/dist/federation/bootstrap.d.ts +1 -1
- package/dist/federation/bootstrap.js +4 -5
- package/dist/federation/config.d.ts +1 -1
- package/dist/federation/hosted/access.d.ts +53 -1
- package/dist/federation/hosted/access.js +94 -0
- package/dist/federation/hosted/connection-gate.js +1 -1
- package/dist/federation/hosted/index.d.ts +11 -3
- package/dist/federation/hosted/index.js +9 -3
- package/dist/federation/hosted/pinned-capability.d.ts +91 -0
- package/dist/federation/hosted/pinned-capability.js +73 -0
- package/dist/federation/hosted/probe.d.ts +67 -0
- package/dist/federation/hosted/probe.js +99 -0
- package/dist/federation/hosted/revocation.d.ts +5 -2
- package/dist/federation/hosted/revocation.js +1 -1
- package/dist/federation/hosted/store-config.d.ts +43 -0
- package/dist/federation/hosted/store-config.js +209 -0
- package/dist/federation/hosted/store-credentials.d.ts +74 -0
- package/dist/federation/hosted/store-credentials.js +228 -0
- package/dist/federation/hosted/store-input.d.ts +55 -0
- package/dist/federation/hosted/store-input.js +232 -0
- package/dist/federation/hosted/store-oauth-fields.d.ts +26 -0
- package/dist/federation/hosted/store-oauth-fields.js +246 -0
- package/dist/federation/hosted/store-view.d.ts +49 -0
- package/dist/federation/hosted/store-view.js +112 -0
- package/dist/federation/hosted/store.d.ts +13 -180
- package/dist/federation/hosted/store.js +33 -1252
- package/dist/federation/hosted/store.memory.d.ts +26 -1
- package/dist/federation/hosted/store.memory.js +71 -22
- package/dist/federation/hosted/store.save.d.ts +39 -0
- package/dist/federation/hosted/store.save.js +63 -0
- package/dist/federation/hosted/vault.d.ts +79 -1
- package/dist/federation/hosted/vault.js +107 -0
- package/dist/federation/hosted/vocabulary.d.ts +1 -1
- package/dist/federation/hosted/vocabulary.js +1 -1
- package/dist/federation/index.d.ts +1 -0
- package/dist/federation/index.js +1 -0
- package/dist/federation/mcp-protocol.d.ts +1 -1
- package/dist/federation/mcp-protocol.js +1 -1
- package/dist/federation/ports.d.ts +2 -2
- package/dist/federation/refusal-notice.d.ts +1 -1
- package/dist/federation/refusal-notice.js +1 -1
- package/dist/federation/registrations.d.ts +6 -6
- package/dist/federation/registrations.js +1 -1
- package/dist/federation/reload.js +37 -36
- package/dist/federation/stdio/adapter.stdio.js +27 -20
- package/dist/federation/stdio/default-connect.d.ts +2 -5
- package/dist/federation/stdio/default-connect.js +2 -1
- package/dist/federation/stdio/index.d.ts +1 -0
- package/dist/federation/stdio/index.js +1 -0
- package/dist/federation/stdio/smoke.d.ts +62 -0
- package/dist/federation/stdio/smoke.js +156 -0
- package/dist/federation/trust.d.ts +2 -2
- package/dist/federation/trust.js +4 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1 -1
- package/dist/server/adapters/sdk-server.d.ts +88 -0
- package/dist/server/adapters/sdk-server.js +27 -0
- package/dist/server/{sdk-transport.d.ts → adapters/sdk-transport.d.ts} +3 -3
- package/dist/server/{sdk-transport.js → adapters/sdk-transport.js} +2 -2
- package/dist/server/adapters/sdk-wire.d.ts +16 -0
- package/dist/server/adapters/sdk-wire.js +16 -0
- package/dist/server/call-progress.d.ts +48 -0
- package/dist/server/call-progress.js +60 -0
- package/dist/server/http-tool-server.adapter.js +209 -196
- package/dist/server/index.d.ts +1 -0
- package/dist/server/loopback-fetch.d.ts +5 -0
- package/dist/server/loopback-fetch.js +48 -0
- package/dist/server/resource-protocol.d.ts +1 -1
- package/dist/server/run-tool-host.js +3 -1
- package/dist/server/stdio-hosting.d.ts +8 -12
- package/dist/server/stdio-hosting.js +135 -126
- package/dist/server/tool-arguments.d.ts +9 -1
- package/dist/server/tool-arguments.js +18 -4
- package/dist/server/tool-protocol.d.ts +15 -3
- package/dist/server/tool-protocol.js +18 -21
- package/dist/server/tool-result-pages.js +37 -28
- package/dist/server/tool-server.d.ts +8 -46
- package/dist/server/tool-server.js +138 -128
- package/dist/server/tools/component-catalog-tools.d.ts +2 -2
- package/dist/server/tools/component-catalog-tools.js +2 -2
- package/dist/server/tools/delegated-tool.js +74 -57
- package/dist/server/tools/run-tools.d.ts +5 -5
- package/dist/server/tools/run-tools.js +5 -5
- package/dist/server/tools/tool-catalog-tools.d.ts +2 -2
- package/dist/server/tools/tool-catalog-tools.js +35 -12
- package/package.json +8 -9
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { SUPPORTED_EXTERNAL_MCP_TRANSPORTS } from "./vocabulary.js";
|
|
2
|
+
import { resolveExternalMcpAuthMode } from "./auth.js";
|
|
3
|
+
import { externalMcpAdmissionRevision, parseExternalMcpJsonArray, readExternalMcpToolGrants } from "./access.js";
|
|
4
|
+
import { openExternalMcpEnv } from "./vault.js";
|
|
5
|
+
import { openExternalMcpStaticAccessToken, resolveExternalMcpAccessToken } from "./store-credentials.js";
|
|
6
|
+
import { FEDERATED_CONNECTION_DEFAULTS } from "../config.js";
|
|
7
|
+
/** A failure entry for one record, in the shape {@link readEnabledExternalMcpConfigs} collects. */
|
|
8
|
+
function externalMcpFailure({ record, reason }, { category } = {}) {
|
|
9
|
+
return { ok: false, failure: { serverId: record.serverId, reason, ...(category === undefined ? {} : { category }) } };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds a `stdio` row's target: its pasted environment, plus the access token under the operator's
|
|
13
|
+
* chosen variable name when the row is OAuth-authenticated.
|
|
14
|
+
*
|
|
15
|
+
* The two credential sources compose rather than exclude: a server can need a pasted `BASE_URL` AND
|
|
16
|
+
* an OAuth bearer token. The OAuth-derived variable is applied LAST so it cannot be shadowed by a
|
|
17
|
+
* stale hand-typed copy of the same name in the pasted block.
|
|
18
|
+
*/
|
|
19
|
+
async function resolveStdioTarget(record, env, authMode, oauth, staticAccessToken, ports) {
|
|
20
|
+
if (!record.command)
|
|
21
|
+
return externalMcpFailure({ record, reason: "no command is configured to launch it" });
|
|
22
|
+
const withStaticToken = withStaticAccessToken(record, env, authMode, staticAccessToken);
|
|
23
|
+
if (withStaticToken === null) {
|
|
24
|
+
return externalMcpFailure({ record, reason: "no environment variable name is configured to receive its access token" });
|
|
25
|
+
}
|
|
26
|
+
let resolvedEnv = withStaticToken;
|
|
27
|
+
if (authMode === "oauth") {
|
|
28
|
+
if (!record.oauthTokenEnvName) {
|
|
29
|
+
return externalMcpFailure({ record, reason: "no environment variable name is configured to receive its OAuth access token" });
|
|
30
|
+
}
|
|
31
|
+
const token = await resolveExternalMcpAccessToken({ record, oauth, settingsLink: ports.settingsLink, reauthRequiredCode: ports.reauthRequiredCode });
|
|
32
|
+
if (!token.ok)
|
|
33
|
+
return externalMcpFailure({ record, reason: token.reason }, { category: token.category });
|
|
34
|
+
resolvedEnv = { ...resolvedEnv, [record.oauthTokenEnvName]: token.token };
|
|
35
|
+
}
|
|
36
|
+
return { ok: true, target: { kind: "stdio", command: record.command, args: parseExternalMcpJsonArray({ raw: record.args }), env: resolvedEnv } };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Builds a hosted row's target: its endpoint, plus the bearer header when the row is
|
|
40
|
+
* OAuth-authenticated.
|
|
41
|
+
*
|
|
42
|
+
* A hosted row's pasted `env` block is deliberately NOT turned into headers. An operator typing
|
|
43
|
+
* `FOO=bar` means an environment variable, and silently promoting it to a request header would send
|
|
44
|
+
* a value they scoped to a local process to a third party over the network. A hosted server's static
|
|
45
|
+
* credential is the dedicated `static_env` access token instead: typed for THIS endpoint, and sent as
|
|
46
|
+
* `Authorization: Bearer`.
|
|
47
|
+
*/
|
|
48
|
+
async function resolveHttpTarget(record, authMode, oauth, staticAccessToken, ports) {
|
|
49
|
+
if (!record.url)
|
|
50
|
+
return externalMcpFailure({ record, reason: "no URL is configured to reach it" });
|
|
51
|
+
const headers = {};
|
|
52
|
+
let shared = false;
|
|
53
|
+
if (authMode === "static_env" && staticAccessToken !== null)
|
|
54
|
+
headers.authorization = `Bearer ${staticAccessToken}`;
|
|
55
|
+
if (authMode === "oauth") {
|
|
56
|
+
const token = await resolveExternalMcpAccessToken({ record, oauth, settingsLink: ports.settingsLink, reauthRequiredCode: ports.reauthRequiredCode });
|
|
57
|
+
if (!token.ok)
|
|
58
|
+
return externalMcpFailure({ record, reason: token.reason }, { category: token.category });
|
|
59
|
+
headers.authorization = `Bearer ${token.token}`;
|
|
60
|
+
shared = token.shared === true;
|
|
61
|
+
}
|
|
62
|
+
if (headers.authorization !== undefined) {
|
|
63
|
+
const failure = hostedTokenFailure({ authorization: headers.authorization, credential: ports.credential });
|
|
64
|
+
if (failure !== null)
|
|
65
|
+
return externalMcpFailure({ record, reason: failure });
|
|
66
|
+
}
|
|
67
|
+
return { ok: true, target: { kind: "streamable_http", url: record.url, headers,
|
|
68
|
+
...(shared ? { bearerToken: async () => {
|
|
69
|
+
const token = await oauth.resolveSharedAccessToken({ serverId: record.serverId });
|
|
70
|
+
if (token === undefined)
|
|
71
|
+
throw new Error(`This shared connection was removed from this site. Choose a saved connection again in ${ports.settingsLink}.`);
|
|
72
|
+
return token;
|
|
73
|
+
} } : {}),
|
|
74
|
+
} };
|
|
75
|
+
}
|
|
76
|
+
function hostedTokenFailure({ authorization, credential }, _options = {}) {
|
|
77
|
+
try {
|
|
78
|
+
credential.assert({ value: authorization.slice('Bearer '.length), hosted: true });
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
return err instanceof credential.InputError ? err.message : credential.messages.ascii;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `env` with a `static_env` row's access token applied under its variable name — LAST, as the OAuth
|
|
87
|
+
* token is in {@link resolveStdioTarget}, so a stale pasted copy of the same variable cannot shadow it.
|
|
88
|
+
*
|
|
89
|
+
* @returns `env` unchanged when the row holds no static token; `null` when it holds one but names no
|
|
90
|
+
* variable to put it in (the save path refuses that, so reaching it means another writer).
|
|
91
|
+
* @complexity O(n) in the env variable count.
|
|
92
|
+
*/
|
|
93
|
+
function withStaticAccessToken(record, env, authMode, staticAccessToken) {
|
|
94
|
+
if (authMode !== "static_env" || staticAccessToken === null)
|
|
95
|
+
return env;
|
|
96
|
+
if (!record.oauthTokenEnvName)
|
|
97
|
+
return null;
|
|
98
|
+
return { ...env, [record.oauthTokenEnvName]: staticAccessToken };
|
|
99
|
+
}
|
|
100
|
+
/** Resolves one ENABLED record into either a usable config or a failure entry, for
|
|
101
|
+
* {@link readEnabledExternalMcpConfigs}'s loop. */
|
|
102
|
+
async function resolveExternalMcpConfig(record, deps, oauth) {
|
|
103
|
+
const transport = record.transport;
|
|
104
|
+
if (!SUPPORTED_EXTERNAL_MCP_TRANSPORTS.includes(transport)) {
|
|
105
|
+
return externalMcpFailure({ record, reason: `unsupported transport '${record.transport}'` });
|
|
106
|
+
}
|
|
107
|
+
const opened = await openExternalMcpEnv(record, deps);
|
|
108
|
+
if (!opened.ok)
|
|
109
|
+
return externalMcpFailure({ record, reason: opened.reason });
|
|
110
|
+
const authMode = resolveExternalMcpAuthMode(record);
|
|
111
|
+
const staticToken = await openExternalMcpStaticAccessToken(record, deps);
|
|
112
|
+
if (!staticToken.ok)
|
|
113
|
+
return externalMcpFailure({ record, reason: staticToken.reason });
|
|
114
|
+
const resolved = transport === "stdio"
|
|
115
|
+
? await resolveStdioTarget(record, opened.env, authMode, oauth, staticToken.token, deps)
|
|
116
|
+
: await resolveHttpTarget(record, authMode, oauth, staticToken.token, deps);
|
|
117
|
+
if (!resolved.ok)
|
|
118
|
+
return resolved;
|
|
119
|
+
const grants = readExternalMcpToolGrants(record);
|
|
120
|
+
return {
|
|
121
|
+
ok: true,
|
|
122
|
+
config: {
|
|
123
|
+
serverId: record.serverId,
|
|
124
|
+
...(record.provisionedByPluginId ? { provisionedByPluginId: record.provisionedByPluginId } : {}),
|
|
125
|
+
label: record.label ?? record.serverId,
|
|
126
|
+
transport,
|
|
127
|
+
authMode,
|
|
128
|
+
enabled: true,
|
|
129
|
+
allowedToolNames: grants.allowedToolNames,
|
|
130
|
+
writeAllowedToolNames: grants.writeAllowedToolNames,
|
|
131
|
+
target: resolved.target,
|
|
132
|
+
admissionRevision: externalMcpAdmissionRevision(record),
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Reads and decrypts every ENABLED server, for the daemon's boot-time federation pass.
|
|
138
|
+
*
|
|
139
|
+
* A row whose sealed env cannot be opened is SKIPPED rather than thrown on, and the reason is
|
|
140
|
+
* returned in `failures`. This mirrors `bootstrap.ts`'s fail-open posture for the same reason: a
|
|
141
|
+
* rotated site key or a corrupt row must not stop the daemon booting, and one unusable server must
|
|
142
|
+
* not take out a second working one. Disabled rows never reach the sealer at all.
|
|
143
|
+
*
|
|
144
|
+
* @returns The usable configs plus a per-server accounting of what could not be read.
|
|
145
|
+
* @complexity O(n) in the enabled server count, one unseal each.
|
|
146
|
+
* @overallScore 100
|
|
147
|
+
*/
|
|
148
|
+
export async function readEnabledExternalMcpConfigs({ deps, workspaceId }, _optional = {}) {
|
|
149
|
+
const records = await deps.repo.listByWorkspaceId(workspaceId);
|
|
150
|
+
const configs = [];
|
|
151
|
+
const failures = [];
|
|
152
|
+
for (const record of records) {
|
|
153
|
+
if (!record.enabled)
|
|
154
|
+
continue;
|
|
155
|
+
const resolved = await resolveExternalMcpConfig(record, deps, deps.oauth);
|
|
156
|
+
if (resolved.ok)
|
|
157
|
+
configs.push(resolved.config);
|
|
158
|
+
else
|
|
159
|
+
failures.push(resolved.failure);
|
|
160
|
+
}
|
|
161
|
+
return { configs, failures };
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Maps stored configs onto the shape `../bootstrap.ts` consumes.
|
|
165
|
+
*
|
|
166
|
+
* Timeouts and caps come from core's shared `FEDERATED_CONNECTION_DEFAULTS` rather than being
|
|
167
|
+
* stored per server: they are policy about how much a third party may cost this process, which is
|
|
168
|
+
* the host's call and not an operator preference. `allowedToolNames` is the one field that IS the
|
|
169
|
+
* operator's, and it is passed through untouched for `trust.ts` to enforce.
|
|
170
|
+
*
|
|
171
|
+
* @param readOnlyRemoteNamesByServer - Reviewed manifest lists matched by the roster source;
|
|
172
|
+
* never inferred from remote annotations or the tool admission allowlist.
|
|
173
|
+
* @complexity O(n) time and output space in the config count.
|
|
174
|
+
*/
|
|
175
|
+
export function toResolvedFederatedConnections({ configs }, { readOnlyRemoteNamesByServer = new Map() } = {}) {
|
|
176
|
+
return configs.map((config) => ({
|
|
177
|
+
...(config.target.kind === "streamable_http" && config.target.bearerToken ? { bearerToken: config.target.bearerToken } : {}),
|
|
178
|
+
config: {
|
|
179
|
+
connectionId: config.serverId,
|
|
180
|
+
...(config.provisionedByPluginId ? { provisionedByPluginId: config.provisionedByPluginId } : {}),
|
|
181
|
+
label: config.label,
|
|
182
|
+
allowedToolNames: config.allowedToolNames,
|
|
183
|
+
writeAllowedToolNames: config.writeAllowedToolNames,
|
|
184
|
+
...(readOnlyRemoteNamesByServer.has(config.serverId) ? { readOnlyRemoteNames: readOnlyRemoteNamesByServer.get(config.serverId) } : {}),
|
|
185
|
+
connectTimeoutMs: FEDERATED_CONNECTION_DEFAULTS.connectTimeoutMs,
|
|
186
|
+
callTimeoutMs: FEDERATED_CONNECTION_DEFAULTS.callTimeoutMs,
|
|
187
|
+
maxResultBytes: FEDERATED_CONNECTION_DEFAULTS.maxResultBytes,
|
|
188
|
+
maxTools: FEDERATED_CONNECTION_DEFAULTS.maxTools,
|
|
189
|
+
origin: { kind: "roster", admissionRevision: config.admissionRevision },
|
|
190
|
+
},
|
|
191
|
+
launch: toFederatedLaunchSpec(config.target),
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
/** Maps a resolved target onto the federation layer's launch spec. The two shapes are deliberately
|
|
195
|
+
* separate — this one is the store's, that one is federation's — so neither domain has to widen
|
|
196
|
+
* when the other gains a field. */
|
|
197
|
+
function toFederatedLaunchSpec(target) {
|
|
198
|
+
if (target.kind === "streamable_http")
|
|
199
|
+
return { url: target.url, headers: target.headers };
|
|
200
|
+
return {
|
|
201
|
+
command: target.command,
|
|
202
|
+
args: target.args,
|
|
203
|
+
// The child's environment REPLACES the daemon's rather than extending it, matching the
|
|
204
|
+
// Supabase preset. `PATH`/`HOME`/`TMPDIR` are added by the launcher, not here; anything else
|
|
205
|
+
// a server needs is an explicit, written-down grant in its own env block.
|
|
206
|
+
env: target.env,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=store-config.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ResolvedOAuthFields } from "./store-oauth-fields.js";
|
|
2
|
+
import type { ExternalMcpIdentity, OpenDeps, SealDeps } from "./vault.js";
|
|
3
|
+
import type { ExternalMcpAuthMode, ExternalMcpConfigFailure, ExternalMcpOAuthTokenResolverPort, ExternalMcpServerRecord, ExternalMcpTransport, SaveExternalMcpServerInput, SealedExternalMcpOAuth } from "@jini-ai/core/contracts/hosted-mcp";
|
|
4
|
+
import type { SealedSecret } from "@jini-ai/core/contracts/vault";
|
|
5
|
+
import type { HostedMcpStorePorts } from "./store-ports.js";
|
|
6
|
+
/**
|
|
7
|
+
* Obtains one record's OAuth access token, or explains why it cannot be.
|
|
8
|
+
*
|
|
9
|
+
* Returns the raw token rather than a placement, because WHERE it goes is the transport's business:
|
|
10
|
+
* a child-process variable for `stdio`, an `Authorization` header for a hosted endpoint. Splitting
|
|
11
|
+
* "can we get a token" from "where does it go" is what stops the second question's answer from
|
|
12
|
+
* being duplicated per transport.
|
|
13
|
+
*
|
|
14
|
+
* @complexity O(1) plus at most one token refresh round trip.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveExternalMcpAccessToken({ record, oauth, settingsLink, reauthRequiredCode }: {
|
|
17
|
+
record: ExternalMcpServerRecord;
|
|
18
|
+
oauth: ExternalMcpOAuthTokenResolverPort | undefined;
|
|
19
|
+
settingsLink: Pick<HostedMcpStorePorts, "settingsLink" | "reauthRequiredCode">["settingsLink"];
|
|
20
|
+
reauthRequiredCode: Pick<HostedMcpStorePorts, "settingsLink" | "reauthRequiredCode">["reauthRequiredCode"];
|
|
21
|
+
}, _optional?: {}): Promise<{
|
|
22
|
+
readonly ok: true;
|
|
23
|
+
readonly token: string;
|
|
24
|
+
readonly shared?: true;
|
|
25
|
+
} | ({
|
|
26
|
+
readonly ok: false;
|
|
27
|
+
} & Omit<ExternalMcpConfigFailure, "serverId">)>;
|
|
28
|
+
/**
|
|
29
|
+
* Opens a `static_env` row's sealed access token, or resolves `null` when it holds none — without
|
|
30
|
+
* touching the sealer for any other row. A blob that will not open is a per-row failure, the same
|
|
31
|
+
* posture {@link openExternalMcpEnv} takes for the env block.
|
|
32
|
+
*
|
|
33
|
+
* @complexity O(1) — at most one unseal.
|
|
34
|
+
*/
|
|
35
|
+
export declare function openExternalMcpStaticAccessToken(record: ExternalMcpServerRecord, deps: OpenDeps): Promise<{
|
|
36
|
+
readonly ok: true;
|
|
37
|
+
readonly token: string | null;
|
|
38
|
+
} | {
|
|
39
|
+
readonly ok: false;
|
|
40
|
+
readonly reason: string;
|
|
41
|
+
}>;
|
|
42
|
+
export declare function resolveExternalMcpSealedEnv(deps: SealDeps, identity: ExternalMcpIdentity, rawEnv: string | undefined, existing: ExternalMcpServerRecord | null): Promise<{
|
|
43
|
+
readonly sealedEnv: SealedSecret | null;
|
|
44
|
+
readonly envNames: string[];
|
|
45
|
+
readonly aadVersion: number;
|
|
46
|
+
}>;
|
|
47
|
+
/** @agent-note `credential` is the host-bound token policy; its input errors become the canonical validation error with the same message and field. */
|
|
48
|
+
export declare function normalizeExternalMcpAccessToken({ value, transport, credential }: {
|
|
49
|
+
value: unknown;
|
|
50
|
+
transport: string;
|
|
51
|
+
credential: HostedMcpStorePorts["credential"];
|
|
52
|
+
}, _optional?: {}): string;
|
|
53
|
+
/**
|
|
54
|
+
* The sealed-credential columns for one save, by auth mode: a `static_env` row's access token and its
|
|
55
|
+
* variable name, or an `oauth`/`none` row's client secret and carried token set (nothing, for `none`).
|
|
56
|
+
* Split out to keep {@link saveExternalMcpServer} under the shop's complexity ceiling.
|
|
57
|
+
*
|
|
58
|
+
* @complexity O(1) beyond at most one unseal and one seal.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveSavedCredentialColumns({ deps, identity, context }: {
|
|
61
|
+
deps: SealDeps;
|
|
62
|
+
identity: ExternalMcpIdentity;
|
|
63
|
+
context: {
|
|
64
|
+
readonly authMode: ExternalMcpAuthMode;
|
|
65
|
+
readonly transport: ExternalMcpTransport;
|
|
66
|
+
readonly input: SaveExternalMcpServerInput;
|
|
67
|
+
readonly oauthFields: ResolvedOAuthFields;
|
|
68
|
+
readonly keepToken: boolean;
|
|
69
|
+
readonly existing: ExternalMcpServerRecord | null;
|
|
70
|
+
};
|
|
71
|
+
}, _optional?: {}): Promise<SealedExternalMcpOAuth & {
|
|
72
|
+
readonly oauthTokenEnvName: string | null;
|
|
73
|
+
}>;
|
|
74
|
+
//# sourceMappingURL=store-credentials.d.ts.map
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { ExternalMcpValidationError } from "./validation-error.js";
|
|
2
|
+
import { ExternalMcpSecretStoreUnconfiguredError } from "./unconfigured-error.js";
|
|
3
|
+
import { externalMcpRecordHasStaticAccessToken, resolveExternalMcpOAuthStatus } from "./auth.js";
|
|
4
|
+
import { parseExternalMcpJsonArray } from "./access.js";
|
|
5
|
+
import { ENV_NAME_PATTERN, parseEnvBlock } from "./store-input.js";
|
|
6
|
+
import { firstTrimmed } from "./store-oauth-fields.js";
|
|
7
|
+
import { EXTERNAL_MCP_VAULT_VERSION, openExternalMcpOAuthPayload, sealExternalMcpOAuthPayload, sealExternalMcpVaultPayload } from "./vault.js";
|
|
8
|
+
/**
|
|
9
|
+
* A `needs_reauth`/`disconnected`/`pending` row is reported rather than connected.
|
|
10
|
+
*
|
|
11
|
+
* Reported, not silently skipped: an operator whose token expired needs to see WHY the server's
|
|
12
|
+
* tools vanished, and the reason string is the only thing carrying that at boot. The admin tab's
|
|
13
|
+
* `needs_reauth` badge is the out-of-band half of the same signal.
|
|
14
|
+
*/
|
|
15
|
+
function oauthStatusFailure({ record, settingsLink }) {
|
|
16
|
+
const status = resolveExternalMcpOAuthStatus(record);
|
|
17
|
+
if (status === "connected")
|
|
18
|
+
return null;
|
|
19
|
+
if (status === "needs_reauth") {
|
|
20
|
+
return { reason: `its authorization expired or was revoked — reconnect it in ${settingsLink}`, category: "reauth_required" };
|
|
21
|
+
}
|
|
22
|
+
return { reason: `it has not been authorized yet (status '${status}') — connect it in ${settingsLink}` };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Obtains one record's OAuth access token, or explains why it cannot be.
|
|
26
|
+
*
|
|
27
|
+
* Returns the raw token rather than a placement, because WHERE it goes is the transport's business:
|
|
28
|
+
* a child-process variable for `stdio`, an `Authorization` header for a hosted endpoint. Splitting
|
|
29
|
+
* "can we get a token" from "where does it go" is what stops the second question's answer from
|
|
30
|
+
* being duplicated per transport.
|
|
31
|
+
*
|
|
32
|
+
* @complexity O(1) plus at most one token refresh round trip.
|
|
33
|
+
*/
|
|
34
|
+
export async function resolveExternalMcpAccessToken({ record, oauth, settingsLink, reauthRequiredCode }, _optional = {}) {
|
|
35
|
+
try {
|
|
36
|
+
const shared = await oauth?.resolveSharedAccessToken?.({ serverId: record.serverId });
|
|
37
|
+
if (shared !== undefined)
|
|
38
|
+
return { ok: true, token: shared, shared: true };
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return { ok: false, reason: `This shared connection is no longer granted to this site. Choose it again or sign in from ${settingsLink}.` };
|
|
42
|
+
}
|
|
43
|
+
const statusFailure = oauthStatusFailure({ record, settingsLink });
|
|
44
|
+
if (statusFailure !== null)
|
|
45
|
+
return { ok: false, ...statusFailure };
|
|
46
|
+
if (!oauth) {
|
|
47
|
+
return { ok: false, reason: "this process was not wired with an OAuth token resolver, so its access token cannot be obtained" };
|
|
48
|
+
}
|
|
49
|
+
return resolveOwnedAccessToken(record, oauth, { settingsLink, reauthRequiredCode });
|
|
50
|
+
}
|
|
51
|
+
/** {@link resolveExternalMcpAccessToken}'s last step, split out unchanged to keep each function under the complexity limit. */
|
|
52
|
+
async function resolveOwnedAccessToken(record, oauth, { settingsLink, reauthRequiredCode }) {
|
|
53
|
+
try {
|
|
54
|
+
return { ok: true, token: await oauth.resolveAccessToken({ serverId: record.serverId }) };
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// Preserve reauthorization as a typed outcome, without echoing raw provider error messages.
|
|
58
|
+
const needsReauth = err instanceof Error && "code" in err && err.code === reauthRequiredCode;
|
|
59
|
+
return needsReauth
|
|
60
|
+
? { ok: false, reason: `its authorization expired or was revoked — reconnect it in ${settingsLink}`, category: "reauth_required" }
|
|
61
|
+
: { ok: false, reason: `its OAuth access token could not be obtained: OAuth token resolution failed — reconnect this server in ${settingsLink}` };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Opens a `static_env` row's sealed access token, or resolves `null` when it holds none — without
|
|
66
|
+
* touching the sealer for any other row. A blob that will not open is a per-row failure, the same
|
|
67
|
+
* posture {@link openExternalMcpEnv} takes for the env block.
|
|
68
|
+
*
|
|
69
|
+
* @complexity O(1) — at most one unseal.
|
|
70
|
+
*/
|
|
71
|
+
export async function openExternalMcpStaticAccessToken(record, deps) {
|
|
72
|
+
if (!externalMcpRecordHasStaticAccessToken(record))
|
|
73
|
+
return { ok: true, token: null };
|
|
74
|
+
try {
|
|
75
|
+
const payload = await openExternalMcpOAuthPayload(deps, record);
|
|
76
|
+
return { ok: true, token: payload.staticAccessToken ?? null };
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Never put decrypted payloads or cryptographic exception text into an operator/model response.
|
|
80
|
+
return { ok: false, reason: `its stored access token could not be decrypted — re-enter it in ${deps.settingsLink}` };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Resolves the sealed env block and its plaintext variable-name index for one save. `rawEnv ===
|
|
84
|
+
* undefined` preserves whatever `existing` already has (see {@link saveExternalMcpServer}'s doc for
|
|
85
|
+
* why); an empty parsed block clears the seal to `null` rather than sealing `{}`. Split out purely
|
|
86
|
+
* to keep {@link saveExternalMcpServer}'s complexity under the shop ceiling.
|
|
87
|
+
* @throws {ExternalMcpValidationError} On a malformed env block (via {@link parseEnvBlock}).
|
|
88
|
+
* @throws {ExternalMcpSecretStoreUnconfiguredError} When no site key is available to seal under. */
|
|
89
|
+
/** {@link resolveExternalMcpSealedEnv}'s `rawEnv === undefined` branch — carries the existing sealed
|
|
90
|
+
* env block through untouched. Split out purely to keep that function's complexity under the shop
|
|
91
|
+
* ceiling.
|
|
92
|
+
*
|
|
93
|
+
* Carried through untouched, so its lineage must be carried too — bumping the version here would
|
|
94
|
+
* claim an AAD binding the stored ciphertext does not have, and brick the row. */
|
|
95
|
+
function carryForwardExternalMcpSealedEnv(existing) {
|
|
96
|
+
return {
|
|
97
|
+
sealedEnv: existing?.sealedEnv ?? null,
|
|
98
|
+
envNames: parseExternalMcpJsonArray({ raw: existing?.envNames ?? null }),
|
|
99
|
+
aadVersion: existing?.aadVersion ?? EXTERNAL_MCP_VAULT_VERSION,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** {@link resolveExternalMcpSealedEnv}'s fresh-seal branch — parses and seals a NEW env block. Split
|
|
103
|
+
* out purely to keep that function's complexity under the shop ceiling.
|
|
104
|
+
* @throws {ExternalMcpValidationError} On a malformed env block (via {@link parseEnvBlock}).
|
|
105
|
+
* @throws {ExternalMcpSecretStoreUnconfiguredError} When no site key is available to seal under. */
|
|
106
|
+
async function sealFreshExternalMcpEnv(deps, identity, rawEnv) {
|
|
107
|
+
const env = parseEnvBlock({ text: rawEnv, ports: deps });
|
|
108
|
+
const envNames = Object.keys(env);
|
|
109
|
+
if (envNames.length === 0)
|
|
110
|
+
return { sealedEnv: null, envNames, aadVersion: EXTERNAL_MCP_VAULT_VERSION };
|
|
111
|
+
try {
|
|
112
|
+
const sealedEnv = await sealExternalMcpVaultPayload({ deps, identity, kind: "mcp-env", payload: env });
|
|
113
|
+
return { sealedEnv, envNames, aadVersion: EXTERNAL_MCP_VAULT_VERSION };
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
throw new ExternalMcpSecretStoreUnconfiguredError(deps.credential.messages.storage);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export async function resolveExternalMcpSealedEnv(deps, identity, rawEnv, existing) {
|
|
120
|
+
// Owner policy: an exact blank update keeps credentials; whitespace cannot clear them.
|
|
121
|
+
if (rawEnv !== undefined && rawEnv !== '' && rawEnv.trim() === '')
|
|
122
|
+
throw new ExternalMcpValidationError(deps.credential.messages.blank, 'env');
|
|
123
|
+
return rawEnv === undefined || rawEnv === ''
|
|
124
|
+
? carryForwardExternalMcpSealedEnv(existing)
|
|
125
|
+
: sealFreshExternalMcpEnv(deps, identity, rawEnv);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Applies one save's client-secret instruction to the stored blob, preserving the token.
|
|
129
|
+
*
|
|
130
|
+
* `carryToken` is `null` when the save invalidated the stored token (see
|
|
131
|
+
* {@link carryOAuthRuntimeState}); passing the record means "keep whatever token it holds".
|
|
132
|
+
*
|
|
133
|
+
* @throws {ExternalMcpSecretStoreUnconfiguredError} When the blob cannot be opened or resealed.
|
|
134
|
+
* @complexity O(1) — at most one unseal plus one seal.
|
|
135
|
+
*/
|
|
136
|
+
async function resolveSealedOAuthBlob(deps, identity, clientSecret, carryToken) {
|
|
137
|
+
// Nothing to preserve and nothing to write: skip the keyring entirely rather than seal an empty
|
|
138
|
+
// object, which is what keeps a `none`/`static_env` row's OAuth blob genuinely absent.
|
|
139
|
+
if (carryToken === null && (clientSecret === undefined || clientSecret === "")) {
|
|
140
|
+
return { sealedOAuth: null, oauthAadVersion: EXTERNAL_MCP_VAULT_VERSION };
|
|
141
|
+
}
|
|
142
|
+
const existingPayload = carryToken === null ? {} : await openExternalMcpOAuthPayload(deps, carryToken);
|
|
143
|
+
let nextClientSecret = clientSecret;
|
|
144
|
+
if (clientSecret === undefined)
|
|
145
|
+
nextClientSecret = existingPayload.clientSecret;
|
|
146
|
+
if (clientSecret === "")
|
|
147
|
+
nextClientSecret = undefined;
|
|
148
|
+
const next = {
|
|
149
|
+
...(nextClientSecret === undefined ? {} : { clientSecret: nextClientSecret }),
|
|
150
|
+
...(existingPayload.tokens === undefined ? {} : { tokens: existingPayload.tokens }),
|
|
151
|
+
};
|
|
152
|
+
return sealExternalMcpOAuthPayload({ deps, identity, payload: next });
|
|
153
|
+
}
|
|
154
|
+
/** @agent-note `credential` is the host-bound token policy; its input errors become the canonical validation error with the same message and field. */
|
|
155
|
+
export function normalizeExternalMcpAccessToken({ value, transport, credential }, _optional = {}) {
|
|
156
|
+
try {
|
|
157
|
+
return credential.normalize({ value, field: 'accessToken', hosted: transport !== 'stdio' });
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
if (err instanceof credential.InputError)
|
|
161
|
+
throw new ExternalMcpValidationError(err.message, err.field);
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The sealed blob for a `static_env` row's access token, under the `env` field's three-state rule.
|
|
167
|
+
*
|
|
168
|
+
* Stored in the row's existing sealed OAuth columns (and AAD lineage) rather than a new column: it is
|
|
169
|
+
* the same kind of thing — a sealed connection credential beside the env block — and while a row is
|
|
170
|
+
* `static_env` that blob holds nothing else. A carried token keeps its ciphertext AND its
|
|
171
|
+
* `oauthAadVersion` together, for the reason {@link SealedExternalMcpOAuth} gives.
|
|
172
|
+
*
|
|
173
|
+
* @throws {ExternalMcpValidationError} Via {@link assertValidStaticAccessToken}.
|
|
174
|
+
* @throws {ExternalMcpSecretStoreUnconfiguredError} When no site key is available to seal under.
|
|
175
|
+
* @complexity O(n) in the token length; at most one seal.
|
|
176
|
+
*/
|
|
177
|
+
async function resolveSealedStaticAccessToken(deps, identity, rawToken, existing, transport) {
|
|
178
|
+
const none = { sealedOAuth: null, oauthAadVersion: EXTERNAL_MCP_VAULT_VERSION };
|
|
179
|
+
if (rawToken === undefined || rawToken === "") {
|
|
180
|
+
return existing !== null && externalMcpRecordHasStaticAccessToken(existing)
|
|
181
|
+
? { sealedOAuth: existing.sealedOAuth, oauthAadVersion: existing.oauthAadVersion }
|
|
182
|
+
: none;
|
|
183
|
+
}
|
|
184
|
+
const token = normalizeExternalMcpAccessToken({ value: rawToken, transport, credential: deps.credential });
|
|
185
|
+
return sealExternalMcpOAuthPayload({ deps, identity, payload: { staticAccessToken: token } });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Which child env variable receives a `stdio` + `static_env` row's access token. `null` for a hosted
|
|
189
|
+
* row (its token travels in a header) and for a stdio row that neither holds a token nor names one.
|
|
190
|
+
*
|
|
191
|
+
* @throws {ExternalMcpValidationError} When a stdio row holds a token but names no variable, or an
|
|
192
|
+
* invalid one.
|
|
193
|
+
* @complexity O(n) in the name length.
|
|
194
|
+
*/
|
|
195
|
+
function resolveStaticAccessTokenEnvName(transport, input, existing, holdsToken) {
|
|
196
|
+
if (transport !== "stdio")
|
|
197
|
+
return null;
|
|
198
|
+
const name = firstTrimmed(input.accessTokenEnvName, existing?.oauthTokenEnvName);
|
|
199
|
+
if (name === "") {
|
|
200
|
+
if (!holdsToken)
|
|
201
|
+
return null;
|
|
202
|
+
throw new ExternalMcpValidationError("a local command given an access token needs the name of the environment variable that receives it", "accessTokenEnvName");
|
|
203
|
+
}
|
|
204
|
+
if (!ENV_NAME_PATTERN.test(name)) {
|
|
205
|
+
throw new ExternalMcpValidationError(`'${name}' is not a valid environment variable name (letters, digits and underscore, not starting with a digit)`, "accessTokenEnvName");
|
|
206
|
+
}
|
|
207
|
+
return name;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The sealed-credential columns for one save, by auth mode: a `static_env` row's access token and its
|
|
211
|
+
* variable name, or an `oauth`/`none` row's client secret and carried token set (nothing, for `none`).
|
|
212
|
+
* Split out to keep {@link saveExternalMcpServer} under the shop's complexity ceiling.
|
|
213
|
+
*
|
|
214
|
+
* @complexity O(1) beyond at most one unseal and one seal.
|
|
215
|
+
*/
|
|
216
|
+
export async function resolveSavedCredentialColumns({ deps, identity, context }, _optional = {}) {
|
|
217
|
+
const { authMode, transport, input, oauthFields, keepToken, existing } = context;
|
|
218
|
+
if (authMode !== "static_env") {
|
|
219
|
+
const sealed = await resolveSealedOAuthBlob(deps, identity, oauthFields.clientSecret, keepToken ? existing : null);
|
|
220
|
+
return { ...sealed, oauthTokenEnvName: oauthFields.oauthTokenEnvName };
|
|
221
|
+
}
|
|
222
|
+
const sealed = await resolveSealedStaticAccessToken(deps, identity, input.accessToken, existing, transport);
|
|
223
|
+
if (transport !== "stdio" && sealed.sealedOAuth === null) {
|
|
224
|
+
throw new ExternalMcpValidationError("Enter a token. Spaces alone are not a token.", "accessToken");
|
|
225
|
+
}
|
|
226
|
+
return { ...sealed, oauthTokenEnvName: resolveStaticAccessTokenEnvName(transport, input, existing, sealed.sealedOAuth !== null) };
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=store-credentials.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CredentialPorts } from "./store.save.js";
|
|
2
|
+
import type { ExternalMcpTransport, SaveExternalMcpServerInput } from "@jini-ai/core/contracts/hosted-mcp";
|
|
3
|
+
/** POSIX-ish environment variable name. Deliberately stricter than what a shell tolerates: a name
|
|
4
|
+
* outside this set is far more likely a mis-pasted line than an intentional variable. */
|
|
5
|
+
export declare const ENV_NAME_PATTERN: RegExp;
|
|
6
|
+
/** @agent-note `ports` are the host-bound credential rules (length cap, messages, secret-in-plain-field check). */
|
|
7
|
+
export declare function parseEnvBlock({ text, ports }: {
|
|
8
|
+
text: string;
|
|
9
|
+
ports: CredentialPorts;
|
|
10
|
+
}, _optional?: Record<string, never>): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Splits an operator's space-separated argv string.
|
|
13
|
+
*
|
|
14
|
+
* One quoting rule, and only one: a token that STARTS with `"` runs to the next `"`, which must end
|
|
15
|
+
* the token (whitespace or end of string after it), and both quotes are dropped. That is what lets a
|
|
16
|
+
* path with a space in it — `"C:\\Users\\John Smith\\..."`, the desktop shell's win32
|
|
17
|
+
* registration — arrive as one argument. There are no escapes (a backslash is always literal, since
|
|
18
|
+
* Windows paths are full of them), and a `"` anywhere else in a token stays literal exactly as it did
|
|
19
|
+
* before this rule existed, so `--name="x"` still reaches the child unchanged. This is NOT shell
|
|
20
|
+
* quoting: the command is spawned WITHOUT a shell (`adapter.stdio.ts` uses `spawn` with an argv
|
|
21
|
+
* array), and nothing else a shell would do happens here.
|
|
22
|
+
*
|
|
23
|
+
* @throws {ExternalMcpValidationError} On an unterminated quoted token, a closing quote followed by
|
|
24
|
+
* more characters, or more than `MAX_ARGS` arguments.
|
|
25
|
+
* @complexity O(n) in the string length.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseArgs({ raw }: {
|
|
28
|
+
raw: string;
|
|
29
|
+
}, _optional?: Record<string, never>): string[];
|
|
30
|
+
/** Validates `serverId` via the trust tier's own assertion, remapped onto this store's own error
|
|
31
|
+
* type. Split out purely to keep {@link saveExternalMcpServer}'s complexity under the shop
|
|
32
|
+
* ceiling — reuses `trust.ts`'s rule rather than restating it, since this id becomes part of every
|
|
33
|
+
* federated tool id and two copies of that rule could drift. */
|
|
34
|
+
export declare function assertValidExternalMcpServerId(serverId: string): void;
|
|
35
|
+
export declare function assertSupportedExternalMcpTransport(transport: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Splits an operator's comma- or space-separated OAuth scope list.
|
|
38
|
+
*
|
|
39
|
+
* An empty result is legitimate — several providers infer scope from the client registration — so it
|
|
40
|
+
* is returned rather than rejected, the same call {@link parseAllowedToolNames} makes.
|
|
41
|
+
*
|
|
42
|
+
* @throws {ExternalMcpValidationError} Past {@link MAX_OAUTH_SCOPES}.
|
|
43
|
+
* @complexity O(n) in the number of scopes.
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseOAuthScopes({ raw }: {
|
|
46
|
+
raw: string;
|
|
47
|
+
}, _optional?: Record<string, never>): string[];
|
|
48
|
+
/** A `stdio` row needs a command; a remote row needs a URL. Split out to keep
|
|
49
|
+
* {@link saveExternalMcpServer}'s complexity under the shop ceiling.
|
|
50
|
+
* @throws {ExternalMcpValidationError} When the transport's own required field is missing or unsafe. */
|
|
51
|
+
export declare function resolveTransportTarget(transport: ExternalMcpTransport, input: SaveExternalMcpServerInput, ports: CredentialPorts): {
|
|
52
|
+
readonly command: string | null;
|
|
53
|
+
readonly url: string | null;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=store-input.d.ts.map
|