@jini-ai/mcp 0.7.2 → 0.7.3-next.2

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 (146) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/agent-install/antigravity/install.d.ts +15 -0
  3. package/dist/agent-install/antigravity/install.js +15 -0
  4. package/dist/agent-install/claude/install.d.ts +4 -0
  5. package/dist/agent-install/claude/install.js +11 -0
  6. package/dist/agent-install/cline/install.d.ts +4 -0
  7. package/dist/agent-install/cline/install.js +7 -0
  8. package/dist/agent-install/codex/install.d.ts +4 -0
  9. package/dist/agent-install/codex/install.js +10 -0
  10. package/dist/agent-install/cursor/install.d.ts +4 -0
  11. package/dist/agent-install/cursor/install.js +4 -0
  12. package/dist/agent-install/hermes/install.d.ts +4 -0
  13. package/dist/agent-install/hermes/install.js +26 -0
  14. package/dist/agent-install/index.d.ts +1 -1
  15. package/dist/agent-install/install.d.ts +1 -11
  16. package/dist/agent-install/install.js +29 -167
  17. package/dist/agent-install/kimi/install.d.ts +4 -0
  18. package/dist/agent-install/kimi/install.js +10 -0
  19. package/dist/agent-install/openclaw/install.d.ts +4 -0
  20. package/dist/agent-install/openclaw/install.js +4 -0
  21. package/dist/agent-install/opencode/install.d.ts +4 -0
  22. package/dist/agent-install/opencode/install.js +7 -0
  23. package/dist/agent-install/owned-json-install.d.ts +7 -0
  24. package/dist/agent-install/owned-json-install.js +4 -4
  25. package/dist/agent-install/pi/install.d.ts +4 -0
  26. package/dist/agent-install/pi/install.js +13 -0
  27. package/dist/agent-install/planner-shared.d.ts +40 -0
  28. package/dist/agent-install/planner-shared.js +52 -0
  29. package/dist/agent-install/trae/install.d.ts +4 -0
  30. package/dist/agent-install/trae/install.js +7 -0
  31. package/dist/agent-install/vibe/install.d.ts +4 -0
  32. package/dist/agent-install/vibe/install.js +30 -0
  33. package/dist/bin/serve.js +5 -3
  34. package/dist/client/client.js +11 -7
  35. package/dist/core/claude/config.d.ts +21 -0
  36. package/dist/core/claude/config.js +29 -0
  37. package/dist/core/config-shared.d.ts +27 -0
  38. package/dist/core/config-shared.js +64 -0
  39. package/dist/core/config.d.ts +60 -81
  40. package/dist/core/config.js +33 -192
  41. package/dist/core/opencode/config.d.ts +39 -0
  42. package/dist/core/opencode/config.js +74 -0
  43. package/dist/core/tokens.d.ts +38 -25
  44. package/dist/core/tokens.js +23 -54
  45. package/dist/federation/adapter.http.d.ts +8 -5
  46. package/dist/federation/adapter.http.js +12 -8
  47. package/dist/federation/admissions.d.ts +36 -0
  48. package/dist/federation/admissions.js +34 -0
  49. package/dist/federation/approvals/call-confirmation.js +2 -2
  50. package/dist/federation/approvals/remembered-approval.d.ts +11 -2
  51. package/dist/federation/approvals/remembered-approval.js +11 -8
  52. package/dist/federation/approvals/revocation-reason.d.ts +3 -1
  53. package/dist/federation/approvals/revocation-reason.js +1 -1
  54. package/dist/federation/approvals/revocation.js +3 -3
  55. package/dist/federation/approvals/scope-option.d.ts +3 -1
  56. package/dist/federation/approvals/scope-option.js +1 -1
  57. package/dist/federation/bootstrap.d.ts +1 -1
  58. package/dist/federation/bootstrap.js +4 -5
  59. package/dist/federation/config.d.ts +1 -1
  60. package/dist/federation/hosted/access.d.ts +53 -1
  61. package/dist/federation/hosted/access.js +94 -0
  62. package/dist/federation/hosted/connection-gate.js +1 -1
  63. package/dist/federation/hosted/index.d.ts +11 -3
  64. package/dist/federation/hosted/index.js +9 -3
  65. package/dist/federation/hosted/pinned-capability.d.ts +91 -0
  66. package/dist/federation/hosted/pinned-capability.js +73 -0
  67. package/dist/federation/hosted/probe.d.ts +67 -0
  68. package/dist/federation/hosted/probe.js +99 -0
  69. package/dist/federation/hosted/revocation.d.ts +5 -2
  70. package/dist/federation/hosted/revocation.js +1 -1
  71. package/dist/federation/hosted/store-config.d.ts +43 -0
  72. package/dist/federation/hosted/store-config.js +209 -0
  73. package/dist/federation/hosted/store-credentials.d.ts +74 -0
  74. package/dist/federation/hosted/store-credentials.js +228 -0
  75. package/dist/federation/hosted/store-input.d.ts +55 -0
  76. package/dist/federation/hosted/store-input.js +232 -0
  77. package/dist/federation/hosted/store-oauth-fields.d.ts +26 -0
  78. package/dist/federation/hosted/store-oauth-fields.js +246 -0
  79. package/dist/federation/hosted/store-view.d.ts +49 -0
  80. package/dist/federation/hosted/store-view.js +112 -0
  81. package/dist/federation/hosted/store.d.ts +13 -180
  82. package/dist/federation/hosted/store.js +33 -1252
  83. package/dist/federation/hosted/store.memory.d.ts +26 -1
  84. package/dist/federation/hosted/store.memory.js +71 -22
  85. package/dist/federation/hosted/store.save.d.ts +39 -0
  86. package/dist/federation/hosted/store.save.js +63 -0
  87. package/dist/federation/hosted/vault.d.ts +79 -1
  88. package/dist/federation/hosted/vault.js +107 -0
  89. package/dist/federation/hosted/vocabulary.d.ts +1 -1
  90. package/dist/federation/hosted/vocabulary.js +1 -1
  91. package/dist/federation/index.d.ts +1 -0
  92. package/dist/federation/index.js +1 -0
  93. package/dist/federation/mcp-protocol.d.ts +1 -1
  94. package/dist/federation/mcp-protocol.js +1 -1
  95. package/dist/federation/ports.d.ts +2 -2
  96. package/dist/federation/refusal-notice.d.ts +1 -1
  97. package/dist/federation/refusal-notice.js +1 -1
  98. package/dist/federation/registrations.d.ts +6 -6
  99. package/dist/federation/registrations.js +1 -1
  100. package/dist/federation/reload.js +37 -36
  101. package/dist/federation/stdio/adapter.stdio.js +27 -20
  102. package/dist/federation/stdio/default-connect.d.ts +2 -5
  103. package/dist/federation/stdio/default-connect.js +2 -1
  104. package/dist/federation/stdio/index.d.ts +1 -0
  105. package/dist/federation/stdio/index.js +1 -0
  106. package/dist/federation/stdio/smoke.d.ts +62 -0
  107. package/dist/federation/stdio/smoke.js +156 -0
  108. package/dist/federation/trust.d.ts +2 -2
  109. package/dist/federation/trust.js +4 -4
  110. package/dist/index.d.ts +3 -4
  111. package/dist/index.js +1 -1
  112. package/dist/server/adapters/sdk-server.d.ts +88 -0
  113. package/dist/server/adapters/sdk-server.js +27 -0
  114. package/dist/server/{sdk-transport.d.ts → adapters/sdk-transport.d.ts} +3 -3
  115. package/dist/server/{sdk-transport.js → adapters/sdk-transport.js} +2 -2
  116. package/dist/server/adapters/sdk-wire.d.ts +16 -0
  117. package/dist/server/adapters/sdk-wire.js +16 -0
  118. package/dist/server/call-progress.d.ts +48 -0
  119. package/dist/server/call-progress.js +60 -0
  120. package/dist/server/http-tool-server.adapter.js +209 -196
  121. package/dist/server/index.d.ts +1 -0
  122. package/dist/server/loopback-fetch.d.ts +5 -0
  123. package/dist/server/loopback-fetch.js +48 -0
  124. package/dist/server/resource-protocol.d.ts +1 -1
  125. package/dist/server/run-tool-host.js +3 -1
  126. package/dist/server/stdio-hosting.d.ts +8 -12
  127. package/dist/server/stdio-hosting.js +135 -126
  128. package/dist/server/tool-arguments.d.ts +9 -1
  129. package/dist/server/tool-arguments.js +18 -4
  130. package/dist/server/tool-protocol.d.ts +15 -3
  131. package/dist/server/tool-protocol.js +18 -21
  132. package/dist/server/tool-result-pages.js +37 -28
  133. package/dist/server/tool-server.d.ts +8 -46
  134. package/dist/server/tool-server.js +138 -128
  135. package/dist/server/tools/component-catalog-tools.d.ts +2 -2
  136. package/dist/server/tools/component-catalog-tools.js +2 -2
  137. package/dist/server/tools/delegated-tool.js +74 -57
  138. package/dist/server/tools/run-tools.d.ts +5 -5
  139. package/dist/server/tools/run-tools.js +5 -5
  140. package/dist/server/tools/tool-catalog-tools.d.ts +2 -2
  141. package/dist/server/tools/tool-catalog-tools.js +35 -12
  142. package/package.json +8 -9
  143. package/dist/core/oauth.d.ts +0 -274
  144. package/dist/core/oauth.js +0 -667
  145. package/dist/core/secure-write.d.ts +0 -17
  146. package/dist/core/secure-write.js +0 -72
@@ -1,24 +1,12 @@
1
- import type { ExternalMcpApprovedAccess } from "@jini-ai/core/contracts/hosted-mcp";
2
- import type { ExternalMcpServerRepoPort, ExternalMcpServerRecord, ExternalMcpServerConfig, ExternalMcpServerView, ExternalMcpStoreDeps, ExternalMcpOAuthTokenResolverPort, SaveExternalMcpServerInput, ExternalMcpSealedOAuthPayload, SealedExternalMcpOAuth } from "@jini-ai/core/contracts/hosted-mcp";
1
+ import type { UUID } from "@jini-ai/core/primitives";
2
+ import type { ExternalMcpApprovedAccess, ExternalMcpServerRepoPort, ExternalMcpServerView, ExternalMcpStoreDeps, SaveExternalMcpServerInput } from "@jini-ai/core/contracts/hosted-mcp";
3
3
  import type { HostedMcpStorePorts, HostedMcpTokenHint } from "./store-ports.js";
4
- import { type UUID } from "@jini-ai/core/primitives";
5
- import type { SecretSealerPort } from "@jini-ai/core/contracts/vault";
6
- import { type ResolvedFederatedConnection } from "../config.js";
7
- /** One stored row. `sealedEnv` is null when the server needs no credentials, which is normal. */
8
- /** Compatibility DTO version for normalized vault envelopes; historical formats live in recovery. */
9
- export declare const EXTERNAL_MCP_VAULT_VERSION = 1;
10
- type ExternalMcpIdentity = {
11
- workspaceId: string;
12
- serverId: string;
13
- };
4
+ /** `EXTERNAL_MCP_AUTH_MODES`/`ExternalMcpAuthMode` (how a server's credentials are obtained) and
5
+ * their two readers live in the shared `auth.ts` leaf, so every
6
+ * consumer reads the same mode vocabulary. */
14
7
  /** Per-call deps plus the host-bound store ports. */
15
8
  /** @agent-note `repo/sealer/keyring/clock` are per call; every other member is bound once by the host. `repo` must be the same repository object whose envelopes `./vault.js` built. */
16
9
  export type HostedMcpStoreDeps = ExternalMcpStoreDeps & HostedMcpStorePorts;
17
- type SealDeps = Pick<ExternalMcpStoreDeps, "sealer" | "keyring"> & HostedMcpStorePorts;
18
- type OpenDeps = {
19
- sealer: Pick<SecretSealerPort, "open">;
20
- } & HostedMcpStorePorts;
21
- type CredentialPorts = Pick<HostedMcpStorePorts, "assertFreeField" | "credential">;
22
10
  /** Validate exact approved access, then conditionally replace only the access columns.
23
11
  * @throws ExternalMcpValidationError for invalid names/subsets; ToolInputError if the source changed.
24
12
  * @complexity O(a+w) in at most 64 tool names per list, one conditional repository operation.
@@ -27,173 +15,19 @@ export declare function applyExternalMcpAccess({ repo, clock, workspaceId, serve
27
15
  repo: Pick<ExternalMcpServerRepoPort, 'updateAccessIfCurrent'>;
28
16
  clock: ExternalMcpStoreDeps['clock'];
29
17
  }, _options?: {}): Promise<void>;
30
- /** @agent-note `ports` are the host-bound credential rules (length cap, messages, secret-in-plain-field check). */
31
- export declare function parseEnvBlock(text: string, ports: CredentialPorts): Record<string, string>;
32
- /**
33
- * Splits an operator's space-separated argv string.
34
- *
35
- * One quoting rule, and only one: a token that STARTS with `"` runs to the next `"`, which must end
36
- * the token (whitespace or end of string after it), and both quotes are dropped. That is what lets a
37
- * path with a space in it — `"C:\\Users\\John Smith\\..."`, the desktop shell's win32
38
- * registration — arrive as one argument. There are no escapes (a backslash is always literal, since
39
- * Windows paths are full of them), and a `"` anywhere else in a token stays literal exactly as it did
40
- * before this rule existed, so `--name="x"` still reaches the child unchanged. This is NOT shell
41
- * quoting: the command is spawned WITHOUT a shell (`adapter.stdio.ts` uses `spawn` with an argv
42
- * array), and nothing else a shell would do happens here.
43
- *
44
- * @throws {ExternalMcpValidationError} On an unterminated quoted token, a closing quote followed by
45
- * more characters, or more than `MAX_ARGS` arguments.
46
- * @complexity O(n) in the string length.
47
- */
48
- export declare function parseArgs(raw: string): string[];
49
- /**
50
- * Splits an operator's comma-separated allowlist of remote tool names.
51
- *
52
- * @throws {ExternalMcpValidationError} See {@link parseToolNameList}. `field` is `"allowedToolNames"`.
53
- * @complexity O(n) in the number of names.
54
- * @overallScore 100
55
- */
56
- export declare function parseAllowedToolNames(raw: string): string[];
57
- /**
58
- * Splits an operator's comma-separated list of remote tool names separately authorized to write —
59
- * `trust.ts` R3's override, checked only after {@link parseAllowedToolNames}'s allowlist passes (see
60
- * {@link assertWriteAllowlistSubset}).
61
- *
62
- * @throws {ExternalMcpValidationError} See {@link parseToolNameList}. `field` is
63
- * `"writeAllowedToolNames"`.
64
- * @complexity O(n) in the number of names.
65
- * @overallScore 100
66
- */
67
- export declare function parseWriteAllowedToolNames(raw: string): string[];
68
18
  /**
69
- * Whether this row holds an access TOKEN — answered from PLAINTEXT columns alone, never by unsealing.
70
- *
71
- * Token clearing preserves the client secret sharing the sealed blob (setOAuthStatus). A
72
- * disconnected row can therefore have a non-null blob containing a secret but no access token;
73
- * blob presence alone cannot answer this question.
19
+ * Validates and persists one server, sealing its env block.
74
20
  *
75
- * Not repaired by unsealing, deliberately. This is read by a plain list route that must answer
76
- * without a keyring round trip, and must keep answering TRUTHFULLY for a row whose blob will not
77
- * open at all: a rotated site key, or a legacy `aad_version 0` ciphertext. A decrypt here would turn
78
- * either into a failed settings tab, and would put a keyring dependency on a read path that has
79
- * never had one.
21
+ * `env: undefined` preserves whatever is already stored, which is what lets the tab patch `enabled`
22
+ * or `label` without the operator re-typing credentials the UI never sent them. `env: ""` is the
23
+ * distinct, explicit "clear the credentials" instruction — the same unset-vs-empty distinction
24
+ * `../config.ts` draws for allowlists, and for the same reason.
80
25
  *
81
- * The blob check leads because it is the NECESSARY condition — no blob, no token, whatever the
82
- * plaintext says. Each of the two disjuncts after it is independently SUFFICIENT, which is what
83
- * makes a false positive unreachable:
84
- *
85
- * - `connected` is written by exactly one place, `persistTokens`, and that same upsert writes the
86
- * tokens. Every path that clears a token moves the row off `connected` in the same write.
87
- * - `oauthExpiresAt` is written beside the tokens by that same `persistTokens`, and nulled by every
88
- * clear (`setOAuthStatus`'s `clearToken` branch) and by every save that invalidates the token
89
- * ({@link carryOAuthRuntimeState}), so a non-null expiry cannot outlive the token it describes.
90
- *
91
- * @returns `true` only when a token is stored. The single state it can UNDER-report is a token
92
- * issued with no `expires_in` — RFC 6749 §5.1 makes it optional and the OAuth token endpoint stores `null` rather than fabricating one — on a row that has since moved off `connected`
93
- * without its token being cleared: a re-connect left `pending`, or a terminal device-poll failure.
94
- * Under-reporting is the safe direction, and closing it exactly needs a plaintext token-presence
95
- * column, which is a schema change rather than a read fix.
96
- * @complexity O(1) — three field reads, no I/O.
97
- */
98
- export declare function externalMcpRecordHasStoredToken(record: Pick<ExternalMcpServerRecord, "sealedOAuth" | "oauthStatus" | "oauthExpiresAt">): boolean;
99
- /**
100
- * Lists the workspace's servers for the admin tab. The tab has no use for env
101
- * values and must not be a route that decrypts them. Token hints alone are now derived by
102
- * server-side unsealing, per the owner decision; no secret value is returned.
103
- *
104
- * @complexity O(n) in the stored server count.
26
+ * @throws {ExternalMcpValidationError} On any invalid operator input.
27
+ * @throws {ExternalMcpSecretStoreUnconfiguredError} When no site key is available to seal under.
28
+ * @complexity O(n) in the size of the env block.
105
29
  * @overallScore 100
106
30
  */
107
- export declare function listExternalMcpServerViews(deps: Pick<ExternalMcpStoreDeps, "repo"> & Partial<Pick<ExternalMcpStoreDeps, "sealer">> & HostedMcpStorePorts, workspaceId: UUID): Promise<ExternalMcpServerView<HostedMcpTokenHint>[]>;
108
- export declare function readEnabledExternalMcpConfigs(deps: Pick<ExternalMcpStoreDeps, "repo" | "sealer"> & {
109
- oauth?: ExternalMcpOAuthTokenResolverPort;
110
- } & HostedMcpStorePorts, workspaceId: UUID): Promise<{
111
- configs: ExternalMcpServerConfig[];
112
- failures: {
113
- serverId: string;
114
- reason: string;
115
- }[];
116
- }>;
117
- /**
118
- * Maps stored configs onto the shape `../bootstrap.ts` consumes.
119
- *
120
- * Timeouts and caps come from core's shared `FEDERATED_CONNECTION_DEFAULTS` rather than being
121
- * stored per server: they are policy about how much a third party may cost this process, which is
122
- * the host's call and not an operator preference. `allowedToolNames` is the one field that IS the
123
- * operator's, and it is passed through untouched for `trust.ts` to enforce.
124
- *
125
- * @param readOnlyRemoteNamesByServer - Reviewed manifest lists matched by the roster source;
126
- * never inferred from remote annotations or the tool admission allowlist.
127
- * @complexity O(n) time and output space in the config count.
128
- */
129
- export declare function toResolvedFederatedConnections(configs: readonly ExternalMcpServerConfig[], readOnlyRemoteNamesByServer?: ReadonlyMap<string, ReadonlySet<string>>): ResolvedFederatedConnection[];
130
- /**
131
- * Splits an operator's comma- or space-separated OAuth scope list.
132
- *
133
- * An empty result is legitimate — several providers infer scope from the client registration — so it
134
- * is returned rather than rejected, the same call {@link parseAllowedToolNames} makes.
135
- *
136
- * @throws {ExternalMcpValidationError} Past {@link MAX_OAUTH_SCOPES}.
137
- * @complexity O(n) in the number of scopes.
138
- */
139
- export declare function parseOAuthScopes(raw: string): string[];
140
- /**
141
- * What the OAuth sealed blob holds.
142
- *
143
- * ONE blob rather than a column per secret, for exactly the reason the env block is one blob: every
144
- * read path wants the whole thing at once, and per-secret sealing would buy nothing and cost N
145
- * keyring round trips. The consequence is a READ-MODIFY-WRITE rule that every writer must honour —
146
- * unseal, change one member, reseal — because a writer that seals `{ tokens }` alone silently
147
- * deletes the operator's client secret.
148
- *
149
- * Structurally compatible with the OAuth client's `OAuthTokenSet`, but declared here rather than
150
- * imported: this is the STORED shape, and it must be able to stay still while the flow module's
151
- * in-memory type moves.
152
- */
153
- /**
154
- * Schema version of the *plaintext* inside the sealed OAuth blob.
155
- *
156
- * Distinct from `oauth_aad_version`, which versions how the blob is BOUND to its row and says
157
- * nothing about what is inside it. Without this, a field could be added but never renamed, changed,
158
- * or removed — there would be nothing to branch on at open time, and the only way out would be a
159
- * migration over live credentials. Stamped at seal; a blob without it predates versioning and is
160
- * upgraded on read.
161
- */
162
- export declare const EXTERNAL_MCP_OAUTH_PAYLOAD_VERSION = 1;
163
- /**
164
- * The branching read for a sealed OAuth payload. A missing version is v0 (pre-versioning) and is
165
- * upgraded in place; a newer version is refused rather than misread, because silently
166
- * reinterpreting an unknown shape here means handing back a wrong or partial live credential.
167
- *
168
- * `schemaVersion` is stripped from the result: it is a wire concern, and a caller that saw it could
169
- * persist it back into a payload it does not own.
170
- *
171
- * The vault's open already refuses a non-object payload, so `parsed` is always an object here.
172
- *
173
- * @throws When the payload was written by a newer build than this one understands.
174
- * @complexity O(1).
175
- */
176
- export declare function hydrateExternalMcpOAuthPayload(parsed: Record<string, unknown>): ExternalMcpSealedOAuthPayload;
177
- /**
178
- * Opens a row's sealed OAuth blob.
179
- *
180
- * @returns `{}` when the row holds none, which is the normal state before a connection is authorized.
181
- * @throws {ExternalMcpSecretStoreUnconfiguredError} When the blob exists but cannot be opened — a
182
- * rotated site key or a corrupt row. Distinct from "no blob" on purpose: the caller must not treat a
183
- * decryption failure as "not connected yet" and start a fresh authorization over a token that is
184
- * still live at the provider.
185
- * @complexity O(1) — one unseal.
186
- */
187
- /** @agent-note `deps` is the per-call sealer plus the host-bound ports; exactly one `sealer.open` per call. */
188
- export declare function openExternalMcpOAuthPayload(deps: OpenDeps, record: Pick<ExternalMcpServerRecord, "sealedOAuth" | "workspaceId" | "serverId" | "oauthAadVersion">): Promise<ExternalMcpSealedOAuthPayload>;
189
- /** @agent-note `deps` is the per-call sealer/keyring plus the host-bound ports; exactly one seal, the envelope is staged for the host repository's transaction. */
190
- export declare function sealExternalMcpOAuthPayload(deps: SealDeps, identity: ExternalMcpIdentity, payload: ExternalMcpSealedOAuthPayload): Promise<SealedExternalMcpOAuth>;
191
- /** @agent-note `credential` is the host-bound token policy; its input errors become the canonical validation error with the same message and field. */
192
- export declare function normalizeExternalMcpAccessToken({ value, transport, credential }: {
193
- value: unknown;
194
- transport: string;
195
- credential: HostedMcpStorePorts["credential"];
196
- }, _optional?: {}): string;
197
31
  /** @agent-note `deps.repo` is the host repository whose transaction commits the staged envelopes with the row pointers; seal order, id timing and the carried-envelope rule are unchanged. */
198
32
  export declare function saveExternalMcpServer(deps: HostedMcpStoreDeps, input: SaveExternalMcpServerInput): Promise<ExternalMcpServerView<HostedMcpTokenHint>>;
199
33
  /**
@@ -207,5 +41,4 @@ export declare function deleteExternalMcpServer(deps: Pick<ExternalMcpStoreDeps,
207
41
  workspaceId: UUID;
208
42
  serverId: string;
209
43
  }): Promise<boolean>;
210
- export {};
211
44
  //# sourceMappingURL=store.d.ts.map