import { BaseApi } from "../base-api"; import type { CreateMcpConnectionRequest, ListMcpConnectionsResponse, McpConnectionCreatedResponse, McpConnectionSummary } from "./types"; /** * `McpConnectionsApi` wraps the external-MCP connection endpoints. A connection is a per-user * OAuth link to an external (non-Narrative) MCP server; once `connected`, an agent conversation * can reference it by id via `mcp_servers[].connection_id`. Tokens are never returned by the API. * * The OAuth callback (`GET /mcp-connections/callback`) is a browser redirect, not an SDK call, so * it is intentionally not wrapped here. It only stores the authorization code and redirects; the * app then calls {@link McpConnectionsApi.completeMcpConnection} to finish, authenticated as the * user who began the flow. Because the callback is public, it is not allowed to complete anything * itself — otherwise a `state` alone could turn another user's consent into a stored token. */ export declare class McpConnectionsApi extends BaseApi { /** * Lists the calling user's MCP connections with their status. Credential-free. * @returns {Promise} The caller's connections (empty if none). */ listMcpConnections(): Promise; /** * Begins connecting an external MCP server (OAuth discovery + dynamic client registration). * @param {CreateMcpConnectionRequest} request - The server `url` and routing `alias`. * @returns {Promise} The pending `connection_id` and the * `authorization_url` the user must visit to consent. */ createMcpConnection(request: CreateMcpConnectionRequest): Promise; /** * Completes a connection begun with {@link McpConnectionsApi.createMcpConnection}, once the user * has consented and the OAuth callback has stored the authorization code. Exchanges that code and * validates the connection with a `tools/list` call before storing the tokens. * * Must be called with the credentials of the user who began the flow — the `state` on its own is * not enough. * @param {string} state - The one-time `state` the OAuth callback forwarded to the app. * @returns {Promise} The connection's status view, normally `connected`. * Rejects with 404 if the connection does not exist or belongs to another user; 400 if the * `state` is unknown or expired, the authorization code has not arrived yet, or the token * exchange or validation failed. */ completeMcpConnection(state: string): Promise; /** * Fetches one of the calling user's connections. * @param {string} connectionId - The connection id. * @returns {Promise} The connection's status view. Rejects with 404 if it * does not exist or belongs to another user. */ getMcpConnection(connectionId: string): Promise; /** * Deletes one of the calling user's connections and its stored tokens. * @param {string} connectionId - The connection id. * @returns {Promise} Resolves when deleted. Rejects with 404 if it does not exist or * belongs to another user. */ deleteMcpConnection(connectionId: string): Promise; }