@jini-ai/mcp 0.7.3-next.2 → 0.7.4
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 +7 -0
- package/README.md +15 -0
- package/dist/agent-install/owned-json-install.d.ts +1 -1
- package/dist/client/client.js +1 -1
- package/dist/client/css-url-refs.d.ts +3 -1
- package/dist/client/css-url-refs.js +2 -2
- package/dist/external/access-review.d.ts +46 -0
- package/dist/external/access-review.js +175 -0
- package/dist/external/agent-tools.d.ts +71 -0
- package/dist/external/agent-tools.js +217 -0
- package/dist/external/built-in-connections.d.ts +17 -0
- package/dist/external/built-in-connections.js +15 -0
- package/dist/external/external-mcp-host-copy.d.ts +14 -0
- package/dist/external/external-mcp-host-copy.js +8 -0
- package/dist/external/operations-tools.d.ts +69 -0
- package/dist/external/operations-tools.js +96 -0
- package/dist/external/save-form.d.ts +105 -0
- package/dist/external/save-form.js +260 -0
- package/dist/external/save-input.d.ts +41 -0
- package/dist/external/save-input.js +149 -0
- package/dist/external/tool-registrations.d.ts +130 -0
- package/dist/external/tool-registrations.js +288 -0
- package/dist/federation/bootstrap.d.ts +18 -0
- package/dist/federation/bootstrap.js +2 -2
- package/dist/federation/external-mcp-admissions.d.ts +19 -0
- package/dist/federation/external-mcp-admissions.js +30 -0
- package/dist/federation/external-mcp-probe.d.ts +86 -0
- package/dist/federation/external-mcp-probe.js +75 -0
- package/dist/federation/hosted/external-mcp-repo.d.ts +108 -0
- package/dist/federation/hosted/external-mcp-repo.js +212 -0
- package/dist/federation/hosted/external-mcp-repo.writes.d.ts +75 -0
- package/dist/federation/hosted/external-mcp-repo.writes.js +131 -0
- package/dist/federation/hosted/store-credentials.d.ts +6 -1
- package/dist/federation/hosted/store-credentials.js +2 -2
- package/dist/federation/hosted/store-input.d.ts +11 -3
- package/dist/federation/hosted/store-input.js +7 -8
- package/dist/federation/hosted/store-oauth-fields.d.ts +10 -2
- package/dist/federation/hosted/store-oauth-fields.js +7 -7
- package/dist/federation/hosted/store-view.d.ts +6 -1
- package/dist/federation/hosted/store-view.js +2 -2
- package/dist/federation/hosted/store.js +7 -7
- package/dist/federation/hosted/store.memory.d.ts +2 -0
- package/dist/federation/hosted/store.memory.js +10 -3
- package/dist/federation/index.d.ts +2 -0
- package/dist/federation/index.js +2 -0
- package/dist/federation/registrations.js +73 -56
- package/dist/federation/roster-change.d.ts +63 -0
- package/dist/federation/roster-change.js +68 -0
- package/dist/federation/runtime.d.ts +140 -0
- package/dist/federation/runtime.js +118 -0
- package/dist/react/external-mcp/ExternalMcpAdmissionsBanner.d.ts +42 -0
- package/dist/react/external-mcp/ExternalMcpAdmissionsBanner.js +80 -0
- package/dist/react/external-mcp/ExternalMcpPanelSections.d.ts +50 -0
- package/dist/react/external-mcp/ExternalMcpPanelSections.js +35 -0
- package/dist/react/external-mcp/ExternalMcpSettingsPanel.d.ts +446 -0
- package/dist/react/external-mcp/ExternalMcpSettingsPanel.hooks.d.ts +135 -0
- package/dist/react/external-mcp/ExternalMcpSettingsPanel.hooks.js +122 -0
- package/dist/react/external-mcp/ExternalMcpSettingsPanel.js +63 -0
- package/dist/react/external-mcp/ExternalMcpSourceRow.d.ts +40 -0
- package/dist/react/external-mcp/ExternalMcpSourceRow.js +100 -0
- package/dist/react/external-mcp/hooks/external-mcp-form.rules.d.ts +58 -0
- package/dist/react/external-mcp/hooks/external-mcp-form.rules.js +209 -0
- package/dist/react/external-mcp/hooks/external-mcp-source-actions.d.ts +115 -0
- package/dist/react/external-mcp/hooks/external-mcp-source-actions.js +152 -0
- package/dist/react/external-mcp/hooks/use-external-mcp-admissions.hooks.d.ts +166 -0
- package/dist/react/external-mcp/hooks/use-external-mcp-admissions.hooks.js +209 -0
- package/dist/react/external-mcp/hooks/use-external-mcp.hooks.d.ts +132 -0
- package/dist/react/external-mcp/hooks/use-external-mcp.hooks.js +37 -0
- package/dist/server/loopback-fetch.js +3 -3
- package/dist/server/tool-arguments.d.ts +5 -1
- package/dist/server/tool-arguments.js +13 -9
- package/dist/server/tool-protocol.js +7 -5
- package/dist/server/tools/tool-catalog-tools.js +6 -3
- package/dist/tools/ask-choice/custom-answer.d.ts +77 -0
- package/dist/tools/ask-choice/custom-answer.js +113 -0
- package/dist/tools/ask-choice/index.d.ts +2 -0
- package/dist/tools/ask-choice/index.js +1 -0
- package/package.json +123 -7
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The product copy a host passes into the external MCP domain's model-facing text (the setup
|
|
3
|
+
* and operations tool catalogs, and the operations handlers' refusal messages). Type-only: the
|
|
4
|
+
* engine names neither the host's settings screen nor the host's own read tool in text a model
|
|
5
|
+
* reads, so the host supplies them.
|
|
6
|
+
*/
|
|
7
|
+
/** Host product copy for external MCP tool catalogs and messages. */
|
|
8
|
+
export interface ExternalMcpHostCopy {
|
|
9
|
+
/** Where the host's admin form for external MCP servers lives, as the model is told, e.g. "Settings → External MCP". */
|
|
10
|
+
readonly settingsLocation: string;
|
|
11
|
+
/** The host tool the model calls to read configured servers (the catalogs and messages point the model at it). */
|
|
12
|
+
readonly listToolName: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=external-mcp-host-copy.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The product copy a host passes into the external MCP domain's model-facing text (the setup
|
|
3
|
+
* and operations tool catalogs, and the operations handlers' refusal messages). Type-only: the
|
|
4
|
+
* engine names neither the host's settings screen nor the host's own read tool in text a model
|
|
5
|
+
* reads, so the host supplies them.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=external-mcp-host-copy.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type AgentToolSideEffect, type ToolRegistration } from "@jini-ai/core";
|
|
2
|
+
import type { ToolContributor } from "@jini-ai/core";
|
|
3
|
+
import type { RateLimiter } from "@jini-ai/core/contracts/server";
|
|
4
|
+
import type { Clock as ClockPort, UUID } from "@jini-ai/core/primitives";
|
|
5
|
+
import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
|
|
6
|
+
import { type AgentToolDefinition } from "@jini-ai/core";
|
|
7
|
+
import type { ExternalMcpHostCopy } from "./external-mcp-host-copy.js";
|
|
8
|
+
/** The slice of the host's tool deps these diagnostics read; the host's full deps bag satisfies it structurally. */
|
|
9
|
+
export interface ExternalMcpOperationsDeps {
|
|
10
|
+
workspaceId: UUID;
|
|
11
|
+
authorize: AuthorizeFn;
|
|
12
|
+
clock: ClockPort;
|
|
13
|
+
}
|
|
14
|
+
/** Composition injects the same services the External MCP admin routes call. Secrets stay in those services.
|
|
15
|
+
* The host also binds its model-facing copy and the probe budget's limiter (its outbound-call profile) here. */
|
|
16
|
+
export interface ExternalMcpOperations<TDeps extends ExternalMcpOperationsDeps = ExternalMcpOperationsDeps> {
|
|
17
|
+
readonly copy: ExternalMcpHostCopy;
|
|
18
|
+
createProbeLimiter(required: {
|
|
19
|
+
clock: ClockPort;
|
|
20
|
+
}): Pick<RateLimiter, "check">;
|
|
21
|
+
probe({ deps, serverId }: {
|
|
22
|
+
deps: TDeps;
|
|
23
|
+
serverId: string;
|
|
24
|
+
}, optional?: Record<string, never>): Promise<{
|
|
25
|
+
readonly ok: true;
|
|
26
|
+
readonly body: {
|
|
27
|
+
readonly tools: readonly unknown[];
|
|
28
|
+
readonly probedAt: string;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
readonly ok: false;
|
|
32
|
+
readonly status: number;
|
|
33
|
+
readonly body: Readonly<Record<string, unknown>>;
|
|
34
|
+
}>;
|
|
35
|
+
admissions(): Promise<{
|
|
36
|
+
readonly ok: true;
|
|
37
|
+
readonly connections: unknown;
|
|
38
|
+
readonly configFailures?: unknown;
|
|
39
|
+
} | {
|
|
40
|
+
readonly ok: false;
|
|
41
|
+
readonly body: {
|
|
42
|
+
readonly error: string;
|
|
43
|
+
readonly code: "AGENT_DAEMON_UNAVAILABLE";
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createExternalMcpOperationsToolCatalog({ copy }: {
|
|
48
|
+
copy: ExternalMcpHostCopy;
|
|
49
|
+
}, _optional?: {}): readonly AgentToolDefinition[];
|
|
50
|
+
export declare const externalMcpOperationsDerivedRisk: ReadonlyMap<string, AgentToolSideEffect>;
|
|
51
|
+
/** Builds two diagnostics handlers. Permission runs before I/O; live probes share a workspace budget.
|
|
52
|
+
* @param deps - Workspace, permission checker and clock shared with the setup tools.
|
|
53
|
+
* @param operations - Shared admin probe and server admissions services, the host copy and probe limiter, injected by composition.
|
|
54
|
+
* @returns Registrations for the hosted probe and live admissions tools.
|
|
55
|
+
* @throws {ToolInputError} Handlers refuse invalid arguments, rate limits or unavailable services.
|
|
56
|
+
* @complexity O(1) wiring; services bound their own I/O and collection costs.
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildExternalMcpOperationsRegistrations<TDeps extends ExternalMcpOperationsDeps>({ deps, operations }: {
|
|
59
|
+
deps: TDeps;
|
|
60
|
+
operations: ExternalMcpOperations<TDeps>;
|
|
61
|
+
}, _optional?: Record<string, never>): ToolRegistration[];
|
|
62
|
+
/** Adds diagnostics under a distinct domain so the existing setup/OAuth contributor remains installed.
|
|
63
|
+
* @param operations - Shared admin services; no credentials are exposed through tool arguments.
|
|
64
|
+
* @returns The contributor installed by the composition root.
|
|
65
|
+
* @example contributeExternalMcpOperationsTools({ copy, createProbeLimiter, probe: probeExternalMcpServer, admissions: serverFederation.admissions })
|
|
66
|
+
* @complexity O(1) time and space.
|
|
67
|
+
*/
|
|
68
|
+
export declare function contributeExternalMcpOperationsTools<TDeps extends ExternalMcpOperationsDeps>(operations: ExternalMcpOperations<TDeps>): ToolContributor<TDeps, unknown>;
|
|
69
|
+
//# sourceMappingURL=operations-tools.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { toolMetadata } from '@jini-ai/core/tool-metadata/external-mcp';
|
|
2
|
+
import { buildDomainRegistrations, indexCatalogById, requireInputRecord } from "@jini-ai/core";
|
|
3
|
+
import { adaptLegacyAuthorize, requireToolPermission } from "@jini-ai/core";
|
|
4
|
+
import { ToolInputError } from "@jini-ai/core";
|
|
5
|
+
import {} from "@jini-ai/core";
|
|
6
|
+
import { EXTERNAL_MCP_MANAGE_PERMISSION } from "./agent-tools.js";
|
|
7
|
+
export function createExternalMcpOperationsToolCatalog({ copy }, _optional = {}) {
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
name: "external_mcp_probe_connection",
|
|
11
|
+
description: "Tests a saved, enabled hosted external MCP connection (needs the full gateway: it can store data) by connecting once, listing advertised tools and closing, just like the admin External MCP page's probe. Call to check live reachability and see which remote tools would be allowed or refused. Returns { tools, probedAt }; does not invoke remote tools or change the assistant's live roster. May refresh and persist an OAuth grant. Refuses unknown, disabled or local-command servers, expired authorization, unreachable endpoints and excessive attempts. Use external_mcp_get_admissions for the actual live roster.",
|
|
12
|
+
sideEffects: "mutates-durable-state",
|
|
13
|
+
authorization: { permission: EXTERNAL_MCP_MANAGE_PERMISSION },
|
|
14
|
+
inputSchema: { type: "object", additionalProperties: false, required: ["id"], properties: { id: { type: "string", minLength: 1, maxLength: 64, description: `A saved hosted server id from ${copy.listToolName}.` } } },
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "external_mcp_get_admissions",
|
|
18
|
+
description: `Shows the server's current external MCP tool admissions (needs the full gateway: it can store data): the tools actually admitted, refused, missing from allowlists, and configuration failures. Call when saved tool selections differ from what the assistant can use. Returns { connections, configFailures? }, preserving the live server report. Starts server federation if needed and may refresh saved OAuth grants; does not change tool grants or server settings. An unavailable report produces an actionable error, never an empty roster. Use ${copy.listToolName} for saved server configuration and status, external_mcp_probe_connection to test a hosted endpoint, or external_mcp_save to open the human setup form.`,
|
|
19
|
+
sideEffects: "mutates-durable-state",
|
|
20
|
+
authorization: { permission: EXTERNAL_MCP_MANAGE_PERMISSION },
|
|
21
|
+
inputSchema: { type: "object", additionalProperties: false, properties: {} },
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
export const externalMcpOperationsDerivedRisk = new Map([
|
|
26
|
+
// probeExternalMcpServer -> readEnabledExternalMcpConfigs -> OAuth token resolution may persist a refreshed grant.
|
|
27
|
+
["external_mcp_probe_connection", "mutates-durable-state"],
|
|
28
|
+
// Server admission startup resolves OAuth tokens and may persist a refreshed grant.
|
|
29
|
+
["external_mcp_get_admissions", "mutates-durable-state"],
|
|
30
|
+
]);
|
|
31
|
+
/** Rejects secret-bearing or unsupported arguments before any I/O, including direct delegated calls.
|
|
32
|
+
* @param required.input - Model arguments; omitted arguments mean an empty object.
|
|
33
|
+
* @param required.toolId - Tool name used in the recovery message.
|
|
34
|
+
* @param required.allowedKeys - The complete non-secret field allowlist.
|
|
35
|
+
* @returns The validated argument record.
|
|
36
|
+
* @throws {ToolInputError} For non-object input or fields outside the allowlist.
|
|
37
|
+
* @complexity O(k) time and space for input keys (allowlists contain at most one key).
|
|
38
|
+
*/
|
|
39
|
+
function readOperationInput({ input, toolId, allowedKeys }, _optional = {}) {
|
|
40
|
+
const record = requireInputRecord({ input: input ?? {} });
|
|
41
|
+
if (Object.keys(record).some(key => !allowedKeys.includes(key)))
|
|
42
|
+
throw new ToolInputError({ message: `${toolId}: unsupported input fields. Never pass credentials through tool arguments.` });
|
|
43
|
+
return record;
|
|
44
|
+
}
|
|
45
|
+
/** Builds two diagnostics handlers. Permission runs before I/O; live probes share a workspace budget.
|
|
46
|
+
* @param deps - Workspace, permission checker and clock shared with the setup tools.
|
|
47
|
+
* @param operations - Shared admin probe and server admissions services, the host copy and probe limiter, injected by composition.
|
|
48
|
+
* @returns Registrations for the hosted probe and live admissions tools.
|
|
49
|
+
* @throws {ToolInputError} Handlers refuse invalid arguments, rate limits or unavailable services.
|
|
50
|
+
* @complexity O(1) wiring; services bound their own I/O and collection costs.
|
|
51
|
+
*/
|
|
52
|
+
export function buildExternalMcpOperationsRegistrations({ deps, operations }, _optional = {}) {
|
|
53
|
+
const limiter = operations.createProbeLimiter({ clock: deps.clock });
|
|
54
|
+
return buildDomainRegistrations({ metadata: toolMetadata,
|
|
55
|
+
domain: "external-mcp-operations",
|
|
56
|
+
catalogModule: "external/operations-tools.ts",
|
|
57
|
+
catalog: indexCatalogById({ catalog: createExternalMcpOperationsToolCatalog({ copy: operations.copy }) }),
|
|
58
|
+
derivedRisk: externalMcpOperationsDerivedRisk,
|
|
59
|
+
handlers: {
|
|
60
|
+
external_mcp_probe_connection: async (ctx) => {
|
|
61
|
+
const input = readOperationInput({ input: ctx.input, toolId: "external_mcp_probe_connection", allowedKeys: ["id"] });
|
|
62
|
+
if (typeof input.id !== "string" || !input.id.trim() || input.id.length > 64)
|
|
63
|
+
throw new ToolInputError({ message: `external_mcp_probe_connection: pass a non-empty saved server id. Use ${operations.copy.listToolName} to find it.` });
|
|
64
|
+
const id = input.id.trim();
|
|
65
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: deps.authorize }),
|
|
66
|
+
workspaceId: deps.workspaceId, principalId: ctx.principal.id, permission: EXTERNAL_MCP_MANAGE_PERMISSION }, { entityType: "integration", entityId: id });
|
|
67
|
+
const budget = await limiter.check({ key: deps.workspaceId });
|
|
68
|
+
if (!budget.allowed)
|
|
69
|
+
throw new ToolInputError({ message: `external_mcp_probe_connection: too many probe attempts. Try again in ${budget.retryAfterSeconds} seconds.` });
|
|
70
|
+
const result = await operations.probe({ deps, serverId: id });
|
|
71
|
+
if (!result.ok)
|
|
72
|
+
throw new ToolInputError({ message: `external_mcp_probe_connection: ${result.body.error}. Review the server in ${operations.copy.settingsLocation}.` });
|
|
73
|
+
return result.body;
|
|
74
|
+
},
|
|
75
|
+
external_mcp_get_admissions: async (ctx) => {
|
|
76
|
+
readOperationInput({ input: ctx.input, toolId: "external_mcp_get_admissions", allowedKeys: [] });
|
|
77
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: deps.authorize }),
|
|
78
|
+
workspaceId: deps.workspaceId, principalId: ctx.principal.id, permission: EXTERNAL_MCP_MANAGE_PERMISSION }, { entityType: "integration" });
|
|
79
|
+
const result = await operations.admissions();
|
|
80
|
+
if (!result.ok)
|
|
81
|
+
throw new ToolInputError({ message: `external_mcp_get_admissions: ${result.body.error}. Try again shortly; no live admissions report is available.` });
|
|
82
|
+
return result.configFailures === undefined ? { connections: result.connections } : { connections: result.connections, configFailures: result.configFailures };
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Adds diagnostics under a distinct domain so the existing setup/OAuth contributor remains installed.
|
|
88
|
+
* @param operations - Shared admin services; no credentials are exposed through tool arguments.
|
|
89
|
+
* @returns The contributor installed by the composition root.
|
|
90
|
+
* @example contributeExternalMcpOperationsTools({ copy, createProbeLimiter, probe: probeExternalMcpServer, admissions: serverFederation.admissions })
|
|
91
|
+
* @complexity O(1) time and space.
|
|
92
|
+
*/
|
|
93
|
+
export function contributeExternalMcpOperationsTools(operations) {
|
|
94
|
+
return { domain: "external-mcp-operations", build: deps => buildExternalMcpOperationsRegistrations({ deps, operations }), risk: externalMcpOperationsDerivedRisk };
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=operations-tools.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { SecretCardField, SecretCardForm } from "@jini-ai/core/contracts/cards";
|
|
2
|
+
import type { ExternalMcpServerView as CanonicalExternalMcpServerView } from "@jini-ai/core/contracts/hosted-mcp";
|
|
3
|
+
/** The admin read model with any host's credential-hint shape: the prefill reads no hint. */
|
|
4
|
+
type ExternalMcpServerView = CanonicalExternalMcpServerView<unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* @file The confirmation form `external_mcp_save` renders — see `tool-registrations.ts`'s handler
|
|
7
|
+
* for how it is opened, answered, and turned into a real write.
|
|
8
|
+
*
|
|
9
|
+
* ## Why the field LIST is computed once, not reactive
|
|
10
|
+
*
|
|
11
|
+
* The host admin UI's `rules.ts`'s `buildExternalMcpFieldSpecs` solves the identical
|
|
12
|
+
* "which fields apply to this transport/authMode" decision for the admin UI, where it must be
|
|
13
|
+
* REACTIVE — a human can change their mind mid-form. An MCP-UI form has no such need: it is a
|
|
14
|
+
* server-rendered HTML document generated once per tool call, and the agent has already committed
|
|
15
|
+
* to a transport/authMode by the time it calls this tool (see `agent-tools.ts`'s own schema doc).
|
|
16
|
+
* So this file restates the SAME decision rules as a one-shot computation over the tool's own input,
|
|
17
|
+
* rather than importing the admin package's React-specific type. Two independent, intentionally
|
|
18
|
+
* parallel implementations of one documented rule — not a shared abstraction — because the two
|
|
19
|
+
* outputs are genuinely different shapes (`@jini-ai/ui`'s `SourceFieldSpec` vs `@jini-ai/ui/mcp-ui/
|
|
20
|
+
* secret-card`'s `SecretCardField`) for two different rendering systems.
|
|
21
|
+
*
|
|
22
|
+
* ## Secrets never appear as `value`
|
|
23
|
+
*
|
|
24
|
+
* `env`/`accessToken`/`oauthClientSecret` are rendered `secret: true` with NO `value` — never pre-filled, even
|
|
25
|
+
* when updating a row that already has one, because there is nothing to pre-fill FROM: no read model
|
|
26
|
+
* in this subsystem ever returns a stored secret (see the host admin UI's own `use-external-mcp.hooks.ts`
|
|
27
|
+
* header for the identical rule, restated for the identical reason). Leaving it blank on submit is
|
|
28
|
+
* what "keep what's stored" means to `saveExternalMcpServer` — the same tri-state convention the
|
|
29
|
+
* admin form's own write path already relies on.
|
|
30
|
+
*/
|
|
31
|
+
export declare const EXTERNAL_MCP_SAVE_TOOL_ID = "external_mcp_save";
|
|
32
|
+
/** `external_mcp_save`'s own non-secret input, narrowed to what {@link buildExternalMcpSaveFormFields}
|
|
33
|
+
* and {@link buildExternalMcpSaveForm} actually read. Matches `agent-tools.ts`'s `SAVE_INPUT_SCHEMA`
|
|
34
|
+
* property-for-property. */
|
|
35
|
+
export interface ExternalMcpSaveInput {
|
|
36
|
+
id: string;
|
|
37
|
+
label?: string | undefined;
|
|
38
|
+
enabled?: boolean | undefined;
|
|
39
|
+
transport: string;
|
|
40
|
+
command?: string | undefined;
|
|
41
|
+
args?: string | undefined;
|
|
42
|
+
url?: string | undefined;
|
|
43
|
+
allowedToolNames?: string | undefined;
|
|
44
|
+
/** Raw operator input, comma-separated remote tool names separately authorized to write —
|
|
45
|
+
* `SaveExternalMcpServerInput.writeAllowedToolNames`'s own tri-state convention (resent in full on
|
|
46
|
+
* every save, not tri-state like `env`; see `tool-registrations.ts`'s
|
|
47
|
+
* `buildSaveExternalMcpServerInputFromFormParams` for why). The store rejects a name here that is
|
|
48
|
+
* not also in `allowedToolNames` (`external-mcp-store.ts`'s `assertWriteAllowlistSubset`). */
|
|
49
|
+
writeAllowedToolNames?: string | undefined;
|
|
50
|
+
authMode?: string | undefined;
|
|
51
|
+
/** Non-secret name of the stdio variable that receives the human-entered token. */
|
|
52
|
+
accessTokenEnvName?: string | undefined;
|
|
53
|
+
oauthProviderId?: string | undefined;
|
|
54
|
+
oauthGrant?: string | undefined;
|
|
55
|
+
oauthClientId?: string | undefined;
|
|
56
|
+
oauthScopes?: string | undefined;
|
|
57
|
+
oauthTokenEnvName?: string | undefined;
|
|
58
|
+
oauthAuthorizationEndpoint?: string | undefined;
|
|
59
|
+
oauthTokenEndpoint?: string | undefined;
|
|
60
|
+
oauthDeviceAuthorizationEndpoint?: string | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Merges the agent's own input over an existing row's current (non-secret) values, so an UPDATE's
|
|
64
|
+
* form shows the human accurate current state for anything the agent did not explicitly restate,
|
|
65
|
+
* rather than blanks. `existing` is `undefined` for a brand-new id.
|
|
66
|
+
*
|
|
67
|
+
* @complexity O(1).
|
|
68
|
+
*/
|
|
69
|
+
export declare function mergeExternalMcpSavePrefill({ input, existing }: {
|
|
70
|
+
input: ExternalMcpSaveInput;
|
|
71
|
+
existing: ExternalMcpServerView | undefined;
|
|
72
|
+
}, _optional?: {}): ExternalMcpSaveInput;
|
|
73
|
+
/**
|
|
74
|
+
* The field list for one save form — see this file's header for why this is computed once rather
|
|
75
|
+
* than reactively. Composed from per-section builders (transport, env, oauth) so the section that
|
|
76
|
+
* decides inclusion stays a flat list of ternaries, and each section's own field shape lives in its
|
|
77
|
+
* own single-purpose function.
|
|
78
|
+
*
|
|
79
|
+
* @complexity O(1) — a fixed, bounded number of conditionally-included entries.
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildExternalMcpSaveFormFields({ input, isUpdate }: {
|
|
82
|
+
input: ExternalMcpSaveInput;
|
|
83
|
+
isUpdate: boolean;
|
|
84
|
+
}, _optional?: {}): SecretCardField[];
|
|
85
|
+
/**
|
|
86
|
+
* Builds `external_mcp_save`'s confirmation form.
|
|
87
|
+
*
|
|
88
|
+
* `id`/`transport`/`authMode` are bound to prepared state at save rather than trusted from submit — see this file's
|
|
89
|
+
* header on why the field SET is fixed per call; changing transport or auth mode is "call this tool
|
|
90
|
+
* again", not an in-form control. The engine posts back on cancel rather than a silent close — with the call
|
|
91
|
+
* parked, a silent close would strand the handler for the full TTL staring at a form the human
|
|
92
|
+
* already walked away from.
|
|
93
|
+
*
|
|
94
|
+
* @complexity O(f) in the field count this call includes.
|
|
95
|
+
* @returns Domain form copy and fields; the engine supplies routing/dismissal and renders the card.
|
|
96
|
+
* @example buildExternalMcpSaveForm({ save: { id: "server", transport: "streamable_http" }, isUpdate: false, appName: "host-external-mcp-save" });
|
|
97
|
+
*/
|
|
98
|
+
export declare function buildExternalMcpSaveForm(input: {
|
|
99
|
+
save: ExternalMcpSaveInput;
|
|
100
|
+
isUpdate: boolean;
|
|
101
|
+
/** The host's MCP-UI app name for this form (host identity, so host-supplied). */
|
|
102
|
+
appName: string;
|
|
103
|
+
}, _optional?: {}): SecretCardForm;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=save-form.d.ts.map
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { toolMetadata as externalMcpToolMetadata } from "@jini-ai/core/tool-metadata/external-mcp";
|
|
2
|
+
/** The secret marker comes from the same external MCP tool metadata the host's secret-form gate
|
|
3
|
+
* projects its protected ids from, so the gate and this form can never disagree. */
|
|
4
|
+
const SECRET_FORM_CARD_DEFINITIONS = { external_mcp_save: externalMcpToolMetadata.external_mcp_save.mcpUi };
|
|
5
|
+
/**
|
|
6
|
+
* @file The confirmation form `external_mcp_save` renders — see `tool-registrations.ts`'s handler
|
|
7
|
+
* for how it is opened, answered, and turned into a real write.
|
|
8
|
+
*
|
|
9
|
+
* ## Why the field LIST is computed once, not reactive
|
|
10
|
+
*
|
|
11
|
+
* The host admin UI's `rules.ts`'s `buildExternalMcpFieldSpecs` solves the identical
|
|
12
|
+
* "which fields apply to this transport/authMode" decision for the admin UI, where it must be
|
|
13
|
+
* REACTIVE — a human can change their mind mid-form. An MCP-UI form has no such need: it is a
|
|
14
|
+
* server-rendered HTML document generated once per tool call, and the agent has already committed
|
|
15
|
+
* to a transport/authMode by the time it calls this tool (see `agent-tools.ts`'s own schema doc).
|
|
16
|
+
* So this file restates the SAME decision rules as a one-shot computation over the tool's own input,
|
|
17
|
+
* rather than importing the admin package's React-specific type. Two independent, intentionally
|
|
18
|
+
* parallel implementations of one documented rule — not a shared abstraction — because the two
|
|
19
|
+
* outputs are genuinely different shapes (`@jini-ai/ui`'s `SourceFieldSpec` vs `@jini-ai/ui/mcp-ui/
|
|
20
|
+
* secret-card`'s `SecretCardField`) for two different rendering systems.
|
|
21
|
+
*
|
|
22
|
+
* ## Secrets never appear as `value`
|
|
23
|
+
*
|
|
24
|
+
* `env`/`accessToken`/`oauthClientSecret` are rendered `secret: true` with NO `value` — never pre-filled, even
|
|
25
|
+
* when updating a row that already has one, because there is nothing to pre-fill FROM: no read model
|
|
26
|
+
* in this subsystem ever returns a stored secret (see the host admin UI's own `use-external-mcp.hooks.ts`
|
|
27
|
+
* header for the identical rule, restated for the identical reason). Leaving it blank on submit is
|
|
28
|
+
* what "keep what's stored" means to `saveExternalMcpServer` — the same tri-state convention the
|
|
29
|
+
* admin form's own write path already relies on.
|
|
30
|
+
*/
|
|
31
|
+
export const EXTERNAL_MCP_SAVE_TOOL_ID = "external_mcp_save";
|
|
32
|
+
/**
|
|
33
|
+
* Merges the agent's own input over an existing row's current (non-secret) values, so an UPDATE's
|
|
34
|
+
* form shows the human accurate current state for anything the agent did not explicitly restate,
|
|
35
|
+
* rather than blanks. `existing` is `undefined` for a brand-new id.
|
|
36
|
+
*
|
|
37
|
+
* @complexity O(1).
|
|
38
|
+
*/
|
|
39
|
+
export function mergeExternalMcpSavePrefill({ input, existing }, _optional = {}) {
|
|
40
|
+
if (!existing)
|
|
41
|
+
return input;
|
|
42
|
+
const prefill = {
|
|
43
|
+
id: input.id,
|
|
44
|
+
label: existing.label,
|
|
45
|
+
enabled: existing.enabled,
|
|
46
|
+
transport: input.transport,
|
|
47
|
+
command: existing.command,
|
|
48
|
+
// Quoted the way `parseArgs` reads them, so an unchanged card saves the same arguments.
|
|
49
|
+
args: existing.args.map((arg) => (arg === "" || /\s/.test(arg) ? `"${arg}"` : arg)).join(" "),
|
|
50
|
+
url: existing.url ?? undefined,
|
|
51
|
+
allowedToolNames: existing.allowedToolNames.join(", "),
|
|
52
|
+
writeAllowedToolNames: existing.writeAllowedToolNames.join(", "),
|
|
53
|
+
authMode: existing.authMode,
|
|
54
|
+
accessTokenEnvName: existing.accessTokenEnvName ?? undefined,
|
|
55
|
+
oauthProviderId: existing.oauth.providerId ?? undefined,
|
|
56
|
+
oauthGrant: existing.oauth.grant ?? undefined,
|
|
57
|
+
oauthClientId: existing.oauth.clientId ?? undefined,
|
|
58
|
+
oauthScopes: existing.oauth.scopes.join(" "),
|
|
59
|
+
oauthTokenEnvName: existing.oauth.tokenEnvName ?? undefined,
|
|
60
|
+
// NOT merged from `existing` — `ExternalMcpOAuthView` carries no field for a connection's own
|
|
61
|
+
// typed endpoints (only `providerId`, for a registered one). There is nothing stored to merge
|
|
62
|
+
// from; see the host admin UI's `use-external-mcp.hooks.ts` header for the identical, already-disclosed
|
|
63
|
+
// gap on the admin side.
|
|
64
|
+
oauthAuthorizationEndpoint: input.oauthAuthorizationEndpoint,
|
|
65
|
+
oauthTokenEndpoint: input.oauthTokenEndpoint,
|
|
66
|
+
oauthDeviceAuthorizationEndpoint: input.oauthDeviceAuthorizationEndpoint,
|
|
67
|
+
};
|
|
68
|
+
return Object.keys(prefill).reduce((merged, field) => {
|
|
69
|
+
const key = field;
|
|
70
|
+
return { ...merged, [key]: input[key] ?? merged[key] };
|
|
71
|
+
}, prefill);
|
|
72
|
+
}
|
|
73
|
+
/** `{ value }` when `value` is present, an empty object otherwise — the shared shape every optional
|
|
74
|
+
* field spread in this file's field builders used to write inline as `value !== undefined ? {value}
|
|
75
|
+
* : {}`. Collapsing it into a call removes that ternary from every call site's own complexity count. */
|
|
76
|
+
function fieldValue({ value }, _optional = {}) {
|
|
77
|
+
return value !== undefined ? { value } : {};
|
|
78
|
+
}
|
|
79
|
+
function buildStdioTransportFields(input) {
|
|
80
|
+
return [
|
|
81
|
+
{ kind: "string", name: "command", label: "Command", required: true, ...fieldValue({ value: input.command }), placeholder: "e.g. npx, node, /path/to/binary" },
|
|
82
|
+
{ kind: "string", name: "args", label: "Args", ...fieldValue({ value: input.args }), placeholder: "space-separated" },
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
/** A credential stays exclusively in the human form, with blank update submissions preserving it.
|
|
86
|
+
* @complexity O(1) for a fixed field list.
|
|
87
|
+
*/
|
|
88
|
+
function buildStaticTokenFields({ input, isUpdate, isStdio }, _optional = {}) {
|
|
89
|
+
return [
|
|
90
|
+
{ kind: "string", name: "accessToken", label: "Access token", ...SECRET_FORM_CARD_DEFINITIONS.external_mcp_save.secretField, allowBlank: true, hint: isUpdate ? "Leave blank to keep the stored token." : "Enter the API key or bearer token for this server." },
|
|
91
|
+
...(isStdio ? [{ kind: "string", name: "accessTokenEnvName", label: "Access token environment variable", ...fieldValue({ value: input.accessTokenEnvName }), hint: "The environment variable name the local command reads, e.g. API_TOKEN." }] : []),
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
function buildEnvField({ isUpdate }, _optional = {}) {
|
|
95
|
+
return {
|
|
96
|
+
kind: "string",
|
|
97
|
+
name: "env",
|
|
98
|
+
label: "Environment variables",
|
|
99
|
+
multiline: true,
|
|
100
|
+
rows: 3,
|
|
101
|
+
...SECRET_FORM_CARD_DEFINITIONS.external_mcp_save.secretField, allowBlank: true,
|
|
102
|
+
placeholder: "KEY=VALUE, one per line",
|
|
103
|
+
...(isUpdate ? { hint: "Leave blank to keep the stored values." } : {}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* `isStdio` decides which OAuth fields a human must actually fill in, and it is not a cosmetic
|
|
108
|
+
* distinction: `external-mcp-store.ts`'s `assertOAuthClientId` / `assertOAuthGrant` /
|
|
109
|
+
* `assertOAuthProviderIdentity` admit an EMPTY client id, sign-in method and provider identity on any
|
|
110
|
+
* non-stdio row, because a row carrying a remote URL can run RFC 8414 discovery against it, read the
|
|
111
|
+
* server's own `grant_types_supported`, and mint its own client by RFC 7591 dynamic registration. A
|
|
112
|
+
* growing share of hosted MCP servers publish a registration endpoint and no developer console at
|
|
113
|
+
* all, so for those there is no client id — or a confident answer about the grant — a human could
|
|
114
|
+
* type; marking either field required made the form unsubmittable by any amount of operator effort.
|
|
115
|
+
* A stdio row has no URL to discover from, so there the requirement stands. Same rule, same
|
|
116
|
+
* reasoning, same wording as the host admin UI's `rules.ts`'s
|
|
117
|
+
* `buildExternalMcpFieldSpecs`.
|
|
118
|
+
*/
|
|
119
|
+
function buildOAuthCoreFields({ input, isUpdate, isStdio }, _optional = {}) {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
kind: "string",
|
|
123
|
+
name: "oauthProviderId",
|
|
124
|
+
label: "Provider ID",
|
|
125
|
+
...fieldValue({ value: input.oauthProviderId }),
|
|
126
|
+
hint: isStdio
|
|
127
|
+
? "Leave blank to use your own endpoints below."
|
|
128
|
+
: "Leave blank unless this server is a registered provider — a hosted server discovers its own endpoints.",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
kind: "enum",
|
|
132
|
+
name: "oauthGrant",
|
|
133
|
+
label: "Sign-in method",
|
|
134
|
+
required: isStdio,
|
|
135
|
+
options: [
|
|
136
|
+
{ value: "authorization_code", label: "Browser sign-in" },
|
|
137
|
+
{ value: "device_code", label: "Device code" },
|
|
138
|
+
],
|
|
139
|
+
...fieldValue({ value: input.oauthGrant }),
|
|
140
|
+
...(isStdio ? {} : { hint: "Detected from the server unless overridden." }),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
kind: "string",
|
|
144
|
+
name: "oauthClientId",
|
|
145
|
+
label: "Client ID",
|
|
146
|
+
required: isStdio,
|
|
147
|
+
...fieldValue({ value: input.oauthClientId }),
|
|
148
|
+
...(isStdio ? {} : { placeholder: "leave blank to register with this server automatically" }),
|
|
149
|
+
},
|
|
150
|
+
{ kind: "string", name: "oauthClientSecret", label: "Client secret", ...SECRET_FORM_CARD_DEFINITIONS.external_mcp_save.secretField, allowBlank: true, hint: isUpdate ? "Leave blank to keep the stored secret." : "Leave blank if this provider needs none (a public/PKCE client)." },
|
|
151
|
+
{ kind: "string", name: "oauthScopes", label: "Scopes", ...fieldValue({ value: input.oauthScopes }), placeholder: "space- or comma-separated" },
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
function buildOAuthTokenEnvField(input) {
|
|
155
|
+
return {
|
|
156
|
+
kind: "string",
|
|
157
|
+
name: "oauthTokenEnvName",
|
|
158
|
+
label: "Access token environment variable",
|
|
159
|
+
required: true,
|
|
160
|
+
...fieldValue({ value: input.oauthTokenEnvName }),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** What an endpoint field means on a row that self-configures: a manual override for the case where
|
|
164
|
+
* discovery does not answer, not something to go and look up. See {@link buildOAuthCoreFields}. */
|
|
165
|
+
const DISCOVERABLE_ENDPOINT_HINT = "Leave blank unless discovery against this server's URL fails.";
|
|
166
|
+
function buildOAuthEndpointFields({ input, isStdio }, _optional = {}) {
|
|
167
|
+
return [
|
|
168
|
+
{
|
|
169
|
+
kind: "string",
|
|
170
|
+
name: "oauthAuthorizationEndpoint",
|
|
171
|
+
label: "Authorization endpoint",
|
|
172
|
+
...fieldValue({ value: input.oauthAuthorizationEndpoint }),
|
|
173
|
+
hint: isStdio ? "Needed for Browser sign-in, unless Provider ID is set." : DISCOVERABLE_ENDPOINT_HINT,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
kind: "string",
|
|
177
|
+
name: "oauthTokenEndpoint",
|
|
178
|
+
label: "Token endpoint",
|
|
179
|
+
...fieldValue({ value: input.oauthTokenEndpoint }),
|
|
180
|
+
hint: isStdio ? "Needed unless Provider ID is set." : DISCOVERABLE_ENDPOINT_HINT,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
kind: "string",
|
|
184
|
+
name: "oauthDeviceAuthorizationEndpoint",
|
|
185
|
+
label: "Device authorization endpoint",
|
|
186
|
+
...fieldValue({ value: input.oauthDeviceAuthorizationEndpoint }),
|
|
187
|
+
hint: isStdio ? "Needed for Device code, unless Provider ID is set." : DISCOVERABLE_ENDPOINT_HINT,
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
function buildOAuthFields({ input, isUpdate, isStdio }, _optional = {}) {
|
|
192
|
+
return [...buildOAuthCoreFields({ input, isUpdate, isStdio }), ...(isStdio ? [buildOAuthTokenEnvField(input)] : []), ...buildOAuthEndpointFields({ input, isStdio })];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The field list for one save form — see this file's header for why this is computed once rather
|
|
196
|
+
* than reactively. Composed from per-section builders (transport, env, oauth) so the section that
|
|
197
|
+
* decides inclusion stays a flat list of ternaries, and each section's own field shape lives in its
|
|
198
|
+
* own single-purpose function.
|
|
199
|
+
*
|
|
200
|
+
* @complexity O(1) — a fixed, bounded number of conditionally-included entries.
|
|
201
|
+
*/
|
|
202
|
+
export function buildExternalMcpSaveFormFields({ input, isUpdate }, _optional = {}) {
|
|
203
|
+
const isStdio = input.transport !== "streamable_http";
|
|
204
|
+
const isOAuth = input.authMode === "oauth";
|
|
205
|
+
return [
|
|
206
|
+
...(isUpdate ? [] : [{ kind: "string", name: "id", label: "ID", required: true, value: input.id, hint: "Lowercase letters, digits and dashes." }]),
|
|
207
|
+
{ kind: "string", name: "label", label: "Display name", ...fieldValue({ value: input.label }) },
|
|
208
|
+
...(isStdio ? buildStdioTransportFields(input) : [{ kind: "string", name: "url", label: "URL", required: true, ...fieldValue({ value: input.url }), placeholder: "https://…" }]),
|
|
209
|
+
...(isStdio ? [buildEnvField({ isUpdate })] : []),
|
|
210
|
+
...(input.authMode === "static_env" || input.authMode === undefined ? buildStaticTokenFields({ input, isUpdate, isStdio }) : []),
|
|
211
|
+
...(isOAuth ? buildOAuthFields({ input, isUpdate, isStdio }) : []),
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
/** Fixed grant disclosures share the credential form without becoming editable fields.
|
|
215
|
+
* @complexity O(a+w) in the bounded proposed tool-name strings; no effects.
|
|
216
|
+
*/
|
|
217
|
+
function fixedAccessDetails(save) {
|
|
218
|
+
return [{ label: "Allowed tools", value: save.allowedToolNames || "None" },
|
|
219
|
+
{ label: "May write", value: save.writeAllowedToolNames || "None" },
|
|
220
|
+
...(save.enabled === false ? [{ label: "Connection access", value: "Disabled" }] : [])];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Builds `external_mcp_save`'s confirmation form.
|
|
224
|
+
*
|
|
225
|
+
* `id`/`transport`/`authMode` are bound to prepared state at save rather than trusted from submit — see this file's
|
|
226
|
+
* header on why the field SET is fixed per call; changing transport or auth mode is "call this tool
|
|
227
|
+
* again", not an in-form control. The engine posts back on cancel rather than a silent close — with the call
|
|
228
|
+
* parked, a silent close would strand the handler for the full TTL staring at a form the human
|
|
229
|
+
* already walked away from.
|
|
230
|
+
*
|
|
231
|
+
* @complexity O(f) in the field count this call includes.
|
|
232
|
+
* @returns Domain form copy and fields; the engine supplies routing/dismissal and renders the card.
|
|
233
|
+
* @example buildExternalMcpSaveForm({ save: { id: "server", transport: "streamable_http" }, isUpdate: false, appName: "host-external-mcp-save" });
|
|
234
|
+
*/
|
|
235
|
+
export function buildExternalMcpSaveForm(input, _optional = {}) {
|
|
236
|
+
const { save, isUpdate, appName } = input;
|
|
237
|
+
let credentials = "API key / token";
|
|
238
|
+
if (save.authMode === "oauth")
|
|
239
|
+
credentials = "Connect via OAuth";
|
|
240
|
+
if (save.authMode === "none")
|
|
241
|
+
credentials = "None needed";
|
|
242
|
+
return {
|
|
243
|
+
title: isUpdate ? `Update "${save.id}"` : `Add "${save.id}"`,
|
|
244
|
+
description: (isUpdate
|
|
245
|
+
? "The assistant wants to update this external MCP server's configuration. Review and edit anything before saving."
|
|
246
|
+
: "The assistant wants to add this external MCP server. Review and edit anything before saving.") +
|
|
247
|
+
" Saved for the whole site: every chat and agent can use it, with approvals.",
|
|
248
|
+
details: [
|
|
249
|
+
{ label: "Connection type", value: save.transport === "streamable_http" ? "Hosted server (URL)" : "Local command (stdio)" },
|
|
250
|
+
{ label: "Credentials", value: credentials },
|
|
251
|
+
...fixedAccessDetails(save),
|
|
252
|
+
...(save.transport === "streamable_http" ? [] : [{ label: "Local access", value: `Saving lets chats start ${save.command ?? "the command below"} on this computer as your OS user.` }]),
|
|
253
|
+
],
|
|
254
|
+
submitLabel: isUpdate ? "Save changes" : "Add server",
|
|
255
|
+
fields: buildExternalMcpSaveFormFields({ input: save, isUpdate }),
|
|
256
|
+
cancelLabel: "Cancel",
|
|
257
|
+
app: { appName, appVersion: "1" },
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=save-form.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { UUID } from '@jini-ai/core/primitives';
|
|
2
|
+
import type { SaveExternalMcpServerInput } from '@jini-ai/core/contracts/hosted-mcp';
|
|
3
|
+
import type { ExternalMcpSaveInput } from './save-form.js';
|
|
4
|
+
import type { ExternalMcpToolDeps } from './tool-registrations.js';
|
|
5
|
+
/** Reads `input[key]` as a string, or `undefined` for anything else — the same tri-state reading
|
|
6
|
+
* rule every other optional field in this domain's save path already follows (see `save-form.ts`'s
|
|
7
|
+
* header). @complexity O(1). */
|
|
8
|
+
export declare function optionalStringField({ input, key }: {
|
|
9
|
+
input: Record<string, unknown>;
|
|
10
|
+
key: string;
|
|
11
|
+
}, _optional?: {}): string | undefined;
|
|
12
|
+
/** Narrows the model's OWN `external_mcp_save` call input into {@link ExternalMcpSaveInput} — the
|
|
13
|
+
* shape `mergeExternalMcpSavePrefill`/`buildExternalMcpSaveForm` take to generate the form the
|
|
14
|
+
* human actually sees. `id` is normalized the same way `saveExternalMcpServer` itself normalizes
|
|
15
|
+
* it (trim + lowercase), so the existing-row lookup below matches what a prior save actually
|
|
16
|
+
* stored. @complexity O(1) — a fixed field list. */
|
|
17
|
+
export declare function buildModelSaveInput(input: Record<string, unknown>, { assertCredentialFreeField }: Pick<ExternalMcpToolDeps, "assertCredentialFreeField">): ExternalMcpSaveInput;
|
|
18
|
+
/**
|
|
19
|
+
* Maps the human's SUBMITTED form (`answer.params`, already past the `received`/dismissed checks)
|
|
20
|
+
* onto {@link SaveExternalMcpServerInput} — `saveExternalMcpServer`'s own input shape.
|
|
21
|
+
*
|
|
22
|
+
* `enabled: true` always: `save-form.ts`'s rendered fields never include an enabled toggle (this
|
|
23
|
+
* tool's job is "connect a server", not "flip one that already exists off/on"), so every save this
|
|
24
|
+
* tool ever performs both creates and enables, or re-enables, the row — matching the admin PUT
|
|
25
|
+
* route's own default (`enabled: body.enabled !== false`) for the identical "caller sent nothing"
|
|
26
|
+
* case. `writeAllowedToolNames` is read from the submitted form the same tri-state way
|
|
27
|
+
* `allowedToolNames` is (`optionalStringField(params, ...) ?? ""`) — see `save-form.ts`'s
|
|
28
|
+
* `writeAllowedToolNames` field/`mergeExternalMcpSavePrefill` for the field this reads and its
|
|
29
|
+
* prefill-from-existing-row behavior. 2026-09-08 fix: this used to hardcode `""` unconditionally,
|
|
30
|
+
* silently dropping every write grant on any save performed through the assistant — this domain's
|
|
31
|
+
* form now has the field `SaveExternalMcpServerInput`'s own doc always assumed an un-migrated caller
|
|
32
|
+
* would eventually grow (ADS-memory/reports/2026-09-08-dock-recovery-product-test.md).
|
|
33
|
+
*
|
|
34
|
+
* @complexity O(1) — a fixed field list.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildSaveExternalMcpServerInputFromFormParams({ params, workspaceId, principalId }: {
|
|
37
|
+
params: Record<string, unknown>;
|
|
38
|
+
workspaceId: UUID;
|
|
39
|
+
principalId: string;
|
|
40
|
+
}, _optional?: {}): SaveExternalMcpServerInput;
|
|
41
|
+
//# sourceMappingURL=save-input.d.ts.map
|