import { D as DiscoveredMcp } from './mcp-discovery-CLihUe93.js'; /** * `~/.agentproto/imported-mcps.json` — the user's curated set of * discovered MCPs they want the daemon to know about. v1 is just * persistence + read-side; the actual MCP-proxy implementation * (where the daemon's /mcp endpoint aggregates the imported * servers' tools under namespace prefixes) is v2 work. * * Purpose: today, "I see you have chrome-devtools in claude" is * read-only. Once a user imports it, the operator agent can refer * to it ("the user said it's enabled — call it") and a future * proxy layer can actually expose it. We persist the choice now so * the data is in place when the proxy lands. * * File shape: * { * "version": 1, * "imports": [ * { * "id": "claude-code:project:/path:chrome-devtools", * "alias": "chrome-devtools", * "addedAt": "2026-05-10T...", * "snapshot": { ...the DiscoveredMcp at import time } * } * ] * } * * Snapshotting at import time keeps the daemon resilient to the * source config getting deleted (user runs `claude mcp remove ...`). * The imported entry stays usable; only the next discovery pass * stops listing it as "available to import." */ declare const IMPORTED_MCPS_PATH: () => string; declare const IMPORTED_MCPS_VERSION: 1; /** Where an import came from. `plugin` (written by plugin-local-browser) and * `manual` have no discovery source; `kind` otherwise mirrors * `DiscoveredMcp["source"]`. */ interface ImportedMcpOrigin { kind: DiscoveredMcp["source"] | "plugin" | "manual"; scope: string; name: string; } /** `live` = re-read the source harness config at connect time (the snapshot is * only a fallback); `snapshot` = the stored copy is authoritative. */ type ImportedMcpResolve = "live" | "snapshot"; /** Opaque secret refs (resolved via `resolveMcpSecret`), keyed by the header * / env key they fill. Values are refs, NEVER secret material. */ interface ImportedMcpSecretRefs { headers?: Record; env?: Record; } interface ImportedMcpEntry { id: string; alias: string; addedAt: string; snapshot: DiscoveredMcp; /** Additive (no file-version bump): link back to the source config. */ origin?: ImportedMcpOrigin; resolve?: ImportedMcpResolve; secretRefs?: ImportedMcpSecretRefs; /** http/sse only: the server authenticates with OAuth. Tokens live in the * keychain (`mcpOAuthRef`), never in this file. Set by `mcp login`. */ auth?: ImportedMcpAuth; /** http/sse only: also send the caller session and node headers * (`x-agentproto-caller-session`, `x-agentproto-caller-node`) to this server * when it is not on this machine. Loopback servers always receive them. */ forwardCaller?: boolean; /** http only: mint an AIP-59 section 8 sub-session token per caller session * and send it as `Agentproto-Subsession` instead of the bare caller header. * Only meaningful when the server serves `POST /pair/subsessions`. */ subsession?: "aip-59"; } interface ImportedMcpAuth { type: "oauth"; /** Scope to request; omitted = the server's advertised default. */ scope?: string; } /** Value written into `snapshot.headers[K]` / `snapshot.env[K]` in place of a * literal secret that now lives behind `secretRefs`. */ declare const SECRET_REF_MARKER = ""; /** `live` only when discovery can actually re-find the entry: a discovery * source AND a scope discovery scans (`global` / `project:*` / `workspace:*`). * claude-code `local`-scope and plugin/manual entries stay `snapshot`. */ declare function deriveResolve(snapshot: DiscoveredMcp): ImportedMcpResolve; /** Keychain path + account for one secret slot of an import. Ref format * `agentproto/mcp-import/#:` (split on LAST `#`). */ declare function mcpSecretRef(importId: string, kind: "header" | "env", key: string): string; /** A value worth moving to the keychain: non-empty, not already the marker, * and not a `${VAR}` placeholder (those expand at connect, no secret at rest). */ declare function isLiteralSecretValue(v: unknown): v is string; interface MoveSecretsResult { entry: ImportedMcpEntry; /** Header/env KEY names moved this call (never values). */ moved: string[]; /** Human warnings (key names only). */ warnings: string[]; } /** * Move every literal header/env value of `entry.snapshot` behind a keychain * ref. Keychain write happens FIRST per key; only on success is the snapshot * value replaced by the marker (a failed write keeps the literal + warns). * Read-back verification when `resolve` is supplied. */ declare function moveEntrySecrets(entry: ImportedMcpEntry, hooks: { storeMcpSecret?: (ref: string, value: string) => Promise; resolveMcpSecret?: (ref: string) => Promise; }): Promise; interface ImportedMcpsConfig { version: typeof IMPORTED_MCPS_VERSION; imports: ImportedMcpEntry[]; } declare function loadImportedMcps(path?: string): Promise; declare function saveImportedMcps(config: ImportedMcpsConfig, path?: string): Promise; /** * Add (or replace) an import. Snapshots the discovered MCP at * import time so the entry stays usable when the source config * disappears. */ declare function addImport(config: ImportedMcpsConfig, input: { snapshot: DiscoveredMcp; alias?: string; }): ImportedMcpsConfig; /** * `addImport` + move literal header/env values behind keychain refs (via the * `storeMcpSecret` hook). Hook absent → literals kept and a warning returned. * Callers persist `config` and surface `warnings` in their reply. */ declare function addImportWithSecrets(config: ImportedMcpsConfig, input: { snapshot: DiscoveredMcp; alias?: string; }, hooks: { storeMcpSecret?: (ref: string, value: string) => Promise; resolveMcpSecret?: (ref: string) => Promise; }): Promise<{ config: ImportedMcpsConfig; entry: ImportedMcpEntry; warnings: string[]; }>; declare function removeImport(config: ImportedMcpsConfig, id: string): ImportedMcpsConfig; declare function findImport(config: ImportedMcpsConfig, id: string): ImportedMcpEntry | undefined; /** KEY names only (never refs' targets or values) — for status surfaces. */ declare function secretRefKeys(entry: Pick): { headers?: string[]; env?: string[]; } | undefined; export { IMPORTED_MCPS_PATH, IMPORTED_MCPS_VERSION, type ImportedMcpAuth, type ImportedMcpEntry, type ImportedMcpOrigin, type ImportedMcpResolve, type ImportedMcpSecretRefs, type ImportedMcpsConfig, type MoveSecretsResult, SECRET_REF_MARKER, addImport, addImportWithSecrets, deriveResolve, findImport, isLiteralSecretValue, loadImportedMcps, mcpSecretRef, moveEntrySecrets, removeImport, saveImportedMcps, secretRefKeys };