@jini-ai/mcp 0.7.2 → 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 -9
- 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
- package/dist/core/oauth.d.ts +0 -274
- package/dist/core/oauth.js +0 -667
- package/dist/core/secure-write.d.ts +0 -17
- package/dist/core/secure-write.js +0 -72
package/dist/core/tokens.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { redactSecrets } from '@jini-ai/core';
|
|
3
|
-
import { createSystemClock } from "@jini-ai/core/primitives";
|
|
1
|
+
import { createConsoleLogger } from "@jini-ai/core/primitives";
|
|
4
2
|
/**
|
|
5
3
|
* @module @jini-ai/mcp/core/tokens
|
|
6
4
|
* Persistent, 0600-guarded OAuth-token store for remote MCP servers, keyed by
|
|
@@ -25,39 +23,9 @@ import { createSystemClock } from "@jini-ai/core/primitives";
|
|
|
25
23
|
// 0600 atomically at creation and fails closed (removing the temp file and
|
|
26
24
|
// throwing) if a POSIX platform did not honor that mode; it skips
|
|
27
25
|
// verification on `win32`, which has no POSIX permission-bit model.
|
|
28
|
-
import { readFile } from 'node:fs/promises';
|
|
29
26
|
import { createHash } from 'node:crypto';
|
|
30
27
|
import path from 'node:path';
|
|
31
|
-
import {
|
|
32
|
-
/** Shared atomic secret persistence (CR-006 / SEC-RB-002).
|
|
33
|
-
* The previous pattern in each of those stores wrote the temp file with
|
|
34
|
-
* default permissions and either never restricted it (config, OAuth client
|
|
35
|
-
* cache) or `chmod(0600)`'d it *after* the atomic rename and silently
|
|
36
|
-
* continued when the chmod failed (tokens) — both leave a window where the
|
|
37
|
-
* file exists world/group-readable, and the latter makes the "protection"
|
|
38
|
-
* advisory rather than enforced. The platform writer instead:
|
|
39
|
-
*
|
|
40
|
-
* 1. Creates the temp file *exclusively* (`wx`) with mode 0600 supplied to
|
|
41
|
-
* the same `open()`/`writeFile()` call that creates it — POSIX applies
|
|
42
|
-
* the requested mode atomically at creation time, so there is no
|
|
43
|
-
* window where the file exists with a broader mode. Creation-mode enforcement
|
|
44
|
-
* follows the existing prompt-file precedent; the shared writer also reapplies
|
|
45
|
-
* 0600 before checking the mode and flushing the file, never after rename.
|
|
46
|
-
* 2. On POSIX platforms, verifies the on-disk mode actually landed as
|
|
47
|
-
* owner-only before renaming into place, and fails closed — removing
|
|
48
|
-
* the temp file and throwing — if it did not (e.g. an unusual umask or
|
|
49
|
-
* a filesystem that doesn't honor `mode`).
|
|
50
|
-
* 3. Skips that verification on `win32`: Windows has no POSIX permission-
|
|
51
|
-
* bit model (`mode` there only toggles the read-only attribute), so
|
|
52
|
-
* there is nothing meaningful to enforce or fail closed on.
|
|
53
|
-
* 4. Flushes file content before rename and the parent directory after it. A directory
|
|
54
|
-
* flush can fail after replacement; it is reported rather than silently ignored.
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
const defaultFilesystem = {
|
|
58
|
-
readText: ({ filePath }) => readFile(filePath, 'utf8'),
|
|
59
|
-
writeSecretText: ({ filePath, contents }) => writeFileAtomicAsync({ filePath, content: contents }, { mode: 0o600, verifyOwnerOnly: true, createParent: true }),
|
|
60
|
-
};
|
|
28
|
+
import { writeSecretText } from './config.js';
|
|
61
29
|
const EMPTY = { servers: {} };
|
|
62
30
|
function tokensFile(dataDir) {
|
|
63
31
|
return path.join(dataDir, 'mcp-tokens.json');
|
|
@@ -68,7 +36,7 @@ function isPlainObject(v) {
|
|
|
68
36
|
/** Coerce a freeform JSON blob into the typed shape, dropping anything that
|
|
69
37
|
* doesn't deserialize cleanly. Used both at read time and as a defensive
|
|
70
38
|
* pass when third-party tooling has hand-edited the file. */
|
|
71
|
-
export function sanitizeTokensFile({ raw
|
|
39
|
+
export function sanitizeTokensFile({ raw, clock }, _optional = {}) {
|
|
72
40
|
if (!isPlainObject(raw))
|
|
73
41
|
return { servers: {} };
|
|
74
42
|
const servers = raw.servers;
|
|
@@ -129,12 +97,11 @@ function sanitizeToken(raw, clock) {
|
|
|
129
97
|
* @throws On unexpected read errors or a failed backup; the damaged file is left untouched.
|
|
130
98
|
* @complexity O(n) time and space in the token file length, including a backup write on corruption.
|
|
131
99
|
*/
|
|
132
|
-
export async function readTokensFile({ dataDir },
|
|
133
|
-
const filesystem = options.filesystem ?? defaultFilesystem;
|
|
100
|
+
export async function readTokensFile({ dataDir, clock, files }, { report = createConsoleLogger({ prefix: '[mcp-tokens]' }) } = {}) {
|
|
134
101
|
let raw;
|
|
135
102
|
try {
|
|
136
|
-
raw = await
|
|
137
|
-
return sanitizeTokensFile({ raw: JSON.parse(raw) }
|
|
103
|
+
raw = await files.readText({ filePath: tokensFile(dataDir) });
|
|
104
|
+
return sanitizeTokensFile({ raw: JSON.parse(raw), clock });
|
|
138
105
|
}
|
|
139
106
|
catch (err) {
|
|
140
107
|
const e = err;
|
|
@@ -143,11 +110,13 @@ export async function readTokensFile({ dataDir }, options = {}) {
|
|
|
143
110
|
if (e.name === 'SyntaxError' && raw !== undefined) {
|
|
144
111
|
// Different corrupt contents must not overwrite each other's recovery copy.
|
|
145
112
|
const digest = createHash('sha256').update(raw).digest('hex');
|
|
146
|
-
await
|
|
113
|
+
await writeSecretText({
|
|
114
|
+
files,
|
|
147
115
|
filePath: `${tokensFile(dataDir)}.corrupt-${digest}`,
|
|
148
116
|
contents: raw,
|
|
149
117
|
});
|
|
150
|
-
|
|
118
|
+
const logger = report;
|
|
119
|
+
logger.error({ message: `The MCP token file ${tokensFile(dataDir)} is not valid JSON; kept a copy beside it and reading it as an empty store.` }, { error: err });
|
|
151
120
|
return { ...EMPTY, servers: { ...EMPTY.servers } };
|
|
152
121
|
}
|
|
153
122
|
throw err;
|
|
@@ -166,49 +135,49 @@ async function withLock(dataDir, fn) {
|
|
|
166
135
|
writeLocks.delete(dataDir);
|
|
167
136
|
}
|
|
168
137
|
}
|
|
169
|
-
async function writeTokensFile(dataDir, next,
|
|
138
|
+
async function writeTokensFile(dataDir, next, files) {
|
|
170
139
|
const file = tokensFile(dataDir);
|
|
171
140
|
// Bearer tokens can hand someone posting-as-you against the upstream MCP,
|
|
172
141
|
// so the file is created with owner-only (0600) permissions from the
|
|
173
142
|
// first byte and the write fails closed if that can't be guaranteed on a
|
|
174
143
|
// POSIX platform — see `writeFileAtomicAsync`.
|
|
175
|
-
await
|
|
144
|
+
await writeSecretText({ files, filePath: file, contents: JSON.stringify(next, null, 2) });
|
|
176
145
|
return next;
|
|
177
146
|
}
|
|
178
147
|
/** Get the current token for a given server, or null when none is stored
|
|
179
148
|
* (or the persisted entry is malformed). */
|
|
180
|
-
export async function getToken({ dataDir, serverId },
|
|
181
|
-
const file = await readTokensFile({ dataDir },
|
|
149
|
+
export async function getToken({ dataDir, serverId, clock, files }, { report } = {}) {
|
|
150
|
+
const file = await readTokensFile({ dataDir, clock, files }, report ? { report } : {});
|
|
182
151
|
return Object.hasOwn(file.servers, serverId) ? file.servers[serverId] : null;
|
|
183
152
|
}
|
|
184
153
|
/** Atomically merge a new token for `serverId` into the tokens file. */
|
|
185
|
-
export async function setToken({ dataDir, serverId, token },
|
|
154
|
+
export async function setToken({ dataDir, serverId, token, clock, files }, { report } = {}) {
|
|
186
155
|
await withLock(dataDir, async () => {
|
|
187
|
-
const file = await readTokensFile({ dataDir },
|
|
156
|
+
const file = await readTokensFile({ dataDir, clock, files }, report ? { report } : {});
|
|
188
157
|
file.servers[serverId] = token;
|
|
189
|
-
await writeTokensFile(dataDir, file,
|
|
158
|
+
await writeTokensFile(dataDir, file, files);
|
|
190
159
|
});
|
|
191
160
|
}
|
|
192
161
|
/** Atomically delete the stored token for `serverId`. No-op when absent. */
|
|
193
|
-
export async function clearToken({ dataDir, serverId },
|
|
162
|
+
export async function clearToken({ dataDir, serverId, clock, files }, { report } = {}) {
|
|
194
163
|
await withLock(dataDir, async () => {
|
|
195
|
-
const file = await readTokensFile({ dataDir },
|
|
164
|
+
const file = await readTokensFile({ dataDir, clock, files }, report ? { report } : {});
|
|
196
165
|
if (!(serverId in file.servers))
|
|
197
166
|
return;
|
|
198
167
|
delete file.servers[serverId];
|
|
199
|
-
await writeTokensFile(dataDir, file,
|
|
168
|
+
await writeTokensFile(dataDir, file, files);
|
|
200
169
|
});
|
|
201
170
|
}
|
|
202
171
|
/** Bulk read used by the spawn pipeline so we make one disk hit per spawn,
|
|
203
172
|
* not one per server. */
|
|
204
|
-
export async function readAllTokens({ dataDir },
|
|
205
|
-
const file = await readTokensFile({ dataDir },
|
|
173
|
+
export async function readAllTokens({ dataDir, clock, files }, { report } = {}) {
|
|
174
|
+
const file = await readTokensFile({ dataDir, clock, files }, report ? { report } : {});
|
|
206
175
|
return file.servers;
|
|
207
176
|
}
|
|
208
177
|
/** True when the stored token is past its `expiresAt` (or within `skew`
|
|
209
178
|
* milliseconds of expiring). Returns false when no `expiresAt` is recorded
|
|
210
179
|
* — many providers issue non-expiring tokens. */
|
|
211
|
-
export function isTokenExpired({ token }, {
|
|
180
|
+
export function isTokenExpired({ token, clock }, { now = clock.nowMs(), skew = 30_000 } = {}) {
|
|
212
181
|
if (typeof token.expiresAt !== 'number')
|
|
213
182
|
return false;
|
|
214
183
|
return token.expiresAt - skew <= now;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { McpBearerTokenSupplier } from "@jini-ai/core/contracts/hosted-mcp";
|
|
2
|
+
import type { HttpFetchPort } from "@jini-ai/core/contracts/runtime";
|
|
2
3
|
import type { FederationMessages } from "./messages.js";
|
|
3
|
-
import type { TextReadOptions } from "@jini-ai/
|
|
4
|
+
import type { TextReadOptions } from "@jini-ai/core/net";
|
|
4
5
|
import type { McpHttpExchange, McpHttpLaunchSpec, McpSessionPort, McpClientInfo } from "./ports.js";
|
|
5
6
|
/**
|
|
6
7
|
* A connected MCP client session against one hosted server.
|
|
@@ -52,17 +53,19 @@ export declare function connectMcpHttpSession(deps: Omit<McpHttpSessionDependenc
|
|
|
52
53
|
* already under test through the exchange seam, and code that only runs when a real network exists
|
|
53
54
|
* is code that only fails in production.
|
|
54
55
|
*
|
|
55
|
-
* `redirect: "error"` is the security-relevant choice, and matches `
|
|
56
|
+
* `redirect: "error"` is the security-relevant choice, and matches `packages/oauth/src/token-endpoint.ts`:
|
|
56
57
|
* these requests carry a bearer token in a header, and a followed cross-origin redirect would
|
|
57
58
|
* re-send that header to whatever host the server nominated. Refusing to follow means a redirect is
|
|
58
59
|
* a visible failure rather than a silent credential disclosure.
|
|
59
60
|
*
|
|
60
|
-
* Byte caps and strict UTF-8
|
|
61
|
-
*
|
|
61
|
+
* Byte caps and strict UTF-8 require an injected readResponseText (HttpFetchPort); without one,
|
|
62
|
+
* construction throws McpProtocolError. The default path keeps unlimited response.text().
|
|
62
63
|
*
|
|
63
64
|
* @complexity O(n) in the response body length.
|
|
64
65
|
*/
|
|
65
66
|
export declare function createFetchMcpHttpExchange({ fetch: fetchImpl }: {
|
|
66
67
|
fetch: typeof fetch;
|
|
67
|
-
}, optional?: TextReadOptions
|
|
68
|
+
}, optional?: TextReadOptions & {
|
|
69
|
+
readResponseText?: HttpFetchPort["readResponseText"];
|
|
70
|
+
}): McpHttpExchange;
|
|
68
71
|
//# sourceMappingURL=adapter.http.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { loadOptionalPeer } from '@jini-ai/core/optional-peer';
|
|
2
1
|
import { redactSecrets } from '@jini-ai/core';
|
|
3
2
|
import { scrubFederatedResponseValue } from "./result-secrets.js";
|
|
4
3
|
import { parseSseRecord } from "@jini-ai/core/primitives";
|
|
@@ -12,7 +11,7 @@ import { buildInitializeParams, CLIENT_PROTOCOL_VERSION, drainToolsList, McpAuth
|
|
|
12
11
|
* `https://mcp.supabase.com/mcp`, anything SaaS — has no such program, and the only way to reach it
|
|
13
12
|
* is an authenticated HTTPS endpoint. `external-mcp-server-federation.md` deferred this transport
|
|
14
13
|
* with a specific, now-expired reason: "OAuth needs an interactive browser consent flow and a token
|
|
15
|
-
* store, neither of which host app has". `src/platform/oauth/` and
|
|
14
|
+
* store, neither of which host app has". `src/platform/oauth/` and a host module are both of
|
|
16
15
|
* those, so the blocker is gone and, exactly as that doc predicted, this lands as an added adapter
|
|
17
16
|
* rather than a redesign.
|
|
18
17
|
*
|
|
@@ -415,17 +414,22 @@ export async function connectMcpHttpSession(deps, options = {}) {
|
|
|
415
414
|
* already under test through the exchange seam, and code that only runs when a real network exists
|
|
416
415
|
* is code that only fails in production.
|
|
417
416
|
*
|
|
418
|
-
* `redirect: "error"` is the security-relevant choice, and matches `
|
|
417
|
+
* `redirect: "error"` is the security-relevant choice, and matches `packages/oauth/src/token-endpoint.ts`:
|
|
419
418
|
* these requests carry a bearer token in a header, and a followed cross-origin redirect would
|
|
420
419
|
* re-send that header to whatever host the server nominated. Refusing to follow means a redirect is
|
|
421
420
|
* a visible failure rather than a silent credential disclosure.
|
|
422
421
|
*
|
|
423
|
-
* Byte caps and strict UTF-8
|
|
424
|
-
*
|
|
422
|
+
* Byte caps and strict UTF-8 require an injected readResponseText (HttpFetchPort); without one,
|
|
423
|
+
* construction throws McpProtocolError. The default path keeps unlimited response.text().
|
|
425
424
|
*
|
|
426
425
|
* @complexity O(n) in the response body length.
|
|
427
426
|
*/
|
|
428
427
|
export function createFetchMcpHttpExchange({ fetch: fetchImpl }, optional = {}) {
|
|
428
|
+
const { readResponseText, ...textReadOptions } = optional;
|
|
429
|
+
const guarded = textReadOptions.maxResponseBytes !== undefined || textReadOptions.strictUtf8 === true;
|
|
430
|
+
if (guarded && !readResponseText) {
|
|
431
|
+
throw new McpProtocolError({ message: "mcp-federation: readResponseText is required when maxResponseBytes or strictUtf8 is set" });
|
|
432
|
+
}
|
|
429
433
|
return {
|
|
430
434
|
async send(request, options = {}) {
|
|
431
435
|
const response = await fetchImpl(request.url, {
|
|
@@ -440,9 +444,9 @@ export function createFetchMcpHttpExchange({ fetch: fetchImpl }, optional = {})
|
|
|
440
444
|
contentType: (response.headers.get("content-type") ?? "").toLowerCase(),
|
|
441
445
|
sessionId: response.headers.get("mcp-session-id") ?? undefined,
|
|
442
446
|
wwwAuthenticate: response.headers.get("www-authenticate") ?? undefined,
|
|
443
|
-
text:
|
|
444
|
-
? await response
|
|
445
|
-
: await
|
|
447
|
+
text: guarded && readResponseText
|
|
448
|
+
? await readResponseText({ response }, textReadOptions)
|
|
449
|
+
: await response.text(),
|
|
446
450
|
};
|
|
447
451
|
},
|
|
448
452
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Read one federation's admission report after its bounded startup wait. The essential invariant:
|
|
3
|
+
* an unavailable report (not composed, still connecting, malformed, failed read) is never confused with an
|
|
4
|
+
* available, empty roster. Constructs no runtime and no admission store; the host passes its live ones.
|
|
5
|
+
*/
|
|
6
|
+
/** @agent-note Host-wired from the running federation. Absent `awaitFederation`/`readAdmissions` = not composed, so the read fails closed. */
|
|
7
|
+
export interface FederationAdmissionsPorts {
|
|
8
|
+
readonly awaitFederation?: ((required: {
|
|
9
|
+
timeoutMs: number;
|
|
10
|
+
}, optional?: Record<string, never>) => Promise<{
|
|
11
|
+
readonly settled: boolean;
|
|
12
|
+
}>) | undefined;
|
|
13
|
+
/** Live in-process accounting. The federation transport owns remote errors and their tracing. */
|
|
14
|
+
readonly readAdmissions?: (() => Promise<{
|
|
15
|
+
readonly connections: unknown;
|
|
16
|
+
readonly configFailures?: unknown;
|
|
17
|
+
}>) | undefined;
|
|
18
|
+
/** Receives a wait/read failure. Transport errors can carry credentials: the host redacts before it logs. */
|
|
19
|
+
readonly report: (required: {
|
|
20
|
+
error: unknown;
|
|
21
|
+
}, optional?: Record<string, never>) => void;
|
|
22
|
+
}
|
|
23
|
+
export type FederationAdmissionsResult = {
|
|
24
|
+
readonly ok: true;
|
|
25
|
+
readonly connections: readonly unknown[];
|
|
26
|
+
readonly configFailures?: readonly unknown[];
|
|
27
|
+
} | {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
};
|
|
30
|
+
/** Waits (bounded by `timeoutMs`) for the federation to settle, then reads its current reports.
|
|
31
|
+
* @complexity O(1) beyond federation startup and the report reader. */
|
|
32
|
+
export declare function readFederationAdmissions({ ports, timeoutMs }: {
|
|
33
|
+
readonly ports: FederationAdmissionsPorts;
|
|
34
|
+
readonly timeoutMs: number;
|
|
35
|
+
}, _optional?: Record<string, never>): Promise<FederationAdmissionsResult>;
|
|
36
|
+
//# sourceMappingURL=admissions.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Read one federation's admission report after its bounded startup wait. The essential invariant:
|
|
3
|
+
* an unavailable report (not composed, still connecting, malformed, failed read) is never confused with an
|
|
4
|
+
* available, empty roster. Constructs no runtime and no admission store; the host passes its live ones.
|
|
5
|
+
*/
|
|
6
|
+
const UNAVAILABLE = { ok: false };
|
|
7
|
+
/** Accepts a report only when its lists are lists; `configFailures` stays absent when the runtime omitted it. */
|
|
8
|
+
function admittedReport({ report }, _optional = {}) {
|
|
9
|
+
if (!Array.isArray(report.connections))
|
|
10
|
+
return UNAVAILABLE;
|
|
11
|
+
if (report.configFailures !== undefined && !Array.isArray(report.configFailures))
|
|
12
|
+
return UNAVAILABLE;
|
|
13
|
+
return report.configFailures === undefined
|
|
14
|
+
? { ok: true, connections: report.connections }
|
|
15
|
+
: { ok: true, connections: report.connections, configFailures: report.configFailures };
|
|
16
|
+
}
|
|
17
|
+
/** Waits (bounded by `timeoutMs`) for the federation to settle, then reads its current reports.
|
|
18
|
+
* @complexity O(1) beyond federation startup and the report reader. */
|
|
19
|
+
export async function readFederationAdmissions({ ports, timeoutMs }, _optional = {}) {
|
|
20
|
+
const { awaitFederation, readAdmissions, report } = ports;
|
|
21
|
+
if (!awaitFederation || !readAdmissions)
|
|
22
|
+
return UNAVAILABLE;
|
|
23
|
+
try {
|
|
24
|
+
if (!(await awaitFederation({ timeoutMs })).settled)
|
|
25
|
+
return UNAVAILABLE;
|
|
26
|
+
return admittedReport({ report: await readAdmissions() });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
// Only the sink sees the error: an opaque transport failure must not reach the caller.
|
|
30
|
+
report({ error });
|
|
31
|
+
return UNAVAILABLE;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=admissions.js.map
|
|
@@ -41,8 +41,8 @@ export function buildFederatedCallConfirmSpec({ request, messages, errorCode },
|
|
|
41
41
|
export function createFederatedCallConfirmer(required, options = {}) {
|
|
42
42
|
return async ({ context, request }) => {
|
|
43
43
|
const approvals = options.approvals;
|
|
44
|
-
const keys = approvalContext(context, request, approvals, required.fingerprintDomain);
|
|
45
|
-
if (approvals && await isRemembered(approvals, request, keys, options))
|
|
44
|
+
const keys = approvalContext({ context, request, approvals, fingerprintDomain: required.fingerprintDomain });
|
|
45
|
+
if (approvals && await isRemembered({ approvals, request, keys }, options))
|
|
46
46
|
return { confirmed: true };
|
|
47
47
|
const offers = await cardOffers({ request, principalId: context.principal.id, keys, approvals, options });
|
|
48
48
|
const spec = buildFederatedCallConfirmSpec({ request, messages: required.messages, errorCode: required.errorCode }, { offers });
|
|
@@ -12,9 +12,18 @@ export interface ApprovalContext {
|
|
|
12
12
|
} | undefined;
|
|
13
13
|
}
|
|
14
14
|
/** @complexity O(1) beyond the fingerprint hash. */
|
|
15
|
-
export declare function approvalContext(context
|
|
15
|
+
export declare function approvalContext({ context, request, approvals, fingerprintDomain }: {
|
|
16
|
+
context: FederatedConfirmationContext;
|
|
17
|
+
request: FederatedCallConfirmationRequest;
|
|
18
|
+
approvals: FederatedApprovalDeps | undefined;
|
|
19
|
+
fingerprintDomain: string;
|
|
20
|
+
}, _optional?: Record<string, never>): ApprovalContext;
|
|
16
21
|
/** Whether a remembered grant lets this call skip its card. A write-shaped call never does. */
|
|
17
|
-
export declare function isRemembered(approvals
|
|
22
|
+
export declare function isRemembered({ approvals, request, keys }: {
|
|
23
|
+
approvals: FederatedApprovalDeps;
|
|
24
|
+
request: FederatedCallConfirmationRequest;
|
|
25
|
+
keys: ApprovalContext;
|
|
26
|
+
}, options?: FederatedCallConfirmerOptions): Promise<boolean>;
|
|
18
27
|
/** The remember buttons this call's card may offer. A destructive or write-shaped call offers
|
|
19
28
|
* none, and the host's always permission is then not even consulted. */
|
|
20
29
|
export declare function cardOffers({ request, principalId, keys, approvals, options }: {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { nowIso } from "@jini-ai/core/primitives";
|
|
2
2
|
import { federatedToolApprovalFingerprint } from "../tool-approvals.js";
|
|
3
3
|
import { scopeOption } from "./scope-option.js";
|
|
4
|
+
function approvalConversationId(approvals, context) {
|
|
5
|
+
return approvals?.conversationIdForRun?.({ runId: context.run.id });
|
|
6
|
+
}
|
|
4
7
|
/** @complexity O(1) beyond the fingerprint hash. */
|
|
5
|
-
export function approvalContext(context, request, approvals, fingerprintDomain) {
|
|
8
|
+
export function approvalContext({ context, request, approvals, fingerprintDomain }, _optional = {}) {
|
|
6
9
|
const fingerprint = federatedToolApprovalFingerprint({ identity: request, fingerprintDomain });
|
|
7
|
-
const conversationId = approvals
|
|
10
|
+
const conversationId = approvalConversationId(approvals, context);
|
|
8
11
|
return {
|
|
9
12
|
fingerprint,
|
|
10
13
|
chatKey: approvals?.chat && conversationId ? { conversationId, principalId: context.principal.id, connectionId: request.connectionId, toolName: request.remoteName, fingerprint } : undefined,
|
|
@@ -17,15 +20,15 @@ export function approvalContext(context, request, approvals, fingerprintDomain)
|
|
|
17
20
|
async function alwaysGrantAuthorizes(approvals, request, keys, options) {
|
|
18
21
|
if (!keys.alwaysKey || !approvals.always)
|
|
19
22
|
return false;
|
|
20
|
-
const saved = await approvals.always.find(keys.alwaysKey, scopeOption(options.scope));
|
|
23
|
+
const saved = await approvals.always.find(keys.alwaysKey, scopeOption({ scope: options.scope }));
|
|
21
24
|
if (saved && saved.fingerprint === keys.fingerprint && !request.destructive)
|
|
22
25
|
return true;
|
|
23
26
|
if (saved)
|
|
24
|
-
await approvals.always.delete(keys.alwaysKey, scopeOption(options.scope));
|
|
27
|
+
await approvals.always.delete(keys.alwaysKey, scopeOption({ scope: options.scope }));
|
|
25
28
|
return false;
|
|
26
29
|
}
|
|
27
30
|
/** Whether a remembered grant lets this call skip its card. A write-shaped call never does. */
|
|
28
|
-
export async function isRemembered(approvals, request, keys, options) {
|
|
31
|
+
export async function isRemembered({ approvals, request, keys }, options = {}) {
|
|
29
32
|
if (request.writeShapedInputs.length > 0)
|
|
30
33
|
return false;
|
|
31
34
|
if (await alwaysGrantAuthorizes(approvals, request, keys, options))
|
|
@@ -40,7 +43,7 @@ export async function isRemembered(approvals, request, keys, options) {
|
|
|
40
43
|
async function mayOfferAlways({ principalId, keys, approvals, options }) {
|
|
41
44
|
if (keys.alwaysKey === undefined || approvals === undefined)
|
|
42
45
|
return false;
|
|
43
|
-
return approvals.mayAlwaysAllow({ principalId }, scopeOption(options.scope));
|
|
46
|
+
return approvals.mayAlwaysAllow({ principalId }, scopeOption({ scope: options.scope }));
|
|
44
47
|
}
|
|
45
48
|
/** The remember buttons this call's card may offer. A destructive or write-shaped call offers
|
|
46
49
|
* none, and the host's always permission is then not even consulted. */
|
|
@@ -65,7 +68,7 @@ async function persistGrant({ context, keys, approvals, choice, options }, grant
|
|
|
65
68
|
if (choice === "always" && keys.alwaysKey && approvals.always) {
|
|
66
69
|
await approvals.always.upsert({
|
|
67
70
|
...keys.alwaysKey, fingerprint: keys.fingerprint, grantedByPrincipalId: context.principal.id, grantedAt,
|
|
68
|
-
}, scopeOption(options.scope));
|
|
71
|
+
}, scopeOption({ scope: options.scope }));
|
|
69
72
|
return true;
|
|
70
73
|
}
|
|
71
74
|
return false;
|
|
@@ -89,7 +92,7 @@ export async function rememberApproval(input) {
|
|
|
89
92
|
}
|
|
90
93
|
try {
|
|
91
94
|
await options.webhooks?.approvalRemembered({ principalId: context.principal.id,
|
|
92
|
-
connectionId: request.connectionId, toolName: request.remoteName, fingerprint: keys.fingerprint, scope: choice, grantedAt }, scopeOption(options.scope));
|
|
95
|
+
connectionId: request.connectionId, toolName: request.remoteName, fingerprint: keys.fingerprint, scope: choice, grantedAt }, scopeOption({ scope: options.scope }));
|
|
93
96
|
}
|
|
94
97
|
catch (error) {
|
|
95
98
|
report(options, { toolId: request.toolId, choice, stage: "webhook", error });
|
|
@@ -5,5 +5,7 @@ import type { ExternalMcpRevocationReason } from "./revocation.js";
|
|
|
5
5
|
* for a write tool with no write grant; it maps to "write-not-allowed" rather than collapsing into
|
|
6
6
|
* "tool-not-allowed", so the model is told the tool may not make changes.
|
|
7
7
|
* @complexity O(1). */
|
|
8
|
-
export declare function revocationReasonForToolRefusal(refusal
|
|
8
|
+
export declare function revocationReasonForToolRefusal({ refusal }: {
|
|
9
|
+
refusal: ToolRefusalReason | null;
|
|
10
|
+
}, _optional?: Record<string, never>): ExternalMcpRevocationReason | null;
|
|
9
11
|
//# sourceMappingURL=revocation-reason.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* for a write tool with no write grant; it maps to "write-not-allowed" rather than collapsing into
|
|
4
4
|
* "tool-not-allowed", so the model is told the tool may not make changes.
|
|
5
5
|
* @complexity O(1). */
|
|
6
|
-
export function revocationReasonForToolRefusal(refusal) {
|
|
6
|
+
export function revocationReasonForToolRefusal({ refusal }, _optional = {}) {
|
|
7
7
|
if (refusal === null)
|
|
8
8
|
return null;
|
|
9
9
|
return refusal === "remote-declares-not-read-only" ? "write-not-allowed" : "tool-not-allowed";
|
|
@@ -13,7 +13,7 @@ export function rosterRefusalFor({ record, call }) {
|
|
|
13
13
|
return "turned-off";
|
|
14
14
|
if (record.disconnected)
|
|
15
15
|
return "disconnected";
|
|
16
|
-
return revocationReasonForToolRefusal(refusalForAdmittedToolUnderCurrentGrants({ tool: call, grants: record.grants }));
|
|
16
|
+
return revocationReasonForToolRefusal({ refusal: refusalForAdmittedToolUnderCurrentGrants({ tool: call, grants: record.grants }) });
|
|
17
17
|
}
|
|
18
18
|
/** One roster read plus its refusal. A failed read or check is reported and fails closed as
|
|
19
19
|
* `"unverifiable"`, so the driver error never reaches the refusal. @complexity O(1). */
|
|
@@ -21,7 +21,7 @@ async function readRosterRefusal({ roster, connectionId, call }, { scope, report
|
|
|
21
21
|
// A row that was read but cannot be judged keeps its label on the refusal.
|
|
22
22
|
let record = null;
|
|
23
23
|
try {
|
|
24
|
-
record = await roster.findByServerId({ serverId: connectionId }, scopeOption(scope));
|
|
24
|
+
record = await roster.findByServerId({ serverId: connectionId }, scopeOption({ scope }));
|
|
25
25
|
return { record, reason: rosterRefusalFor({ record, call }) };
|
|
26
26
|
}
|
|
27
27
|
catch (error) {
|
|
@@ -47,7 +47,7 @@ export function createFederatedConnectionRevocationGate(required, optional = {})
|
|
|
47
47
|
return "current-grants-checked";
|
|
48
48
|
const refusal = { serverId: connectionId, label: record?.label ?? null, remoteName: call.remoteName, reason };
|
|
49
49
|
try {
|
|
50
|
-
await optional.webhooks?.connectionRefused(refusal, scopeOption(optional.scope));
|
|
50
|
+
await optional.webhooks?.connectionRefused(refusal, scopeOption({ scope: optional.scope }));
|
|
51
51
|
}
|
|
52
52
|
catch (error) {
|
|
53
53
|
report({ connectionId, stage: "webhook", error });
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** The opaque host storage partition as a port's options object: `{}` when absent, so a port
|
|
2
2
|
* never receives `{ scope: undefined }`. @complexity O(1). */
|
|
3
|
-
export declare function scopeOption(scope
|
|
3
|
+
export declare function scopeOption({ scope }: {
|
|
4
|
+
scope: string | undefined;
|
|
5
|
+
}, _optional?: Record<string, never>): {
|
|
4
6
|
scope?: string;
|
|
5
7
|
};
|
|
6
8
|
//# sourceMappingURL=scope-option.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The opaque host storage partition as a port's options object: `{}` when absent, so a port
|
|
2
2
|
* never receives `{ scope: undefined }`. @complexity O(1). */
|
|
3
|
-
export function scopeOption(scope) {
|
|
3
|
+
export function scopeOption({ scope }, _optional = {}) {
|
|
4
4
|
return scope === undefined ? {} : { scope };
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=scope-option.js.map
|
|
@@ -82,7 +82,7 @@ export interface AttachFederatedMcpToolsParams {
|
|
|
82
82
|
connections?: readonly ResolvedFederatedConnection[] | undefined;
|
|
83
83
|
/**
|
|
84
84
|
* Connections from a config source that is not the preset registry — today, the operator-editable
|
|
85
|
-
* roster in
|
|
85
|
+
* roster in a host module.
|
|
86
86
|
*
|
|
87
87
|
* A second parameter rather than a second preset, because `FederatedMcpPresetResolver` cannot
|
|
88
88
|
* express this source: it is synchronous (a DB read plus an unseal are not) and returns at most
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
1
|
import { redactSecrets } from '@jini-ai/core';
|
|
3
2
|
import { createConsoleLogger } from "@jini-ai/core/primitives";
|
|
4
3
|
import { defaultFederatedMcpPresetRegistry } from "./presets.js";
|
|
@@ -9,11 +8,11 @@ import { registerFrozenFederationConnection } from './frozen-grants.js';
|
|
|
9
8
|
* `agent-daemon-server.ts` calls, and the only place in this subtree that performs I/O it was not
|
|
10
9
|
* handed.
|
|
11
10
|
*
|
|
12
|
-
* Split out of `agent-daemon-server.ts` for the reason `tool-catalog-query.ts` and
|
|
11
|
+
* Split out of `agent-daemon-server.ts` for the reason `tool-catalog-query.ts` and a host module
|
|
13
12
|
* were: that file is a top-level side-effecting script which opens a real port and a real DB
|
|
14
13
|
* connection on import, so nothing in it can be imported by a test. Everything here can be.
|
|
15
14
|
*
|
|
16
|
-
* FAIL-OPEN, and deliberately the opposite of
|
|
15
|
+
* FAIL-OPEN, and deliberately the opposite of a host module's fail-closed gate. The two are
|
|
17
16
|
* answering different questions. `requireAgentDaemonToken` guards ACCESS TO host app, where failing
|
|
18
17
|
* open would admit unauthenticated callers, so an unconfigured gate must refuse to serve. This
|
|
19
18
|
* guards an OPTIONAL OUTBOUND CONVENIENCE, where failing closed would mean a third party's server
|
|
@@ -177,7 +176,7 @@ async function attachOneFederatedConnection(params) {
|
|
|
177
176
|
return { registeredToolIds, session, report };
|
|
178
177
|
}
|
|
179
178
|
catch (error) {
|
|
180
|
-
logger.warn({ message: `mcp-federation: '${connectionId}' failed, continuing without its tools
|
|
179
|
+
logger.warn({ message: `mcp-federation: '${connectionId}' failed, continuing without its tools` }, { error });
|
|
181
180
|
// A session that connected but failed during listing/admission still owns a child process.
|
|
182
181
|
await session?.close({}).catch(() => undefined);
|
|
183
182
|
return { registeredToolIds: [], session: null, report: null, connectFailureReason: redactSecrets({ input: messageOf(error) }, { redactPii: false }) };
|
|
@@ -203,7 +202,7 @@ export function resolveFederatedMcpPresets({ env, logger, registry }, _optional
|
|
|
203
202
|
connections.push(connection);
|
|
204
203
|
}
|
|
205
204
|
catch (error) {
|
|
206
|
-
logger.warn({ message: `mcp-federation: preset '${preset.presetId}' configuration is invalid, continuing without federated tools
|
|
205
|
+
logger.warn({ message: `mcp-federation: preset '${preset.presetId}' configuration is invalid, continuing without federated tools` }, { error });
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
208
|
return connections;
|
|
@@ -7,7 +7,7 @@ import type { FederatedMcpConnectionConfig, McpLaunchSpec } from "./ports.js";
|
|
|
7
7
|
* What this file deliberately does NOT contain, as of 2026-07-30: any specific vendor's preset. The
|
|
8
8
|
* Supabase preset this capability was designed and verified against used to live here; it moved to
|
|
9
9
|
* `src/features/plugins/supabase-mcp/` on 2026-07-30 and was retired on 2026-09-29 (Supabase is now
|
|
10
|
-
* the `content/agent-plugins/supabase` Agent Plugin). The reasoning is the same one that keeps `store
|
|
10
|
+
* the `content/agent-plugins/supabase` Agent Plugin). The reasoning is the same one that keeps `store plugin` and `deployment plugin` out
|
|
11
11
|
* of `src/server` proper: a concrete vendor integration that ships by default is still an OPTIONAL
|
|
12
12
|
* module, and a reader who finds it inside `src/assistant/` reasonably concludes the assistant
|
|
13
13
|
* REQUIRES it. Nothing in `mcp-federation/` should be readable as "host app's assistant needs Supabase".
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ISODateTime } from "@jini-ai/core/primitives";
|
|
2
|
-
import type { ExternalMcpAccessSnapshot } from "@jini-ai/core/contracts/hosted-mcp";
|
|
2
|
+
import type { ExternalMcpAccessSnapshot, ExternalMcpServerRecord, SaveExternalMcpServerInput } from "@jini-ai/core/contracts/hosted-mcp";
|
|
3
3
|
/** Only source identity is hashed; credentials are represented by their existing ciphertext. */
|
|
4
4
|
interface ExternalMcpAdmissionSource {
|
|
5
5
|
readonly createdAt: ISODateTime;
|
|
@@ -88,5 +88,57 @@ export declare function validateExternalMcpToolNames({ names, field }: {
|
|
|
88
88
|
names: readonly string[];
|
|
89
89
|
field: string;
|
|
90
90
|
}, _options?: {}): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Splits an operator's comma-separated allowlist of remote tool names.
|
|
93
|
+
*
|
|
94
|
+
* @throws {ExternalMcpValidationError} See {@link parseToolNameList}. `field` is `"allowedToolNames"`.
|
|
95
|
+
* @complexity O(n) in the number of names.
|
|
96
|
+
* @overallScore 100
|
|
97
|
+
*/
|
|
98
|
+
export declare function parseAllowedToolNames({ raw }: {
|
|
99
|
+
raw: string;
|
|
100
|
+
}, _optional?: Record<string, never>): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Splits an operator's comma-separated list of remote tool names separately authorized to write —
|
|
103
|
+
* `trust.ts` R3's override, checked only after {@link parseAllowedToolNames}'s allowlist passes (see
|
|
104
|
+
* {@link assertWriteAllowlistSubset}).
|
|
105
|
+
*
|
|
106
|
+
* @throws {ExternalMcpValidationError} See {@link parseToolNameList}. `field` is
|
|
107
|
+
* `"writeAllowedToolNames"`.
|
|
108
|
+
* @complexity O(n) in the number of names.
|
|
109
|
+
* @overallScore 100
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseWriteAllowedToolNames({ raw }: {
|
|
112
|
+
raw: string;
|
|
113
|
+
}, _optional?: Record<string, never>): string[];
|
|
114
|
+
/**
|
|
115
|
+
* A tool may be write-authorized only if it is ALSO allowlisted. Enforced at save time so an
|
|
116
|
+
* operator learns of the mistake immediately rather than the entry sitting inert (or, worse, being
|
|
117
|
+
* misread as intentional) until a boot-time report surfaces it.
|
|
118
|
+
*
|
|
119
|
+
* @throws {ExternalMcpValidationError} Naming the first write-authorized tool absent from the
|
|
120
|
+
* allowlist, with `field === "writeAllowedToolNames"`.
|
|
121
|
+
* @complexity O(n) in the number of write-authorized names.
|
|
122
|
+
*/
|
|
123
|
+
export declare function assertWriteAllowlistSubset(writeAllowedToolNames: readonly string[], allowedToolNames: readonly string[]): void;
|
|
124
|
+
/**
|
|
125
|
+
* Resolves the two write-grant attribution columns for one save.
|
|
126
|
+
*
|
|
127
|
+
* Written ONLY when {@link writeAllowedToolNames}'s contents actually change — compared as a set
|
|
128
|
+
* against whatever the row already has — so a save that merely renames a connection or flips
|
|
129
|
+
* `enabled` does not stamp a new "authorized by / on" over an untouched grant. `input.principalId`
|
|
130
|
+
* is read only on the changed branch, which is what lets it stay a required TYPE without becoming a
|
|
131
|
+
* runtime hazard: a caller written before this field existed can only reach `undefined` here if it
|
|
132
|
+
* also never sets a non-empty {@link SaveExternalMcpServerInput.writeAllowedToolNames}, in which case
|
|
133
|
+
* the list never changes and this branch never runs.
|
|
134
|
+
*
|
|
135
|
+
* @complexity O(n) in the length of the longer list (via {@link toolNameSetsEqual}).
|
|
136
|
+
*/
|
|
137
|
+
export declare function resolveWriteGrantAttribution({ input, writeAllowedToolNames, existing, nowIso }: {
|
|
138
|
+
input: Pick<SaveExternalMcpServerInput, "principalId">;
|
|
139
|
+
writeAllowedToolNames: readonly string[];
|
|
140
|
+
existing: ExternalMcpServerRecord | null;
|
|
141
|
+
nowIso: ISODateTime;
|
|
142
|
+
}, _optional?: {}): Pick<ExternalMcpServerRecord, "writeGrantsUpdatedByPrincipalId" | "writeGrantsUpdatedAt">;
|
|
91
143
|
export {};
|
|
92
144
|
//# sourceMappingURL=access.d.ts.map
|