/** * "Auth-required" stdio MCP server — run when ~/.memwal/credentials.json is * missing but the package was spawned by an MCP client (Cursor / Claude * Desktop / etc.). * * Instead of exiting (which makes the MCP client show a cryptic * "Failed to start server" error that the user can't act on), we boot a * minimal MCP server that: * * - Responds to `initialize` so the client sees a healthy server. * - Advertises the 4 real Walrus Memory tools + a 5th `memwal_login` tool in * `tools/list` so the agent knows what's available. * - On `tools/call memwal_login`: invokes the browser-based wallet login * flow inline so the user never has to leave their MCP client. Eliminates * the previous "run a separate `npx ... login` command then restart" UX. * - On any other `tools/call`: returns `isError: true` with a friendly * instruction telling the agent to call `memwal_login` first (or run * the CLI command as a fallback). * * Note: HTTP transport (`/api/mcp`) gets a separate native OAuth flow per * MCP spec 2025-06 — see ENG-1750. The two paths cover different surfaces * and coexist. */ import { type MemWalCredentials } from "./auth.js"; /** Tool names the OLDEST relayer this bridge still talks to serves. * * The bridge ships on npm and updates itself; a relayer ships per environment * and does not, so the bridge is routinely NEWER than the relayer it dials — * 0.0.14-dev.0 against prod and staging on 0.0.13, which is GH #928. The * cold-start list is served before any relayer capability is known, so every * name in it that the dialled relayer does not serve is a tool the agent can * be told about and then cannot call. * * Cold start is therefore a FLOOR, not a forecast: add a name here only once * the tool has shipped to prod, never when it lands on dev. Newer tools reach * the client a beat later anyway — the relayer's own `tools/list` replaces * this one and `notifications/tools/list_changed` tells the client to re-read * it. `memwal_remember_status` is the worked example: it exists on dev, not on * prod/staging, and belongs here only after a prod release carries it. */ export declare const BASELINE_RELAYER_TOOLS: ReadonlySet; /** Every tool this bridge can describe, baseline or not. Only the baseline * subset is advertised at cold start; this is what the schema tests pin, so a * newer tool's shape stays reviewed while it waits for a prod release. */ export declare const ALL_TOOL_DEFINITIONS: ({ name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { text: { type: string; minLength: number; }; namespace: { type: string; minLength?: undefined; }; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { facts: { type: string; items: { type: string; minLength: number; }; minItems: number; maxItems: number; }; namespace: { type: string; minLength?: undefined; }; text?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { job_id: { type: string; minLength: number; }; job_ids: { type: string; items: { type: string; minLength: number; }; minItems: number; maxItems: number; }; waitMs: { type: string; minimum: number; maximum: number; default: number; }; text?: undefined; namespace?: undefined; facts?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; additionalProperties: boolean; required?: undefined; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { query: { type: string; minLength: number; }; limit: { type: string; minimum: number; maximum: number; default: number; }; namespace: { type: string; minLength?: undefined; }; maxDistance: { type: string; minimum: number; description: string; }; text?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { namespace: { type: string; minLength: number; }; limit: { type: string; minimum: number; maximum: number; default: number; }; text?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { text?: undefined; namespace?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; additionalProperties: boolean; required?: undefined; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { freshKey: { type: string; default: boolean; description: string; }; text?: undefined; namespace?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; }; additionalProperties: boolean; required?: undefined; }; })[]; /** Signed-in cold-start list (bridge). Credentials exist; the relayer session * is not up yet. Proactive wording so clients that keep the first tools/list * still save/recall without being asked. */ export declare const TOOL_DEFINITIONS: ({ name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { text: { type: string; minLength: number; }; namespace: { type: string; minLength?: undefined; }; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { facts: { type: string; items: { type: string; minLength: number; }; minItems: number; maxItems: number; }; namespace: { type: string; minLength?: undefined; }; text?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { job_id: { type: string; minLength: number; }; job_ids: { type: string; items: { type: string; minLength: number; }; minItems: number; maxItems: number; }; waitMs: { type: string; minimum: number; maximum: number; default: number; }; text?: undefined; namespace?: undefined; facts?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; additionalProperties: boolean; required?: undefined; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { query: { type: string; minLength: number; }; limit: { type: string; minimum: number; maximum: number; default: number; }; namespace: { type: string; minLength?: undefined; }; maxDistance: { type: string; minimum: number; description: string; }; text?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { namespace: { type: string; minLength: number; }; limit: { type: string; minimum: number; maximum: number; default: number; }; text?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { text?: undefined; namespace?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; additionalProperties: boolean; required?: undefined; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { freshKey: { type: string; default: boolean; description: string; }; text?: undefined; namespace?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; }; additionalProperties: boolean; required?: undefined; }; })[]; /** Signed-out list (auth-required). No credentials, so every memory call * fails: keep conservative wording or the model will spam remember and get * a stream of auth errors. */ export declare const SIGNED_OUT_TOOL_DEFINITIONS: ({ name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { text: { type: string; minLength: number; }; namespace: { type: string; minLength?: undefined; }; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { facts: { type: string; items: { type: string; minLength: number; }; minItems: number; maxItems: number; }; namespace: { type: string; minLength?: undefined; }; text?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { job_id: { type: string; minLength: number; }; job_ids: { type: string; items: { type: string; minLength: number; }; minItems: number; maxItems: number; }; waitMs: { type: string; minimum: number; maximum: number; default: number; }; text?: undefined; namespace?: undefined; facts?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; additionalProperties: boolean; required?: undefined; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { query: { type: string; minLength: number; }; limit: { type: string; minimum: number; maximum: number; default: number; }; namespace: { type: string; minLength?: undefined; }; maxDistance: { type: string; minimum: number; description: string; }; text?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { namespace: { type: string; minLength: number; }; limit: { type: string; minimum: number; maximum: number; default: number; }; text?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; maxDistance?: undefined; freshKey?: undefined; }; required: string[]; additionalProperties: boolean; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { text?: undefined; namespace?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; freshKey?: undefined; }; additionalProperties: boolean; required?: undefined; }; } | { name: string; title: string; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; description: string; inputSchema: { type: string; properties: { freshKey: { type: string; default: boolean; description: string; }; text?: undefined; namespace?: undefined; facts?: undefined; job_id?: undefined; job_ids?: undefined; waitMs?: undefined; query?: undefined; limit?: undefined; maxDistance?: undefined; }; additionalProperties: boolean; required?: undefined; }; })[]; /** Config passed in by the entry point (`index.ts`) so the login flow uses * the same web/relayer URLs as the rest of the CLI (e.g. `--dev` → * dashboard at `https://dev.memwal.ai`, not the prod default at * `https://memory.walrus.xyz`). */ export interface AuthRequiredConfig { relayerUrl: string; webUrl: string; label: string; /** Default memory namespace resolved at boot. Accepted here so the entry * point can pass one config shape to both server modes — but auth-required * mode never forwards a memory tool call (every non-login tool returns the * login instruction), so there is nothing to namespace yet. It takes * effect once credentials exist and the bridge runs. */ namespace?: string; } /** Returned by {@link runAuthRequiredServer} when the user signs in mid-session * (via `memwal_login`) and the request should now be served by the real bridge * instead — WITHOUT a client restart. */ export interface AuthHandoff { creds: MemWalCredentials; /** Lines the auth-required reader already pulled off stdin that the bridge * must process first: the tool call that triggered the handoff, plus * anything buffered behind it. */ pendingLines: string[]; } /** * Run the auth-required stdio MCP server. * * Resolves with an {@link AuthHandoff} the moment `memwal_login` completes and * the next memory tool call (or tools/list) arrives — so the caller can pick up * the real bridge IN THE SAME PROCESS, eliminating the second client restart. * Resolves with `undefined` if stdin closes before any sign-in. * * We manage the stdin listeners directly (rather than via the shared * `readStdinLines`) so we can DETACH cleanly at handoff: the bridge attaches its * own reader next, and two concurrent `data` listeners would double-process * every line. `pause()` keeps any bytes that arrive during the switch buffered * until the bridge's reader resumes the stream. * * The `config` parameter carries the same `relayerUrl` / `webUrl` / `label` * that the rest of the CLI resolved (e.g. `--dev` → dev URLs). Without it, * `memwal_login` would fall back to prod defaults and open the wrong dashboard. */ export declare function runAuthRequiredServer(config: AuthRequiredConfig): Promise; //# sourceMappingURL=auth-required.d.ts.map