@jini-ai/mcp 0.7.3-next.1 → 0.7.3-next.3

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +15 -0
  3. package/dist/agent-install/owned-json-install.d.ts +1 -1
  4. package/dist/client/client.js +1 -1
  5. package/dist/client/css-url-refs.d.ts +3 -1
  6. package/dist/client/css-url-refs.js +1 -1
  7. package/dist/external/access-review.d.ts +46 -0
  8. package/dist/external/access-review.js +175 -0
  9. package/dist/external/agent-tools.d.ts +72 -0
  10. package/dist/external/agent-tools.js +218 -0
  11. package/dist/external/built-in-connections.d.ts +17 -0
  12. package/dist/external/built-in-connections.js +15 -0
  13. package/dist/external/external-mcp-host-copy.d.ts +14 -0
  14. package/dist/external/external-mcp-host-copy.js +8 -0
  15. package/dist/external/operations-tools.d.ts +69 -0
  16. package/dist/external/operations-tools.js +96 -0
  17. package/dist/external/save-form.d.ts +105 -0
  18. package/dist/external/save-form.js +260 -0
  19. package/dist/external/save-input.d.ts +41 -0
  20. package/dist/external/save-input.js +149 -0
  21. package/dist/external/tool-registrations.d.ts +130 -0
  22. package/dist/external/tool-registrations.js +299 -0
  23. package/dist/federation/bootstrap.d.ts +18 -0
  24. package/dist/federation/bootstrap.js +2 -2
  25. package/dist/federation/external-mcp-admissions.d.ts +19 -0
  26. package/dist/federation/external-mcp-admissions.js +30 -0
  27. package/dist/federation/external-mcp-probe.d.ts +86 -0
  28. package/dist/federation/external-mcp-probe.js +75 -0
  29. package/dist/federation/hosted/external-mcp-repo.d.ts +108 -0
  30. package/dist/federation/hosted/external-mcp-repo.js +210 -0
  31. package/dist/federation/hosted/external-mcp-repo.writes.d.ts +75 -0
  32. package/dist/federation/hosted/external-mcp-repo.writes.js +131 -0
  33. package/dist/federation/hosted/store-credentials.d.ts +6 -1
  34. package/dist/federation/hosted/store-credentials.js +2 -2
  35. package/dist/federation/hosted/store-input.d.ts +11 -3
  36. package/dist/federation/hosted/store-input.js +5 -5
  37. package/dist/federation/hosted/store-oauth-fields.d.ts +10 -2
  38. package/dist/federation/hosted/store-oauth-fields.js +7 -7
  39. package/dist/federation/hosted/store-view.d.ts +6 -1
  40. package/dist/federation/hosted/store-view.js +2 -2
  41. package/dist/federation/hosted/store.js +7 -7
  42. package/dist/federation/hosted/store.memory.d.ts +2 -0
  43. package/dist/federation/hosted/store.memory.js +6 -2
  44. package/dist/federation/index.d.ts +2 -0
  45. package/dist/federation/index.js +2 -0
  46. package/dist/federation/registrations.js +73 -56
  47. package/dist/federation/roster-change.d.ts +63 -0
  48. package/dist/federation/roster-change.js +68 -0
  49. package/dist/federation/runtime.d.ts +140 -0
  50. package/dist/federation/runtime.js +118 -0
  51. package/dist/react/external-mcp/ExternalMcpAdmissionsBanner.d.ts +42 -0
  52. package/dist/react/external-mcp/ExternalMcpAdmissionsBanner.js +80 -0
  53. package/dist/react/external-mcp/ExternalMcpPanelSections.d.ts +50 -0
  54. package/dist/react/external-mcp/ExternalMcpPanelSections.js +35 -0
  55. package/dist/react/external-mcp/ExternalMcpSettingsPanel.d.ts +446 -0
  56. package/dist/react/external-mcp/ExternalMcpSettingsPanel.hooks.d.ts +135 -0
  57. package/dist/react/external-mcp/ExternalMcpSettingsPanel.hooks.js +122 -0
  58. package/dist/react/external-mcp/ExternalMcpSettingsPanel.js +63 -0
  59. package/dist/react/external-mcp/ExternalMcpSourceRow.d.ts +40 -0
  60. package/dist/react/external-mcp/ExternalMcpSourceRow.js +100 -0
  61. package/dist/react/external-mcp/hooks/external-mcp-form.rules.d.ts +58 -0
  62. package/dist/react/external-mcp/hooks/external-mcp-form.rules.js +209 -0
  63. package/dist/react/external-mcp/hooks/external-mcp-source-actions.d.ts +115 -0
  64. package/dist/react/external-mcp/hooks/external-mcp-source-actions.js +152 -0
  65. package/dist/react/external-mcp/hooks/use-external-mcp-admissions.hooks.d.ts +166 -0
  66. package/dist/react/external-mcp/hooks/use-external-mcp-admissions.hooks.js +209 -0
  67. package/dist/react/external-mcp/hooks/use-external-mcp.hooks.d.ts +132 -0
  68. package/dist/react/external-mcp/hooks/use-external-mcp.hooks.js +37 -0
  69. package/dist/server/tool-arguments.d.ts +5 -1
  70. package/dist/server/tool-arguments.js +13 -9
  71. package/dist/server/tool-protocol.js +7 -5
  72. package/dist/server/tools/tool-catalog-tools.js +6 -3
  73. package/dist/tools/ask-choice/custom-answer.d.ts +77 -0
  74. package/dist/tools/ask-choice/custom-answer.js +113 -0
  75. package/dist/tools/ask-choice/index.d.ts +2 -0
  76. package/dist/tools/ask-choice/index.js +1 -0
  77. package/package.json +122 -7
@@ -0,0 +1,149 @@
1
+ import { requireString, ToolInputError } from '@jini-ai/core';
2
+ /** Reads `input[key]` as a string, or `undefined` for anything else — the same tri-state reading
3
+ * rule every other optional field in this domain's save path already follows (see `save-form.ts`'s
4
+ * header). @complexity O(1). */
5
+ export function optionalStringField({ input, key }, _optional = {}) {
6
+ return typeof input[key] === "string" ? input[key] : undefined;
7
+ }
8
+ /** Reads `input[key]` as a string, treating a blank (empty-after-trim) value the same as absent:
9
+ * `undefined`. For the handful of fields this form never prefills back with the stored secret —
10
+ * `env` (`save-form.ts:164`) and the OAuth client secret (`save-form.ts:212`) — the field hint tells
11
+ * the human "leave blank to keep the stored value", so a blank submission must carry forward what is
12
+ * already saved, not `optionalStringField`'s ordinary `""`. The store's own PUT contract still lets
13
+ * `""` mean "clear" ({@link resolveExternalMcpSealedEnv}, `resolveSealedOAuthBlob` in
14
+ * `external-mcp-store.ts`) for callers that DO round-trip the current value — that contract is
15
+ * unchanged; only this form's blank-means-absent mapping is fixed here.
16
+ * @complexity O(1). */
17
+ function optionalSecretField({ input, key }, _optional = {}) {
18
+ const value = optionalStringField({ input, key });
19
+ return value === undefined || value === "" ? undefined : value;
20
+ }
21
+ /** The model's own {@link ExternalMcpSaveInput} fields beyond `id`/`transport` — every one of
22
+ * `SAVE_INPUT_SCHEMA`'s optional string properties (`agent-tools.ts`), read the same tri-state way
23
+ * the submitted form's own params are read below. */
24
+ const SAVE_MODEL_OPTIONAL_FIELDS = [
25
+ "label",
26
+ "command",
27
+ "args",
28
+ "url",
29
+ "allowedToolNames",
30
+ "writeAllowedToolNames",
31
+ "authMode",
32
+ "accessTokenEnvName",
33
+ "oauthProviderId",
34
+ "oauthGrant",
35
+ "oauthClientId",
36
+ "oauthScopes",
37
+ "oauthTokenEnvName",
38
+ "oauthAuthorizationEndpoint",
39
+ "oauthTokenEndpoint",
40
+ "oauthDeviceAuthorizationEndpoint",
41
+ ];
42
+ /** Narrows the model's OWN `external_mcp_save` call input into {@link ExternalMcpSaveInput} — the
43
+ * shape `mergeExternalMcpSavePrefill`/`buildExternalMcpSaveForm` take to generate the form the
44
+ * human actually sees. `id` is normalized the same way `saveExternalMcpServer` itself normalizes
45
+ * it (trim + lowercase), so the existing-row lookup below matches what a prior save actually
46
+ * stored. @complexity O(1) — a fixed field list. */
47
+ export function buildModelSaveInput(input, { assertCredentialFreeField }) {
48
+ if (Object.keys(input).some(key => key !== "id" && key !== "transport" && key !== "enabled" && !SAVE_MODEL_OPTIONAL_FIELDS.some(field => field === key))) {
49
+ throw new ToolInputError({ message: "external_mcp_save: credentials belong in the human form, never in this tool input. Nothing was saved." });
50
+ }
51
+ const id = requireString({ input, key: "id" }).trim().toLowerCase();
52
+ const transport = requireString({ input, key: "transport" });
53
+ if (input.enabled !== undefined && typeof input.enabled !== 'boolean')
54
+ throw new ToolInputError({ message: "'enabled' must be true or false. Nothing was saved." });
55
+ let save = { id, transport, ...(input.enabled === undefined ? {} : { enabled: input.enabled }) };
56
+ for (const key of SAVE_MODEL_OPTIONAL_FIELDS) {
57
+ const value = optionalStringField({ input, key });
58
+ if (value !== undefined) {
59
+ assertCredentialFreeField({ value, field: key });
60
+ save = { ...save, [key]: value };
61
+ }
62
+ }
63
+ return save;
64
+ }
65
+ /** The submitted form field name -> {@link SaveExternalMcpOAuthInput} field name pairs —
66
+ * `save-form.ts`'s `buildOAuthCoreFields`/`buildOAuthTokenEnvField`/`buildOAuthEndpointFields` own
67
+ * the field NAMES on the rendered side; this is the one place that maps them back. */
68
+ const OAUTH_FORM_FIELD_MAP = [
69
+ ["oauthProviderId", "providerId"],
70
+ ["oauthGrant", "grant"],
71
+ ["oauthClientId", "clientId"],
72
+ ["oauthClientSecret", "clientSecret"],
73
+ ["oauthScopes", "scopes"],
74
+ ["oauthTokenEnvName", "tokenEnvName"],
75
+ ["oauthAuthorizationEndpoint", "authorizationEndpoint"],
76
+ ["oauthTokenEndpoint", "tokenEndpoint"],
77
+ ["oauthDeviceAuthorizationEndpoint", "deviceAuthorizationEndpoint"],
78
+ ];
79
+ /** Builds the OAuth half of a save from the submitted form's params — only rendered fields are ever
80
+ * present (see this file's header), so an absent key here means the form never showed that field,
81
+ * not that the human left it blank. `undefined` when nothing OAuth-shaped was submitted.
82
+ * @complexity O(1) — a fixed field list. */
83
+ function buildOAuthSaveInputFromFormParams(params) {
84
+ let oauth = {};
85
+ for (const [formKey, oauthKey] of OAUTH_FORM_FIELD_MAP) {
86
+ // `oauthClientSecret` is the one OAuth field this form never prefills back with the stored value
87
+ // (`save-form.ts:212`'s hint: "Leave blank to keep the stored secret") — every other OAuth field
88
+ // IS prefilled from the existing row, so a blank one there is a genuine, intentional clear.
89
+ const value = formKey === "oauthClientSecret" ? optionalSecretField({ input: params, key: formKey }) : optionalStringField({ input: params, key: formKey });
90
+ if (value !== undefined)
91
+ oauth = { ...oauth, [oauthKey]: value };
92
+ }
93
+ return Object.keys(oauth).length === 0 ? undefined : oauth;
94
+ }
95
+ /**
96
+ * Maps the human's SUBMITTED form (`answer.params`, already past the `received`/dismissed checks)
97
+ * onto {@link SaveExternalMcpServerInput} — `saveExternalMcpServer`'s own input shape.
98
+ *
99
+ * `enabled: true` always: `save-form.ts`'s rendered fields never include an enabled toggle (this
100
+ * tool's job is "connect a server", not "flip one that already exists off/on"), so every save this
101
+ * tool ever performs both creates and enables, or re-enables, the row — matching the admin PUT
102
+ * route's own default (`enabled: body.enabled !== false`) for the identical "caller sent nothing"
103
+ * case. `writeAllowedToolNames` is read from the submitted form the same tri-state way
104
+ * `allowedToolNames` is (`optionalStringField(params, ...) ?? ""`) — see `save-form.ts`'s
105
+ * `writeAllowedToolNames` field/`mergeExternalMcpSavePrefill` for the field this reads and its
106
+ * prefill-from-existing-row behavior. 2026-09-08 fix: this used to hardcode `""` unconditionally,
107
+ * silently dropping every write grant on any save performed through the assistant — this domain's
108
+ * form now has the field `SaveExternalMcpServerInput`'s own doc always assumed an un-migrated caller
109
+ * would eventually grow (ADS-memory/reports/2026-09-08-dock-recovery-product-test.md).
110
+ *
111
+ * @complexity O(1) — a fixed field list.
112
+ */
113
+ export function buildSaveExternalMcpServerInputFromFormParams({ params, workspaceId, principalId }, _optional = {}) {
114
+ const optionalFields = Object.fromEntries(["label", "url", "authMode", "accessTokenEnvName"]
115
+ .map(key => [key, optionalStringField({ input: params, key })])
116
+ .filter(([, value]) => value !== undefined));
117
+ const serverIdRaw = params.id;
118
+ const transportRaw = params.transport;
119
+ if (typeof serverIdRaw !== "string" || typeof transportRaw !== "string") {
120
+ // Both come from prepared state, formerly `baseParams` on every render — their absence means
121
+ // the domain save port was called without this tool's bound destination.
122
+ throw new Error("external_mcp_save: the submitted form is missing 'id' or 'transport'.");
123
+ }
124
+ return {
125
+ workspaceId,
126
+ serverId: serverIdRaw,
127
+ transport: transportRaw,
128
+ ...optionalFields,
129
+ enabled: params.enabled,
130
+ command: optionalStringField({ input: params, key: "command" }) ?? "",
131
+ args: optionalStringField({ input: params, key: "args" }) ?? "",
132
+ allowedToolNames: optionalStringField({ input: params, key: "allowedToolNames" }) ?? "",
133
+ writeAllowedToolNames: optionalStringField({ input: params, key: "writeAllowedToolNames" }) ?? "",
134
+ ...readOptionalSecretInputs({ params }),
135
+ principalId,
136
+ };
137
+ }
138
+ /** The save form's optional secret-bearing fields; each is omitted, never defaulted, when absent. */
139
+ function readOptionalSecretInputs({ params }, _optional = {}) {
140
+ const env = optionalSecretField({ input: params, key: "env" });
141
+ const accessToken = optionalSecretField({ input: params, key: "accessToken" });
142
+ const oauth = buildOAuthSaveInputFromFormParams(params);
143
+ return {
144
+ ...(env !== undefined ? { env } : {}),
145
+ ...(accessToken !== undefined ? { accessToken } : {}),
146
+ ...(oauth !== undefined ? { oauth } : {}),
147
+ };
148
+ }
149
+ //# sourceMappingURL=save-input.js.map
@@ -0,0 +1,130 @@
1
+ import { type AgentToolDefinition, type AgentToolSideEffect, type ToolHandler, type ToolRegistration, type ToolContributor, type ToolExecutionContext, type ToolExecutionOptions, type HumanConfirmer } from '@jini-ai/core';
2
+ import type { requireToolPermission } from '@jini-ai/core';
3
+ import { resolveOperatorLocale } from '@jini-ai/core/operator-locale';
4
+ import type { ExternalMcpToolDeps as BaseExternalMcpToolDeps } from '@jini-ai/core/contracts/site/external-mcp-tool-ports';
5
+ import type { ChatDeleteSurfaceDeps } from '@jini-ai/core/contracts/site/daemon-surface-exchanges';
6
+ import type { HumanConfirmSpec } from '@jini-ai/core/contracts/site/human-confirm';
7
+ import type { SurfaceCardsPort, SurfaceCardSecretDeps, SurfaceCardSecretOptions } from '@jini-ai/core/contracts/cards';
8
+ import type { ToolFailureDiagnostic } from '@jini-ai/core/contracts/site/daemon-tool-recovery';
9
+ import type { ExternalMcpStoreDeps, ExternalMcpServerView, SaveExternalMcpServerInput } from '@jini-ai/core/contracts/hosted-mcp';
10
+ import type { externalMcpAccessSnapshot, ExternalMcpValidationError, applyExternalMcpAccess, parseArgs, parseAllowedToolNames, parseWriteAllowedToolNames, readExternalMcpToolGrants } from '../federation/hosted/index.js';
11
+ import type { HostedMcpTokenHint } from '../federation/hosted/store-ports.js';
12
+ export interface ExternalMcpToolDeps extends BaseExternalMcpToolDeps {
13
+ externalMcpAccessSnapshot: typeof externalMcpAccessSnapshot;
14
+ ExternalMcpValidationError: typeof ExternalMcpValidationError;
15
+ applyExternalMcpAccess: typeof applyExternalMcpAccess;
16
+ parseArgs: typeof parseArgs;
17
+ parseAllowedToolNames: typeof parseAllowedToolNames;
18
+ parseWriteAllowedToolNames: typeof parseWriteAllowedToolNames;
19
+ readExternalMcpToolGrants: typeof readExternalMcpToolGrants;
20
+ unverifiedAccessMessage(required: {
21
+ serverId: string;
22
+ }): string;
23
+ unverifiedConnectionMessage: string;
24
+ staleApprovalMessage: string;
25
+ oauthUnavailableMessage(required: {
26
+ serverId: string;
27
+ }): string;
28
+ accessErrorCode: string;
29
+ catalog: readonly AgentToolDefinition[];
30
+ requireToolPermission: typeof requireToolPermission;
31
+ resolveOperatorLocale: typeof resolveOperatorLocale;
32
+ assertCredentialFreeField(required: {
33
+ value: string;
34
+ field: string;
35
+ }): void;
36
+ ForbiddenError: abstract new (...args: never[]) => Error;
37
+ defineSecretCardTool: SurfaceCardsPort['defineSecretCardTool'];
38
+ askThenReport: SurfaceCardSecretDeps['askThenReport'];
39
+ appName: string;
40
+ secretCardOptions: SurfaceCardSecretOptions;
41
+ resolveExternalMcpOAuthRedirectUri(required: {
42
+ serverId: string;
43
+ derivedPublicOrigin: string | undefined;
44
+ }, optional?: Record<string, never>): string | undefined;
45
+ saveExternalMcpServer(deps: ExternalMcpStoreDeps, input: SaveExternalMcpServerInput): Promise<ExternalMcpServerView<HostedMcpTokenHint>>;
46
+ listExternalMcpServerViews: (required: {
47
+ deps: Pick<ExternalMcpStoreDeps, 'repo' | 'sealer'>;
48
+ workspaceId: string;
49
+ }) => Promise<ExternalMcpServerView<HostedMcpTokenHint>[]>;
50
+ readEnabledExternalMcpConfigs: (required: {
51
+ deps: Pick<ExternalMcpStoreDeps, 'repo' | 'sealer'> & {
52
+ oauth: NonNullable<BaseExternalMcpToolDeps['externalMcpOAuth']>['tokenResolver'] | undefined;
53
+ };
54
+ workspaceId: string;
55
+ }) => Promise<{
56
+ configs: {
57
+ serverId: string;
58
+ }[];
59
+ failures: {
60
+ serverId: string;
61
+ reason: string;
62
+ }[];
63
+ }>;
64
+ notifyExternalMcpRosterChanged(optional?: {
65
+ lowered: {
66
+ serverIds: string[];
67
+ };
68
+ }): Promise<void>;
69
+ credentialText(required: {
70
+ id: 'saved' | 'connected' | 'auth' | 'timeout' | 'unreachable' | 'blank' | 'savedTitle' | 'storage';
71
+ locale: string;
72
+ }): string;
73
+ formatCredentialHint(required: {
74
+ hint: HostedMcpTokenHint | null;
75
+ locale: string;
76
+ }): string;
77
+ formatCredentialHints(required: {
78
+ hints: Record<string, HostedMcpTokenHint> | undefined;
79
+ locale: string;
80
+ }): string;
81
+ translateCredentialMessage(required: {
82
+ message: string;
83
+ locale: string;
84
+ }): string;
85
+ issueCredentialSetup(required: {
86
+ setupToolId: string;
87
+ prefill: Readonly<Record<string, string | number | boolean | null>>;
88
+ }, optional: Record<string, never>): ToolFailureDiagnostic;
89
+ approvalToolHandler: <TPrepared>(steps: {
90
+ surfaces: ChatDeleteSurfaceDeps;
91
+ prepare(input: {
92
+ ctx: ToolExecutionContext;
93
+ }, optional: ToolExecutionOptions): Promise<TPrepared>;
94
+ describe(input: {
95
+ ctx: ToolExecutionContext;
96
+ prepared: TPrepared;
97
+ }): HumanConfirmSpec | Promise<HumanConfirmSpec>;
98
+ run(input: {
99
+ ctx: ToolExecutionContext;
100
+ prepared: TPrepared;
101
+ confirmer: HumanConfirmer;
102
+ choice?: string;
103
+ }, optional: ToolExecutionOptions): Promise<unknown>;
104
+ }, optional: {
105
+ flag: string;
106
+ }) => ToolHandler;
107
+ }
108
+ /**
109
+ * This wiring layer's OWN risk classification, authored from what each handler below actually
110
+ * calls. See `DerivedRiskByToolId` in the kit for why it is independent of the catalog's own
111
+ * `sideEffects` declaration.
112
+ */
113
+ export declare const externalMcpDerivedRisk: ReadonlyMap<string, AgentToolSideEffect>;
114
+ export declare function buildExternalMcpRegistrations(routeDeps: ExternalMcpToolDeps, surfaces: ChatDeleteSurfaceDeps): ToolRegistration[];
115
+ /**
116
+ * Contributes External MCP's AI tools to the assistant's catalog — called once by
117
+ * `server/runtime/composition/tool-catalog-manifest.ts`'s `installFirstPartyToolContributors()`, not
118
+ * by importing this module. See this file's header for what was unreachable before this existed.
119
+ */
120
+ export declare function contributeExternalMcpTools({ probe, knownToolNames }?: {
121
+ probe?: ({ deps, serverId }: {
122
+ deps: ExternalMcpToolDeps;
123
+ serverId: string;
124
+ }, optional?: Record<string, never>) => Promise<{
125
+ ok: boolean;
126
+ body: Readonly<Record<string, unknown>>;
127
+ }>;
128
+ knownToolNames?: ExternalMcpToolDeps["externalMcpKnownToolNames"];
129
+ }, _optional?: {}): ToolContributor<ExternalMcpToolDeps, ChatDeleteSurfaceDeps>;
130
+ //# sourceMappingURL=tool-registrations.d.ts.map
@@ -0,0 +1,299 @@
1
+ import { ToolAccessLoweringError } from '@jini-ai/core/tool-access-change';
2
+ import { toolMetadata } from '@jini-ai/core/tool-metadata/external-mcp';
3
+ import { buildDomainRegistrations, indexCatalogById, requireInputRecord, requireNoInput, requireString, ToolInputError } from '@jini-ai/core';
4
+ import { adaptLegacyAuthorize } from '@jini-ai/core';
5
+ import { resolveOperatorLocale } from '@jini-ai/core/operator-locale';
6
+ import { EXTERNAL_MCP_MANAGE_PERMISSION } from './agent-tools.js';
7
+ import { buildExternalMcpSaveForm, mergeExternalMcpSavePrefill, EXTERNAL_MCP_SAVE_TOOL_ID } from './save-form.js';
8
+ import { buildModelSaveInput, buildSaveExternalMcpServerInputFromFormParams } from './save-input.js';
9
+ import { isExternalMcpAccessInput, externalMcpAccessHandler, requireMcpSaveApprover, requireKnownMcpSave, currentMcpSaveRecord, ExternalMcpSaveBasisChangedError } from './access-review.js';
10
+ const EXTERNAL_MCP_ENTITY_TYPE = "external-mcp-server";
11
+ /**
12
+ * `external_mcp_save`'s domain save port — kept separate from the engine's exchange lifecycle so
13
+ * the field mapper, sealed store, probe and roster fan-out retain their own contracts.
14
+ *
15
+ * `ExternalMcpValidationError` is the one rejection a DIFFERENT form submission would fix, so it is
16
+ * turned by the engine's error allowlist into the documented `{ saved: false, reason: 'invalid', ... }` result —
17
+ * matching `agent-tools.ts`'s own description of this tool's return shapes.
18
+ * `ExternalMcpSecretStoreUnconfiguredError` is deliberately NOT folded into that same branch: its own
19
+ * doc states nothing the operator types can fix it, which is the opposite of what `reason: 'invalid'`
20
+ * promises the model — it propagates to the engine's fixed storage-failure outcome instead.
21
+ *
22
+ * @complexity O(1) plus one `saveExternalMcpServer` call.
23
+ */
24
+ async function saveSubmittedExternalMcpConfiguration({ routeDeps, surfaces, expected, principalId, values, save, locale, signal }, _optional = {}) {
25
+ // The field set is fixed per call. A submitted routing value cannot change the credential's
26
+ // destination or switch to an auth/transport mode whose fields the human never reviewed.
27
+ if (values.id !== undefined && values.id !== save.id) {
28
+ throw new routeDeps.ExternalMcpValidationError("The server ID must match the connection form. Nothing was saved.", "id");
29
+ }
30
+ const params = { ...values, id: save.id, transport: save.transport, authMode: save.authMode, enabled: save.enabled ?? true,
31
+ allowedToolNames: save.allowedToolNames ?? "", writeAllowedToolNames: save.writeAllowedToolNames ?? "" };
32
+ const saveInput = buildSaveExternalMcpServerInputFromFormParams({ params, workspaceId: routeDeps.workspaceId, principalId });
33
+ await requireMcpSaveApprover({ routeDeps, surfaces, principalId, id: save.id });
34
+ const current = await currentMcpSaveRecord({ routeDeps, id: save.id, expected });
35
+ requireKnownMcpSave({ routeDeps, record: current, input: saveInput });
36
+ signal.throwIfAborted();
37
+ const server = await routeDeps.saveExternalMcpServer({
38
+ repo: routeDeps.externalMcpServerRepo,
39
+ sealer: routeDeps.siteAssistantSecretSealer,
40
+ keyring: routeDeps.siteAssistantSecretKeyring,
41
+ clock: routeDeps.clock,
42
+ }, saveInput);
43
+ // Same roster-change fan-out `put.ts`/`oauth-callback.ts` fire on their own save/connect success —
44
+ // see `external-mcp-roster-change.ts`'s own header. Fire-and-forget: this chat-surface save
45
+ // already succeeded and is durable regardless of whether any registered runtime reloads cleanly.
46
+ if (server.enabled)
47
+ void routeDeps.notifyExternalMcpRosterChanged();
48
+ else
49
+ await routeDeps.notifyExternalMcpRosterChanged({ lowered: { serverIds: [server.serverId] } });
50
+ const { connection, connectionCode } = await probeSavedExternalMcpConfiguration({
51
+ server, routeDeps, locale,
52
+ });
53
+ const hint = [routeDeps.formatCredentialHint({ hint: server.accessTokenHint ?? null, locale }), routeDeps.formatCredentialHints({ hints: server.envTokenHints, locale })].filter(Boolean).join(' · ');
54
+ const hintPrefix = hint ? `${hint}. ` : '';
55
+ return { saved: true, server, connection: connectionCode, message: `${hintPrefix}${connection}` };
56
+ }
57
+ /** Report reachability after a durable save; probe failure does not undo that save. */
58
+ async function probeSavedExternalMcpConfiguration({ server, routeDeps, locale }, _optional = {}) {
59
+ if (server.transport === "stdio" || !routeDeps.externalMcpProbe) {
60
+ return { connectionCode: "not_tested", connection: routeDeps.credentialText({ id: "saved", locale }) };
61
+ }
62
+ try {
63
+ const result = await routeDeps.externalMcpProbe({ serverId: server.serverId });
64
+ const connectionCode = result.ok ? "connected" : String(result.body.code ?? "MCP_SERVER_UNREACHABLE");
65
+ let id;
66
+ if (result.ok)
67
+ id = "connected";
68
+ else if (connectionCode === "MCP_AUTH_REJECTED")
69
+ id = "auth";
70
+ else if (connectionCode === "MCP_TIMEOUT")
71
+ id = "timeout";
72
+ else
73
+ id = "unreachable";
74
+ return { connectionCode, connection: routeDeps.credentialText({ id, locale }) };
75
+ }
76
+ catch {
77
+ return { connectionCode: "MCP_SERVER_UNREACHABLE", connection: routeDeps.credentialText({ id: "unreachable", locale }) };
78
+ }
79
+ }
80
+ /** Project the engine's classified run without exposing any submitted credential. */
81
+ function externalMcpSaveResult({ run, locale, routeDeps }, { validationField } = {}) {
82
+ if (run.status === "saved")
83
+ return run.saved;
84
+ if (run.status === "cancelled")
85
+ return { saved: false, cancelled: true };
86
+ if (run.status === "blank")
87
+ return { saved: false, cancelled: false, reason: "invalid", message: routeDeps.credentialText({ id: "blank", locale }) };
88
+ if (run.status === "failed")
89
+ return { saved: false, cancelled: false, reason: validationField === undefined ? "error" : "invalid", message: run.safeMessage,
90
+ ...(validationField === undefined ? {} : { field: validationField }) };
91
+ return { saved: false, cancelled: false, reason: run.status, note: run.status === "expired"
92
+ ? "The user did not respond to the connection form before it expired. Nothing was saved."
93
+ : "The connection form was closed because the run ended. Nothing was saved." };
94
+ }
95
+ async function prepareExternalMcpSaveInput({ routeDeps, surfaces, ctx }) {
96
+ const input = requireInputRecord({ input: ctx.input });
97
+ const modelInput = buildModelSaveInput(input, routeDeps);
98
+ await requireMcpSaveApprover({ routeDeps, surfaces, principalId: ctx.principal.id, id: modelInput.id });
99
+ return modelInput;
100
+ }
101
+ /** Bind the domain form/save ports to Jini's one lifecycle owner.
102
+ * @complexity O(s + f) during preparation in server views and fixed form fields, plus store/probe I/O.
103
+ */
104
+ function externalMcpSaveHandler({ routeDeps, surfaces }, _optional = {}) {
105
+ const accessHandler = externalMcpAccessHandler({ routeDeps, surfaces });
106
+ return async (ctx, optional = {}) => {
107
+ if (isExternalMcpAccessInput(requireInputRecord({ input: ctx.input })))
108
+ return accessHandler(ctx, optional);
109
+ // Per-call metadata only: concurrent cards must not share a locale or validation field.
110
+ // The engine owns redaction; this allowlist retains the domain's documented invalid/error shape.
111
+ let validationField;
112
+ let errorLocale = "en";
113
+ const card = routeDeps.defineSecretCardTool({
114
+ toolId: EXTERNAL_MCP_SAVE_TOOL_ID,
115
+ prepare: async ({ ctx }) => {
116
+ const modelInput = await prepareExternalMcpSaveInput({ routeDeps, surfaces, ctx });
117
+ const locale = await routeDeps.resolveOperatorLocale({ deps: routeDeps, workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id });
118
+ errorLocale = locale;
119
+ const record = await routeDeps.externalMcpServerRepo.findByServerId({ workspaceId: routeDeps.workspaceId, serverId: modelInput.id });
120
+ const views = await routeDeps.listExternalMcpServerViews({ deps: { repo: routeDeps.externalMcpServerRepo, sealer: routeDeps.siteAssistantSecretSealer }, workspaceId: routeDeps.workspaceId });
121
+ const existing = views.find(view => view.serverId === modelInput.id);
122
+ const save = mergeExternalMcpSavePrefill({ input: modelInput, existing });
123
+ requireKnownMcpSave({ routeDeps, record, input: buildSaveExternalMcpServerInputFromFormParams({ params: { ...save, enabled: save.enabled ?? true }, workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id }) });
124
+ return { save, expected: record ? routeDeps.externalMcpAccessSnapshot({ record }) : null, isUpdate: existing !== undefined, locale, principalId: ctx.principal.id };
125
+ },
126
+ form: ({ prep }) => buildExternalMcpSaveForm({ save: prep.save, isUpdate: prep.isUpdate, appName: routeDeps.appName }),
127
+ save: ({ values, prep, signal }) => saveSubmittedExternalMcpConfiguration({ routeDeps, surfaces, values, ...prep, signal }),
128
+ result: ({ prep, run }) => externalMcpSaveResult({ run, locale: prep.locale, routeDeps }, { validationField }),
129
+ outcome: ({ prep, run }) => {
130
+ if (run.status === "cancelled" || run.status === "expired" || run.status === "abandoned")
131
+ return undefined;
132
+ const result = externalMcpSaveResult({ run, locale: prep.locale, routeDeps }, { validationField });
133
+ return {
134
+ title: result.saved ? routeDeps.credentialText({ id: result.connection === "connected" ? "connected" : "savedTitle", locale: prep.locale }) : routeDeps.credentialText({ id: "unreachable", locale: prep.locale }),
135
+ state: result.saved ? "success" : "failure",
136
+ message: typeof result.message === "string" ? result.message : routeDeps.credentialText({ id: "unreachable", locale: prep.locale }),
137
+ };
138
+ },
139
+ }, { ...routeDeps.secretCardOptions, safeError: error => externalMcpSaveSafeError({ error, locale: errorLocale, routeDeps, onField: field => { validationField = field; } }), text: { ...routeDeps.secretCardOptions.text, saveFailure: routeDeps.credentialText({ id: "storage", locale: "en" }) } });
140
+ return card.handler({ surfaceExchanges: surfaces.surfaceExchanges, askThenReport: routeDeps.askThenReport })(ctx, optional);
141
+ };
142
+ }
143
+ /** Map a save-port failure to card copy; the engine still redacts the returned text.
144
+ * Three causes stay distinct: changed authority (`ForbiddenError`, which subclasses
145
+ * `ToolInputError` and so must be checked first), a changed approval basis (request a new card) and
146
+ * bad input (fix a field). Bad input keeps its actionable sentence; every such sentence on this path
147
+ * is fixed copy or names a field, never a submitted value. Any other error gets fixed storage copy:
148
+ * an arbitrary `Error.message` can carry internals or the submitted values themselves.
149
+ * @complexity O(m) in the message length; no I/O. */
150
+ function externalMcpSaveSafeError({ error, locale, onField, routeDeps }, _optional = {}) {
151
+ if (error instanceof routeDeps.ForbiddenError)
152
+ return 'Your permission to save this connection changed. Reopen the chat in your signed-in admin session. Nothing was saved.';
153
+ if (error instanceof ExternalMcpSaveBasisChangedError)
154
+ return routeDeps.staleApprovalMessage;
155
+ if (error instanceof ToolAccessLoweringError)
156
+ return error.message;
157
+ // Checked before `ToolInputError` in case the validation class ever becomes its subclass: the field path must stay live.
158
+ if (error instanceof routeDeps.ExternalMcpValidationError) {
159
+ onField(error.field);
160
+ return routeDeps.translateCredentialMessage({ message: error.message, locale });
161
+ }
162
+ if (error instanceof ToolInputError)
163
+ return error.message;
164
+ return routeDeps.credentialText({ id: "storage", locale });
165
+ }
166
+ /** Reuse the daemon's configuration resolver when no live probe is wired. */
167
+ async function resolveExternalMcpConfigurationCheck({ routeDeps, id }, _optional = {}) {
168
+ const { configs, failures } = await routeDeps.readEnabledExternalMcpConfigs({ deps: { repo: routeDeps.externalMcpServerRepo, sealer: routeDeps.siteAssistantSecretSealer, oauth: routeDeps.externalMcpOAuth?.tokenResolver },
169
+ workspaceId: routeDeps.workspaceId });
170
+ if (configs.some((config) => config.serverId === id))
171
+ return { ok: true };
172
+ const failure = failures.find((candidate) => candidate.serverId === id);
173
+ return { ok: false, reason: failure?.reason ?? "this server's connection could not be resolved" };
174
+ }
175
+ /**
176
+ * This wiring layer's OWN risk classification, authored from what each handler below actually
177
+ * calls. See `DerivedRiskByToolId` in the kit for why it is independent of the catalog's own
178
+ * `sideEffects` declaration.
179
+ */
180
+ export const externalMcpDerivedRisk = new Map([
181
+ // -> routeDeps.listExternalMcpServerViews(): a repo read, never unseals.
182
+ ["external_mcp_list", "none"],
183
+ // -> routeDeps.saveExternalMcpServer(): repo.upsert() plus a seal, gated behind the human's own form
184
+ // confirmation (ADR-055-style held-open exchange, same shape as content_post_delete).
185
+ ["external_mcp_save", "mutates-durable-state"],
186
+ // -> routeDeps.readEnabledExternalMcpConfigs(): OAuth token resolution may persist a refreshed grant.
187
+ ["external_mcp_test_connection", "mutates-durable-state"],
188
+ // -> externalMcpOAuth.beginConnect(): writes oauthStatus 'pending' (and, for a self-configuring
189
+ // connection, persists a minted client identity) before returning the authorization/device
190
+ // start. Durable.
191
+ ["external_mcp_oauth_connect", "mutates-durable-state"],
192
+ // -> externalMcpOAuth.pollDeviceAuthorization(): persists the access token on the 'connected'
193
+ // outcome, resets state on a terminal failure. Durable.
194
+ ["external_mcp_oauth_poll_device", "mutates-durable-state"],
195
+ ]);
196
+ async function connectExternalMcpOAuth({ routeDeps, ctx }) {
197
+ const input = requireInputRecord({ input: ctx.input });
198
+ const id = requireString({ input, key: "id" });
199
+ await routeDeps.requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }),
200
+ workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: EXTERNAL_MCP_MANAGE_PERMISSION }, { entityType: EXTERNAL_MCP_ENTITY_TYPE,
201
+ entityId: id });
202
+ if (!routeDeps.externalMcpOAuth) {
203
+ throw new Error(routeDeps.oauthUnavailableMessage({ serverId: id }));
204
+ }
205
+ const redirectUri = routeDeps.resolveExternalMcpOAuthRedirectUri({ serverId: id, derivedPublicOrigin: routeDeps.derivedPublicOrigin });
206
+ try {
207
+ return await routeDeps.externalMcpOAuth.beginConnect({ serverId: id, actorId: ctx.principal.id, ...(redirectUri === undefined ? {} : { redirectUri }), delivery: 'hosted' });
208
+ }
209
+ catch (error) {
210
+ // `ExternalMcpValidationError` is exactly "the caller named something this connection cannot
211
+ // do, and a different input or one config change fixes it" — an unknown id, a non-OAuth row,
212
+ // or (since 2026-09-09) an authorization_code grant with no configured public origin. As a
213
+ // bare `Error` those all reach the model redacted, which is how a clearly-worded refusal
214
+ // naming the configured public URL became, in practice, a silent one. Nothing internal is in these
215
+ // messages beyond the server id the caller already sent.
216
+ if (error instanceof routeDeps.ExternalMcpValidationError)
217
+ throw new ToolInputError({ message: error.message });
218
+ throw error;
219
+ }
220
+ }
221
+ async function listExternalMcpConnections({ routeDeps, ctx }) {
222
+ requireNoInput({ input: ctx.input });
223
+ await routeDeps.requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }),
224
+ workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: EXTERNAL_MCP_MANAGE_PERMISSION }, { entityType: EXTERNAL_MCP_ENTITY_TYPE });
225
+ const servers = await routeDeps.listExternalMcpServerViews({ deps: { repo: routeDeps.externalMcpServerRepo, sealer: routeDeps.siteAssistantSecretSealer }, workspaceId: routeDeps.workspaceId });
226
+ return { servers };
227
+ }
228
+ export function buildExternalMcpRegistrations(routeDeps, surfaces) {
229
+ const handlers = {
230
+ external_mcp_list: async (ctx) => listExternalMcpConnections({ routeDeps, ctx }),
231
+ /**
232
+ * See this file's header ("`external_mcp_save`: one call, held open"). Fails closed rather than
233
+ * degrade when this execution context cannot show a dialog — same posture `content_post_delete`
234
+ * and `deployment_propose_custom_provider_credential` both take for the identical case: a form
235
+ * this tool exists specifically to render cannot be skipped without abandoning the "never saves
236
+ * silently" guarantee `agent-tools.ts`'s own description makes.
237
+ */
238
+ external_mcp_save: externalMcpSaveHandler({ routeDeps, surfaces }),
239
+ /** See this file's header ("`external_mcp_test_connection` never opens a socket"). */
240
+ external_mcp_test_connection: async (ctx) => {
241
+ const input = requireInputRecord({ input: ctx.input });
242
+ const id = requireString({ input, key: "id" });
243
+ await routeDeps.requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }),
244
+ workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: EXTERNAL_MCP_MANAGE_PERMISSION }, { entityType: EXTERNAL_MCP_ENTITY_TYPE,
245
+ entityId: id });
246
+ const record = await routeDeps.externalMcpServerRepo.findByServerId({ workspaceId: routeDeps.workspaceId, serverId: id });
247
+ if (!record)
248
+ return { ok: false, reason: `no external MCP server is configured as '${id}'` };
249
+ if (!record.enabled)
250
+ return { ok: false, reason: "this server is disabled" };
251
+ // The probe is classed mutates-durable-state; a call cancelled during the lookup must not start it.
252
+ ctx.signal.throwIfAborted();
253
+ if (routeDeps.externalMcpProbe) {
254
+ const probe = await routeDeps.externalMcpProbe({ serverId: id });
255
+ return !probe.ok && probe.body.code === "MCP_AUTH_REJECTED" && record.authMode === "static_env"
256
+ ? { ...probe, credentialSetup: routeDeps.issueCredentialSetup({ setupToolId: "external_mcp_save", prefill: { id } }, {}) }
257
+ : probe;
258
+ }
259
+ return resolveExternalMcpConfigurationCheck({ routeDeps, id });
260
+ },
261
+ /** See this file's header ("`external_mcp_oauth_connect` has no live HTTP request"). */
262
+ external_mcp_oauth_connect: async (ctx) => connectExternalMcpOAuth({ routeDeps, ctx }),
263
+ external_mcp_oauth_poll_device: async (ctx) => {
264
+ const input = requireInputRecord({ input: ctx.input });
265
+ const id = requireString({ input, key: "id" });
266
+ await routeDeps.requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }),
267
+ workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: EXTERNAL_MCP_MANAGE_PERMISSION }, { entityType: EXTERNAL_MCP_ENTITY_TYPE,
268
+ entityId: id });
269
+ if (!routeDeps.externalMcpOAuth) {
270
+ throw new Error("external_mcp_oauth_poll_device: this execution context has no OAuth service wired, so this device " +
271
+ "authorization cannot be polled here.");
272
+ }
273
+ const result = await routeDeps.externalMcpOAuth.pollDeviceAuthorization({ serverId: id });
274
+ // Same roster-change fan-out as a completed browser OAuth callback — a device-flow connection
275
+ // becomes usable at exactly this "connected" transition, not at every "pending" poll in between.
276
+ if (result.status === "connected")
277
+ void routeDeps.notifyExternalMcpRosterChanged();
278
+ return result;
279
+ },
280
+ };
281
+ // No `unwiredToolIds`: External MCP wires its ENTIRE catalog, same tripwire discipline as
282
+ // Posts/Themes/Plugins — a 6th catalog entry added without a handler fails the build.
283
+ return buildDomainRegistrations({ metadata: toolMetadata,
284
+ domain: "external-mcp",
285
+ catalogModule: "@jini-ai/mcp/external/agent-tools",
286
+ catalog: indexCatalogById({ catalog: routeDeps.catalog }),
287
+ handlers,
288
+ derivedRisk: externalMcpDerivedRisk,
289
+ });
290
+ }
291
+ /**
292
+ * Contributes External MCP's AI tools to the assistant's catalog — called once by
293
+ * `server/runtime/composition/tool-catalog-manifest.ts`'s `installFirstPartyToolContributors()`, not
294
+ * by importing this module. See this file's header for what was unreachable before this existed.
295
+ */
296
+ export function contributeExternalMcpTools({ probe, knownToolNames } = {}, _optional = {}) {
297
+ return { domain: "external-mcp", build: (deps, surfaces) => buildExternalMcpRegistrations({ ...deps, ...(knownToolNames ? { externalMcpKnownToolNames: knownToolNames } : {}), ...(probe ? { externalMcpProbe: ({ serverId }) => probe({ deps, serverId }) } : {}) }, surfaces), risk: externalMcpDerivedRisk };
298
+ }
299
+ //# sourceMappingURL=tool-registrations.js.map
@@ -97,6 +97,24 @@ export interface AttachFederatedMcpToolsParams {
97
97
  logger?: Logger | undefined;
98
98
  env?: NodeJS.ProcessEnv | undefined;
99
99
  }
100
+ /** Resolves the defaulted inputs `attachFederatedMcpTools` needs — `logger`, `connect`, and the
101
+ * merged connection list (presets or an injected override, plus any extra roster connections),
102
+ * each tagged with its origin. Split out purely to keep that function under the shop complexity
103
+ * ceiling.
104
+ *
105
+ * `params.connections` (an injected override, used throughout this file's own tests) stands in for
106
+ * the preset list, not the roster — it replaces `resolveRegisteredPresets`'s result, and
107
+ * `extraConnections` is documented on {@link AttachFederatedMcpToolsParams} as specifically the
108
+ * operator-editable roster. So the origin tag is exactly which of the two arrays a connection came
109
+ * from, unchanged from before this field existed. */
110
+ /** Stamps a preset-sourced connection's config with `origin: {kind:"preset"}`, so
111
+ * `external-mcp-revocation.ts`'s per-call gate can tell it apart from a roster connection (which
112
+ * carries its OWN origin already, stamped by `external-mcp-store.ts`'s
113
+ * `toResolvedFederatedConnections`) and skip the row re-check a preset has no row to support. Split
114
+ * out purely to keep {@link resolveFederationAttachInputs} under the shop complexity ceiling. */
115
+ export declare function withPresetOrigin({ connection }: {
116
+ connection: ResolvedFederatedConnection;
117
+ }, _optional?: {}): ResolvedFederatedConnection;
100
118
  export type AttachFederatedMcpToolsRequiredArgs = Pick<AttachFederatedMcpToolsParams, "registry" | "deps" | "connect">;
101
119
  export type AttachFederatedMcpToolsOptions = Omit<AttachFederatedMcpToolsParams, "registry" | "deps" | "connect">;
102
120
  export declare function attachFederatedMcpTools(requiredArgs: AttachFederatedMcpToolsRequiredArgs, optionalArgs?: AttachFederatedMcpToolsOptions): Promise<AttachFederatedToolsResult>;
@@ -52,7 +52,7 @@ const consoleLogger = createConsoleLogger({ prefix: "agent-daemon" });
52
52
  * carries its OWN origin already, stamped by `external-mcp-store.ts`'s
53
53
  * `toResolvedFederatedConnections`) and skip the row re-check a preset has no row to support. Split
54
54
  * out purely to keep {@link resolveFederationAttachInputs} under the shop complexity ceiling. */
55
- function withPresetOrigin(connection) {
55
+ export function withPresetOrigin({ connection }, _optional = {}) {
56
56
  return { ...connection, config: { ...connection.config, origin: { kind: "preset" } } };
57
57
  }
58
58
  function resolveFederationAttachInputs(params) {
@@ -60,7 +60,7 @@ function resolveFederationAttachInputs(params) {
60
60
  const connect = params.connect;
61
61
  const presetConnections = params.connections ?? resolveFederatedMcpPresets({ env: params.env ?? process.env, logger, registry: params.presetRegistry ?? defaultFederatedMcpPresetRegistry });
62
62
  const connections = [
63
- ...presetConnections.map((connection) => ({ connection: withPresetOrigin(connection), isPreset: true })),
63
+ ...presetConnections.map((connection) => ({ connection: withPresetOrigin({ connection }), isPreset: true })),
64
64
  ...(params.extraConnections ?? []).map((connection) => ({ connection, isPreset: false })),
65
65
  ];
66
66
  return { logger, connect, connections };
@@ -0,0 +1,19 @@
1
+ import { type FederationAdmissionsPorts } from "./admissions.js";
2
+ import type { ExternalMcpOperations } from "../external/operations-tools.js";
3
+ /** Live in-process accounting. The federation transport owns remote errors and their tracing. */
4
+ export type ServerAdmissionsReader = Omit<FederationAdmissionsPorts, "report">;
5
+ /** The host's report of a failed read. Its log line and redacting formatter are the host's: the cause's class and code
6
+ * only, never its message, so an opaque transport failure cannot expose credentials to the log. */
7
+ export type ReportReadFailure = (required: {
8
+ error: unknown;
9
+ }) => void;
10
+ /** Binds the host's failure reporter once and returns the admissions reader every caller uses.
11
+ * @param required.reportReadFailure - The host's redacting report for a failed read.
12
+ * @returns `readServerAdmissions`, bound to that reporter.
13
+ * @example export const readServerAdmissions = createServerAdmissionsReader({ reportReadFailure });
14
+ * @complexity O(1).
15
+ */
16
+ export declare function createServerAdmissionsReader({ reportReadFailure }: {
17
+ reportReadFailure: ReportReadFailure;
18
+ }, _optional?: {}): ({ awaitFederation, readAdmissions }: ServerAdmissionsReader, _options?: Record<string, never>) => ReturnType<ExternalMcpOperations["admissions"]>;
19
+ //# sourceMappingURL=external-mcp-admissions.d.ts.map