export interface McpToolBus { registerProvider(providerName: string, tools: unknown[]): () => void; registerTool(name: string, fn: (args: any, context?: ToolCallContext) => unknown | Promise, opts?: DefineToolOptions): () => void; getTools(): unknown[]; onChange(cb: () => void): () => void; } export interface DefineToolOptions { description?: string; params?: Record; example?: Record; /** MCP tool hints shown to the client, e.g. `{ readOnlyHint: true }` lets it call the tool without asking. */ annotations?: { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; }; /** When true, `fn` is called as `fn(args, { signal, progress })` — see ToolCallContext. */ context?: boolean; } /** Second argument of a tool function registered with `context: true`. */ export interface ToolCallContext { /** Aborts when the MCP client cancels the call. */ signal: AbortSignal; /** Reports progress to the MCP client; does nothing when the client did not ask for progress. */ progress(progress: number, total?: number, message?: string): void; } /** * Ergonomic, typed wrapper over window.__mcpToolBus.registerTool - for a * normal bundler app that wants to register one ad-hoc tool without * touching the raw bus global directly. Lazily loads the bus on first * call; a page that never calls this (or registerProvider/connectMcpBridge * below) never fetches tool-bus.js at all. */ export declare function defineTool(name: string, fn: (args: any, context?: ToolCallContext) => unknown | Promise, opts?: DefineToolOptions): Promise<(() => void) | undefined>; /** Typed passthrough to window.__mcpToolBus.registerProvider, after ensuring the bus is loaded. */ export declare function registerProvider(providerName: string, tools: unknown[]): Promise<(() => void) | undefined>; export interface ConnectMcpBridgeOptions { appName: string; defaultChannel?: string; onStateChange?: (state: 'disconnected' | 'connecting' | 'connected', channel: string, appLabel: string) => void; /** js-bridge-mcp's own origin, for a server started on a non-default PORT. Defaults to "http://localhost:8766". */ serverUrl?: string; /** Extra bus/provider setup beyond the automatic tool-bus load, e.g. registering a provider before the first connect. */ beforeConnect?: () => Promise | void; } /** * The "ergonomic all-in-one" entrypoint (requirement 4): composes * createMcpConnect (connect.js) with an automatic tool-bus load in * beforeConnect, replacing the ~15-line boilerplate every consumer repo * currently hand-rolls (JSBRIDGE_HOST const, the bus-load-then-merge * dance). The sync-stub-then-swap shim a host needs for a * top-level-await-unsupported bundler target stays THAT HOST's own * concern (it's about their bundler's build target, not this SDK's * shape) - see htmlpaint.com's/mindfoo's own mcp-connect wrapper for the * pattern; do not miscategorize that shim as something this SDK should * absorb. */ export declare function connectMcpBridge(opts: ConnectMcpBridgeOptions): { init: () => Promise; handleConnectClick: () => Promise; onConnectionStateChange: (cb: any) => () => boolean; getConnectionState: () => { state: string; channel: any; appLabel: any; }; };