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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) 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
package/CHANGELOG.md CHANGED
@@ -197,7 +197,7 @@
197
197
 
198
198
  ### Patch Changes
199
199
 
200
- - Tovu clean-up release (2026-10-08): code Tovu moved into Jini, plus the Jini clean-up (see the commit log since 0.4.1).
200
+ - Host clean-up release (2026-10-08): code the first host moved into Jini, plus the Jini clean-up (see the commit log since 0.4.1).
201
201
 
202
202
  ## 0.4.1 — 2026-10-06
203
203
 
@@ -0,0 +1,15 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ /**
4
+ * Home-relative path of the MCP registry the `agy` CLI actually reads:
5
+ * `~/.gemini/config/mcp_config.json` (verified live; see the
6
+ * `externalMcpInjection` comment in `@jini-ai/agent-runtime`'s
7
+ * `packages/agent-runtime/src/defs/antigravity/index.ts`). NOT `~/.gemini/antigravity/mcp_config.json`: that
8
+ * file only works on machines where the Antigravity IDE happened to symlink it
9
+ * to this one, and on a machine without that symlink the bridge entry would
10
+ * never reach `agy`. Planning only this path also means a regular-file
11
+ * `antigravity/mcp_config.json` (the IDE's own) is never touched.
12
+ */
13
+ export declare const ANTIGRAVITY_MCP_CONFIG_SEGMENTS: readonly [".gemini", "config", "mcp_config.json"];
14
+ export declare const planAntigravityInstall: (args: PlannerArgs) => InstallPlan;
15
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,15 @@
1
+ import path from 'node:path';
2
+ import { jsonEntry, jsonPlan } from '../planner-shared.js';
3
+ /**
4
+ * Home-relative path of the MCP registry the `agy` CLI actually reads:
5
+ * `~/.gemini/config/mcp_config.json` (verified live; see the
6
+ * `externalMcpInjection` comment in `@jini-ai/agent-runtime`'s
7
+ * `packages/agent-runtime/src/defs/antigravity/index.ts`). NOT `~/.gemini/antigravity/mcp_config.json`: that
8
+ * file only works on machines where the Antigravity IDE happened to symlink it
9
+ * to this one, and on a machine without that symlink the bridge entry would
10
+ * never reach `agy`. Planning only this path also means a regular-file
11
+ * `antigravity/mcp_config.json` (the IDE's own) is never touched.
12
+ */
13
+ export const ANTIGRAVITY_MCP_CONFIG_SEGMENTS = ['.gemini', 'config', 'mcp_config.json'];
14
+ export const planAntigravityInstall = ({ spec, ctx: { home, serverName } }) => jsonPlan({ slug: 'antigravity', configPath: path.join(home, ...ANTIGRAVITY_MCP_CONFIG_SEGMENTS), keyPath: ['mcpServers'], serverKey: serverName, entry: jsonEntry(spec) });
15
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planClaudeInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { envFlags, cliPlan } from '../planner-shared.js';
2
+ export const planClaudeInstall = ({ spec, ctx: { serverName } }) => cliPlan({ slug: 'claude', bin: 'claude', argv: {
3
+ addArgv: [
4
+ 'mcp', 'add', '--scope', 'user',
5
+ serverName,
6
+ ...envFlags({ env: spec.env, flag: '-e' }),
7
+ '--', spec.command, ...spec.args,
8
+ ],
9
+ removeArgv: ['mcp', 'remove', '--scope', 'user', serverName],
10
+ }, serverName });
11
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planClineInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,7 @@
1
+ import path from 'node:path';
2
+ import { jsonEntry, jsonPlan, editorUserDir } from '../planner-shared.js';
3
+ export const planClineInstall = ({ spec, ctx: { home, platform, serverName }, appData }) => jsonPlan({ slug: 'cline', configPath: clineConfigPath(home, platform, appData), keyPath: ['mcpServers'], serverKey: serverName, entry: jsonEntry(spec, { disabled: false, autoApprove: [] }) });
4
+ function clineConfigPath(home, platform, suppliedAppData) {
5
+ return path.join(editorUserDir({ app: 'Code', home, platform, suppliedAppData }), 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
6
+ }
7
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planCodexInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { envFlags, cliPlan } from '../planner-shared.js';
2
+ export const planCodexInstall = ({ spec, ctx: { serverName } }) => cliPlan({ slug: 'codex', bin: 'codex', argv: {
3
+ addArgv: [
4
+ 'mcp', 'add', serverName,
5
+ ...envFlags({ env: spec.env, flag: '--env' }),
6
+ '--', spec.command, ...spec.args,
7
+ ],
8
+ removeArgv: ['mcp', 'remove', serverName],
9
+ }, serverName });
10
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planCursorInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,4 @@
1
+ import path from 'node:path';
2
+ import { jsonEntry, jsonPlan } from '../planner-shared.js';
3
+ export const planCursorInstall = ({ spec, ctx: { home, serverName } }) => jsonPlan({ slug: 'cursor', configPath: path.join(home, '.cursor', 'mcp.json'), keyPath: ['mcpServers'], serverKey: serverName, entry: jsonEntry(spec, { type: 'stdio' }) });
4
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planHermesInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,26 @@
1
+ import path from 'node:path';
2
+ export const planHermesInstall = ({ spec, ctx: { home, serverName } }) => ({
3
+ kind: 'manual',
4
+ slug: 'hermes',
5
+ format: 'yaml',
6
+ configPath: path.join(home, '.hermes', 'config.yaml'),
7
+ snippet: hermesYamlSnippet(spec, serverName),
8
+ reason: 'Hermes config format is unverified. Add this under your Hermes ' +
9
+ 'MCP server configuration by hand.',
10
+ });
11
+ function hermesYamlSnippet(spec, name) {
12
+ const lines = [
13
+ 'mcp_servers:',
14
+ ` ${name}:`,
15
+ ` command: ${JSON.stringify(spec.command)}`,
16
+ ` args: ${JSON.stringify(spec.args)}`,
17
+ ];
18
+ if (Object.keys(spec.env).length > 0) {
19
+ lines.push(' env:');
20
+ for (const [k, v] of Object.entries(spec.env)) {
21
+ lines.push(` ${k}: ${JSON.stringify(v)}`);
22
+ }
23
+ }
24
+ return lines.join('\n');
25
+ }
26
+ //# sourceMappingURL=install.js.map
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export * from './install.js';
9
9
  export { CHROME_DEVTOOLS_MCP_PRESET } from './chrome-devtools.js';
10
- export { installOwnedJsonAgent } from './owned-json-install.js';
10
+ export { installOwnedJsonAgent, type OwnedJsonInstallFiles } from './owned-json-install.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -5,6 +5,7 @@
5
5
  * the CLI/JSON/manual install-plan shapes, and the JSON apply/remove primitives.
6
6
  * Pure planning logic; imports no sibling MCP subdirectory.
7
7
  */
8
+ export { ANTIGRAVITY_MCP_CONFIG_SEGMENTS } from './antigravity/install.js';
8
9
  /**
9
10
  * Exhaustive tuple of all agent slugs recognized by `mcp install`.
10
11
  * Used as the source of truth for the `AgentSlug` union type and the `isAgentSlug` guard.
@@ -78,17 +79,6 @@ export interface ManualInstallPlan {
78
79
  }
79
80
  /** Discriminated union of all installation plan shapes returned by `planAgentInstall`. */
80
81
  export type InstallPlan = CliInstallPlan | JsonInstallPlan | ManualInstallPlan;
81
- /**
82
- * Home-relative path of the MCP registry the `agy` CLI actually reads:
83
- * `~/.gemini/config/mcp_config.json` (verified live; see the
84
- * `externalMcpInjection` comment in `@jini-ai/agent-runtime`'s
85
- * `defs/antigravity.ts`). NOT `~/.gemini/antigravity/mcp_config.json`: that
86
- * file only works on machines where the Antigravity IDE happened to symlink it
87
- * to this one, and on a machine without that symlink the bridge entry would
88
- * never reach `agy`. Planning only this path also means a regular-file
89
- * `antigravity/mcp_config.json` (the IDE's own) is never touched.
90
- */
91
- export declare const ANTIGRAVITY_MCP_CONFIG_SEGMENTS: readonly [".gemini", "config", "mcp_config.json"];
92
82
  /**
93
83
  * Build the registration plan for one agent. Pure — all IO happens in the
94
84
  * executor. Throws on an unknown slug so callers surface a clear error.
@@ -31,8 +31,20 @@
31
31
  //
32
32
  // The planning functions are pure (no fs / spawn) so they unit-test
33
33
  // against fixed launch specs + a fake home dir; the executor performs the IO.
34
- import path from 'node:path';
35
34
  import { isDeepStrictEqual } from 'node:util';
35
+ import { planClaudeInstall } from './claude/install.js';
36
+ import { planCodexInstall } from './codex/install.js';
37
+ import { planKimiInstall } from './kimi/install.js';
38
+ import { planCursorInstall } from './cursor/install.js';
39
+ import { planClineInstall } from './cline/install.js';
40
+ import { planOpencodeInstall } from './opencode/install.js';
41
+ import { planOpenclawInstall } from './openclaw/install.js';
42
+ import { planAntigravityInstall } from './antigravity/install.js';
43
+ import { planTraeInstall } from './trae/install.js';
44
+ import { planVibeInstall } from './vibe/install.js';
45
+ import { planPiInstall } from './pi/install.js';
46
+ import { planHermesInstall } from './hermes/install.js';
47
+ export { ANTIGRAVITY_MCP_CONFIG_SEGMENTS } from './antigravity/install.js';
36
48
  /**
37
49
  * Exhaustive tuple of all agent slugs recognized by `mcp install`.
38
50
  * Used as the source of truth for the `AgentSlug` union type and the `isAgentSlug` guard.
@@ -60,127 +72,21 @@ export const AGENT_SLUGS = [
60
72
  export function isAgentSlug(args) {
61
73
  return AGENT_SLUGS.includes(args.value);
62
74
  }
63
- // RESIDUAL RISK (CR-006 / SEC-RB-002): `-e`/`--env KEY=VALUE` is claude's,
64
- // codex's, and kimi's own documented `mcp add` CLI contract for passing
65
- // server env vars — a fixed, external interface this package does not
66
- // control and cannot change unilaterally. Because these values land in
67
- // `addArgv` (argv), they are visible to any other local process that can
68
- // list this process's command line (e.g. `ps -ww`) for the — typically very
69
- // brief — window while the daemon's executor shells out to `claude`/`codex`/
70
- // `kimi mcp add`. This package only builds the plan (`planAgentInstall`
71
- // itself performs no fs/spawn, per this file's header comment); there is no
72
- // executor here yet to redact `addArgv` before logging it, so there is
73
- // nothing left in this package's own code to redact. Whichever executor
74
- // eventually drives these plans MUST NOT log/echo `addArgv` verbatim
75
- // (redact anything that looks like an env value from `-e`/`--env` pairs
76
- // before writing it to any log/error surface), and should prefer a
77
- // less-exposed handoff (e.g. piping `env` via stdin, or setting it directly
78
- // in the spawned child's environment) for any future agent whose CLI
79
- // supports that instead of argv-only `KEY=VALUE`.
80
- function envFlags(env, flag) {
81
- const out = [];
82
- for (const [k, v] of Object.entries(env)) {
83
- out.push(flag, `${k}=${v}`);
84
- }
85
- return out;
86
- }
87
- // Attaches the env map under `key` only when non-empty, so configs stay clean.
88
- function withEnv(entry, env, key) {
89
- if (Object.keys(env).length > 0)
90
- entry[key] = env;
91
- return entry;
92
- }
93
- /** JSON server entry shared by the `env`-style agents (cursor /
94
- * cline / openclaw / antigravity / trae). `extra` carries per-agent
95
- * fields; env is only attached when non-empty so configs stay clean. */
96
- function jsonEntry(spec, extra = {}) {
97
- return withEnv({ command: spec.command, args: spec.args, ...extra }, spec.env, 'env');
98
- }
99
- /**
100
- * Home-relative path of the MCP registry the `agy` CLI actually reads:
101
- * `~/.gemini/config/mcp_config.json` (verified live; see the
102
- * `externalMcpInjection` comment in `@jini-ai/agent-runtime`'s
103
- * `defs/antigravity.ts`). NOT `~/.gemini/antigravity/mcp_config.json`: that
104
- * file only works on machines where the Antigravity IDE happened to symlink it
105
- * to this one, and on a machine without that symlink the bridge entry would
106
- * never reach `agy`. Planning only this path also means a regular-file
107
- * `antigravity/mcp_config.json` (the IDE's own) is never touched.
108
- */
109
- export const ANTIGRAVITY_MCP_CONFIG_SEGMENTS = ['.gemini', 'config', 'mcp_config.json'];
110
- function cliPlan(slug, bin, argv, serverName) {
111
- return { kind: 'cli', slug, bin, ...argv, getArgv: ['mcp', 'get', serverName] };
112
- }
113
- function jsonPlan(slug, configPath, keyPath, serverKey, entry) {
114
- return { kind: 'json', slug, configPath, keyPath, serverKey, entry };
115
- }
116
75
  // One planner per slug. Typed as a total map over `AgentSlug`, so adding a slug
117
76
  // without a planner is a compile error (the role the old switch's `never` default played).
118
77
  const AGENT_PLANNERS = {
119
- // ----- CLI-driven agents (idempotent via the agent's own tool) -----
120
- claude: ({ spec, ctx: { serverName } }) => cliPlan('claude', 'claude', {
121
- addArgv: [
122
- 'mcp', 'add', '--scope', 'user',
123
- serverName,
124
- ...envFlags(spec.env, '-e'),
125
- '--', spec.command, ...spec.args,
126
- ],
127
- removeArgv: ['mcp', 'remove', '--scope', 'user', serverName],
128
- }, serverName),
129
- codex: ({ spec, ctx: { serverName } }) => cliPlan('codex', 'codex', {
130
- addArgv: [
131
- 'mcp', 'add', serverName,
132
- ...envFlags(spec.env, '--env'),
133
- '--', spec.command, ...spec.args,
134
- ],
135
- removeArgv: ['mcp', 'remove', serverName],
136
- }, serverName),
137
- kimi: ({ spec, ctx: { serverName } }) => cliPlan('kimi', 'kimi', {
138
- addArgv: [
139
- 'mcp', 'add', '--transport', 'stdio',
140
- ...envFlags(spec.env, '--env'),
141
- serverName, '--', spec.command, ...spec.args,
142
- ],
143
- removeArgv: ['mcp', 'remove', serverName],
144
- }, serverName),
145
- // ----- JSON config-file agents (safe deep-merge) -----
146
- cursor: ({ spec, ctx: { home, serverName } }) => jsonPlan('cursor', path.join(home, '.cursor', 'mcp.json'), ['mcpServers'], serverName, jsonEntry(spec, { type: 'stdio' })),
147
- cline: ({ spec, ctx: { home, platform, serverName }, appData }) => jsonPlan('cline', clineConfigPath(home, platform, appData), ['mcpServers'], serverName, jsonEntry(spec, { disabled: false, autoApprove: [] })),
148
- // OpenCode nests under `mcp`, folds command+args into one array,
149
- // and gates the server with `enabled`.
150
- opencode: ({ spec, ctx: { home, serverName } }) => jsonPlan('opencode', path.join(home, '.config', 'opencode', 'opencode.json'), ['mcp'], serverName, withEnv({ type: 'local', command: [spec.command, ...spec.args], enabled: true }, spec.env, 'environment')),
151
- openclaw: ({ spec, ctx: { home, serverName } }) => jsonPlan('openclaw', path.join(home, '.openclaw', 'openclaw.json'), ['mcp', 'servers'], serverName, jsonEntry(spec)),
152
- antigravity: ({ spec, ctx: { home, serverName } }) => jsonPlan('antigravity', path.join(home, ...ANTIGRAVITY_MCP_CONFIG_SEGMENTS), ['mcpServers'], serverName, jsonEntry(spec)),
153
- trae: ({ spec, ctx: { home, platform, serverName }, appData }) => jsonPlan('trae', traeConfigPath(home, platform, appData), ['mcpServers'], serverName, jsonEntry(spec)),
154
- // ----- Unverified formats: print-only, never write -----
155
- vibe: ({ spec, ctx: { home, serverName } }) => ({
156
- kind: 'manual',
157
- slug: 'vibe',
158
- format: 'toml',
159
- configPath: path.join(home, '.vibe', 'config.toml'),
160
- snippet: vibeTomlSnippet({ spec, name: serverName }),
161
- reason: 'Vibe uses a TOML array-of-tables ([[mcp_servers]]); ' +
162
- 'its exact schema is unverified, so append this block by hand ' +
163
- 'to avoid corrupting an existing config.',
164
- }),
165
- pi: ({ spec, ctx: { home, serverName } }) => ({
166
- kind: 'manual',
167
- slug: 'pi',
168
- format: 'json',
169
- configPath: path.join(home, '.pi', 'agent', 'mcp.json'),
170
- snippet: JSON.stringify({ mcpServers: { [serverName]: jsonEntry(spec) } }, null, 2),
171
- reason: 'The pi coding agent exposes MCP, but its config path/schema is ' +
172
- 'not authoritatively documented. Paste this into pi’s MCP ' +
173
- 'config (check `pi --help` for the exact location).',
174
- }),
175
- hermes: ({ spec, ctx: { home, serverName } }) => ({
176
- kind: 'manual',
177
- slug: 'hermes',
178
- format: 'yaml',
179
- configPath: path.join(home, '.hermes', 'config.yaml'),
180
- snippet: hermesYamlSnippet(spec, serverName),
181
- reason: 'Hermes config format is unverified. Add this under your Hermes ' +
182
- 'MCP server configuration by hand.',
183
- }),
78
+ claude: planClaudeInstall,
79
+ codex: planCodexInstall,
80
+ kimi: planKimiInstall,
81
+ cursor: planCursorInstall,
82
+ cline: planClineInstall,
83
+ opencode: planOpencodeInstall,
84
+ openclaw: planOpenclawInstall,
85
+ antigravity: planAntigravityInstall,
86
+ trae: planTraeInstall,
87
+ vibe: planVibeInstall,
88
+ pi: planPiInstall,
89
+ hermes: planHermesInstall,
184
90
  };
185
91
  /**
186
92
  * Build the registration plan for one agent. Pure — all IO happens in the
@@ -194,20 +100,6 @@ export function planAgentInstall({ slug, spec, ctx }, { env = process.env } = {}
194
100
  }
195
101
  return AGENT_PLANNERS[slug]({ spec, ctx, appData: env.APPDATA });
196
102
  }
197
- // VS Code-family editors keep per-user state under one platform-specific root.
198
- function editorUserDir(app, home, platform, suppliedAppData) {
199
- if (platform === 'darwin')
200
- return path.join(home, 'Library', 'Application Support', app, 'User');
201
- if (platform === 'win32')
202
- return path.join(suppliedAppData ?? path.join(home, 'AppData', 'Roaming'), app, 'User');
203
- return path.join(home, '.config', app, 'User');
204
- }
205
- function clineConfigPath(home, platform, suppliedAppData) {
206
- return path.join(editorUserDir('Code', home, platform, suppliedAppData), 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
207
- }
208
- function traeConfigPath(home, platform, suppliedAppData) {
209
- return path.join(editorUserDir('Trae', home, platform, suppliedAppData), 'mcp.json');
210
- }
211
103
  // --- Pure JSON merge / removal (the heart of the 'json' strategy) -------
212
104
  // CR-007: `JsonInstallPlan` is a public shape and `applyJsonInstall` /
213
105
  // `removeJsonInstall` are public functions — a caller-supplied `keyPath`/
@@ -354,42 +246,12 @@ function installedLaunchMatches({ entry, expected }) {
354
246
  const wanted = expected;
355
247
  if (actual.disabled === true || actual.command !== wanted.command)
356
248
  return false;
249
+ return sameArgsAndEnv({ actual, wanted });
250
+ }
251
+ /** Args and env match by value; a missing list or map counts as empty. */
252
+ function sameArgsAndEnv({ actual, wanted }, _optional = {}) {
357
253
  if (JSON.stringify(actual.args ?? []) !== JSON.stringify(wanted.args ?? []))
358
254
  return false;
359
255
  return JSON.stringify(actual.env ?? {}) === JSON.stringify(wanted.env ?? {});
360
256
  }
361
- // --- Snippets for the manual (print-only) strategy ----------------------
362
- function hermesYamlSnippet(spec, name) {
363
- const lines = [
364
- 'mcp_servers:',
365
- ` ${name}:`,
366
- ` command: ${JSON.stringify(spec.command)}`,
367
- ` args: ${JSON.stringify(spec.args)}`,
368
- ];
369
- if (Object.keys(spec.env).length > 0) {
370
- lines.push(' env:');
371
- for (const [k, v] of Object.entries(spec.env)) {
372
- lines.push(` ${k}: ${JSON.stringify(v)}`);
373
- }
374
- }
375
- return lines.join('\n');
376
- }
377
- /** Render the launch command and environment as a Vibe TOML snippet without I/O.
378
- * @complexity O(n) time and space in the serialized launch spec length.
379
- */
380
- function vibeTomlSnippet({ spec, name }, _options = {}) {
381
- const argsToml = `[${spec.args.map((a) => JSON.stringify(a)).join(', ')}]`;
382
- const lines = [
383
- '[[mcp_servers]]',
384
- `name = ${JSON.stringify(name)}`,
385
- 'transport = "stdio"',
386
- `command = ${JSON.stringify(spec.command)}`,
387
- `args = ${argsToml}`,
388
- ];
389
- if (Object.keys(spec.env).length > 0) {
390
- const envToml = Object.entries(spec.env).map(([key, value]) => `${JSON.stringify(key)} = ${JSON.stringify(value)}`).join(', ');
391
- lines.push(`env = { ${envToml} }`);
392
- }
393
- return lines.join('\n');
394
- }
395
257
  //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planKimiInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { envFlags, cliPlan } from '../planner-shared.js';
2
+ export const planKimiInstall = ({ spec, ctx: { serverName } }) => cliPlan({ slug: 'kimi', bin: 'kimi', argv: {
3
+ addArgv: [
4
+ 'mcp', 'add', '--transport', 'stdio',
5
+ ...envFlags({ env: spec.env, flag: '--env' }),
6
+ serverName, '--', spec.command, ...spec.args,
7
+ ],
8
+ removeArgv: ['mcp', 'remove', serverName],
9
+ }, serverName });
10
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planOpenclawInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,4 @@
1
+ import path from 'node:path';
2
+ import { jsonEntry, jsonPlan } from '../planner-shared.js';
3
+ export const planOpenclawInstall = ({ spec, ctx: { home, serverName } }) => jsonPlan({ slug: 'openclaw', configPath: path.join(home, '.openclaw', 'openclaw.json'), keyPath: ['mcp', 'servers'], serverKey: serverName, entry: jsonEntry(spec) });
4
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planOpencodeInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,7 @@
1
+ import path from 'node:path';
2
+ import { withEnv, jsonPlan } from '../planner-shared.js';
3
+ // OpenCode nests under `mcp`, folds command+args into one array,
4
+ // and gates the server with `enabled`.
5
+ export const planOpencodeInstall = ({ spec, ctx: { home, serverName } }) => jsonPlan({ slug: 'opencode', configPath: path.join(home, '.config', 'opencode', 'opencode.json'), keyPath: ['mcp'], serverKey: serverName,
6
+ entry: withEnv({ entry: { type: 'local', command: [spec.command, ...spec.args], enabled: true }, env: spec.env, key: 'environment' }) });
7
+ //# sourceMappingURL=install.js.map
@@ -1,4 +1,10 @@
1
+ import type { AtomicFileWriterPort, FileLockPort } from '@jini-ai/core/contracts/runtime';
1
2
  import { type McpLaunchSpec, type PlanContext } from './install.js';
3
+ /** The host's file effects: Node hosts pass `{ fileLock: nodeFileLock, writer: nodeAtomicWriter }` from `@jini-ai/node-adapters/fs`. */
4
+ export interface OwnedJsonInstallFiles {
5
+ readonly fileLock: FileLockPort;
6
+ readonly writer: Pick<AtomicFileWriterPort, 'writeText' | 'backupOriginalOnce'>;
7
+ }
2
8
  /** Install one owned static connector after explicit consent, preserving foreign data and a first backup.
3
9
  * The host must call this only for a CLI without a temporary config path. No token is accepted or minted.
4
10
  * @complexity O(config bytes) time and space; one locked read and, when changed, backup plus atomic write.
@@ -8,5 +14,6 @@ export declare function installOwnedJsonAgent(required: {
8
14
  spec: McpLaunchSpec;
9
15
  ctx: PlanContext;
10
16
  allowed: boolean;
17
+ files: OwnedJsonInstallFiles;
11
18
  }, _optional?: Record<string, never>): Promise<void>;
12
19
  //# sourceMappingURL=owned-json-install.d.ts.map
@@ -1,6 +1,5 @@
1
1
  import { promises as fs } from 'node:fs';
2
2
  import { isDeepStrictEqual } from 'node:util';
3
- import { backupOriginalOnce, withFileLock, writeFileAtomicAsync } from '@jini-ai/platform/fs';
4
3
  import { applyJsonInstall, isAgentSlug, planAgentInstall } from './install.js';
5
4
  /** Missing is the only condition permitting creation; reject symlinks even for an unchanged entry. */
6
5
  async function readConfig({ path }) {
@@ -35,14 +34,15 @@ export async function installOwnedJsonAgent(required, _optional = {}) {
35
34
  const plan = planAgentInstall({ slug: slug.value, spec: required.spec, ctx: required.ctx });
36
35
  if (plan.kind !== 'json')
37
36
  throw new Error('MCP installation does not use a JSON registry');
38
- await withFileLock({ lockPath: `${plan.configPath}.jini-lock`, run: async () => {
37
+ const { fileLock, writer } = required.files;
38
+ await fileLock.withFileLock({ lockPath: `${plan.configPath}.jini-lock`, run: async () => {
39
39
  const existingText = await readConfig({ path: plan.configPath });
40
40
  const content = applyJsonInstall({ existingText, plan });
41
41
  if (existingText !== null && isDeepStrictEqual(JSON.parse(existingText), JSON.parse(content)))
42
42
  return;
43
43
  if (existingText !== null)
44
- await backupOriginalOnce({ filePath: plan.configPath });
45
- await writeFileAtomicAsync({ filePath: plan.configPath, content }, { refuseSymlink: true });
44
+ await writer.backupOriginalOnce({ filePath: plan.configPath });
45
+ await writer.writeText({ filePath: plan.configPath, content }, { refuseSymlink: true });
46
46
  } }, { createParent: true, timeoutMs: 5000 });
47
47
  }
48
48
  //# sourceMappingURL=owned-json-install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planPiInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,13 @@
1
+ import path from 'node:path';
2
+ import { jsonEntry } from '../planner-shared.js';
3
+ export const planPiInstall = ({ spec, ctx: { home, serverName } }) => ({
4
+ kind: 'manual',
5
+ slug: 'pi',
6
+ format: 'json',
7
+ configPath: path.join(home, '.pi', 'agent', 'mcp.json'),
8
+ snippet: JSON.stringify({ mcpServers: { [serverName]: jsonEntry(spec) } }, null, 2),
9
+ reason: 'The pi coding agent exposes MCP, but its config path/schema is ' +
10
+ 'not authoritatively documented. Paste this into pi’s MCP ' +
11
+ 'config (check `pi --help` for the exact location).',
12
+ });
13
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,40 @@
1
+ import type { AgentSlug, CliInstallPlan, JsonInstallPlan, McpLaunchSpec, PlanContext } from './install.js';
2
+ export declare function envFlags({ env, flag }: {
3
+ env: Record<string, string>;
4
+ flag: string;
5
+ }, _optional?: Record<string, never>): string[];
6
+ export declare function withEnv({ entry, env, key }: {
7
+ entry: Record<string, unknown>;
8
+ env: Record<string, string>;
9
+ key: 'env' | 'environment';
10
+ }, _optional?: Record<string, never>): Record<string, unknown>;
11
+ /** JSON server entry shared by the `env`-style agents (cursor /
12
+ * cline / openclaw / antigravity / trae). `extra` carries per-agent
13
+ * fields; env is only attached when non-empty so configs stay clean. */
14
+ export declare function jsonEntry(spec: McpLaunchSpec, extra?: Record<string, unknown>): Record<string, unknown>;
15
+ /** Inputs every per-agent planner receives; `appData` is the resolved `APPDATA` (win32 only). */
16
+ export interface PlannerArgs {
17
+ spec: McpLaunchSpec;
18
+ ctx: PlanContext;
19
+ appData: string | undefined;
20
+ }
21
+ export declare function cliPlan({ slug, bin, argv, serverName }: {
22
+ slug: AgentSlug;
23
+ bin: string;
24
+ argv: Pick<CliInstallPlan, 'addArgv' | 'removeArgv'>;
25
+ serverName: string;
26
+ }, _optional?: Record<string, never>): CliInstallPlan;
27
+ export declare function jsonPlan({ slug, configPath, keyPath, serverKey, entry }: {
28
+ slug: AgentSlug;
29
+ configPath: string;
30
+ keyPath: string[];
31
+ serverKey: string;
32
+ entry: unknown;
33
+ }, _optional?: Record<string, never>): JsonInstallPlan;
34
+ export declare function editorUserDir({ app, home, platform, suppliedAppData }: {
35
+ app: string;
36
+ home: string;
37
+ platform: NodeJS.Platform;
38
+ suppliedAppData: string | undefined;
39
+ }, _optional?: Record<string, never>): string;
40
+ //# sourceMappingURL=planner-shared.d.ts.map
@@ -0,0 +1,52 @@
1
+ import path from 'node:path';
2
+ // RESIDUAL RISK (CR-006 / SEC-RB-002): `-e`/`--env KEY=VALUE` is claude's,
3
+ // codex's, and kimi's own documented `mcp add` CLI contract for passing
4
+ // server env vars — a fixed, external interface this package does not
5
+ // control and cannot change unilaterally. Because these values land in
6
+ // `addArgv` (argv), they are visible to any other local process that can
7
+ // list this process's command line (e.g. `ps -ww`) for the — typically very
8
+ // brief — window while the daemon's executor shells out to `claude`/`codex`/
9
+ // `kimi mcp add`. This package only builds the plan (`planAgentInstall`
10
+ // itself performs no fs/spawn, per this file's header comment); there is no
11
+ // executor here yet to redact `addArgv` before logging it, so there is
12
+ // nothing left in this package's own code to redact. Whichever executor
13
+ // eventually drives these plans MUST NOT log/echo `addArgv` verbatim
14
+ // (redact anything that looks like an env value from `-e`/`--env` pairs
15
+ // before writing it to any log/error surface), and should prefer a
16
+ // less-exposed handoff (e.g. piping `env` via stdin, or setting it directly
17
+ // in the spawned child's environment) for any future agent whose CLI
18
+ // supports that instead of argv-only `KEY=VALUE`.
19
+ export function envFlags({ env, flag }, _optional = {}) {
20
+ const out = [];
21
+ for (const [k, v] of Object.entries(env)) {
22
+ out.push(flag, `${k}=${v}`);
23
+ }
24
+ return out;
25
+ }
26
+ // Attaches the env map under `key` only when non-empty, so configs stay clean.
27
+ export function withEnv({ entry, env, key }, _optional = {}) {
28
+ if (Object.keys(env).length > 0)
29
+ entry[key] = env;
30
+ return entry;
31
+ }
32
+ /** JSON server entry shared by the `env`-style agents (cursor /
33
+ * cline / openclaw / antigravity / trae). `extra` carries per-agent
34
+ * fields; env is only attached when non-empty so configs stay clean. */
35
+ export function jsonEntry(spec, extra = {}) {
36
+ return withEnv({ entry: { command: spec.command, args: spec.args, ...extra }, env: spec.env, key: 'env' });
37
+ }
38
+ export function cliPlan({ slug, bin, argv, serverName }, _optional = {}) {
39
+ return { kind: 'cli', slug, bin, ...argv, getArgv: ['mcp', 'get', serverName] };
40
+ }
41
+ export function jsonPlan({ slug, configPath, keyPath, serverKey, entry }, _optional = {}) {
42
+ return { kind: 'json', slug, configPath, keyPath, serverKey, entry };
43
+ }
44
+ // VS Code-family editors keep per-user state under one platform-specific root.
45
+ export function editorUserDir({ app, home, platform, suppliedAppData }, _optional = {}) {
46
+ if (platform === 'darwin')
47
+ return path.join(home, 'Library', 'Application Support', app, 'User');
48
+ if (platform === 'win32')
49
+ return path.join(suppliedAppData ?? path.join(home, 'AppData', 'Roaming'), app, 'User');
50
+ return path.join(home, '.config', app, 'User');
51
+ }
52
+ //# sourceMappingURL=planner-shared.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planTraeInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,7 @@
1
+ import path from 'node:path';
2
+ import { jsonEntry, jsonPlan, editorUserDir } from '../planner-shared.js';
3
+ export const planTraeInstall = ({ spec, ctx: { home, platform, serverName }, appData }) => jsonPlan({ slug: 'trae', configPath: traeConfigPath(home, platform, appData), keyPath: ['mcpServers'], serverKey: serverName, entry: jsonEntry(spec) });
4
+ function traeConfigPath(home, platform, suppliedAppData) {
5
+ return path.join(editorUserDir({ app: 'Trae', home, platform, suppliedAppData }), 'mcp.json');
6
+ }
7
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,4 @@
1
+ import type { InstallPlan } from '../install.js';
2
+ import type { PlannerArgs } from '../planner-shared.js';
3
+ export declare const planVibeInstall: (args: PlannerArgs) => InstallPlan;
4
+ //# sourceMappingURL=install.d.ts.map