import type { IExecuteFunctions } from 'n8n-workflow'; interface McpCredentials { baseUrl: string; authMode: 'apiKey' | 'oauth2'; apiKey?: string; accessToken?: string; allowPrivateNetwork?: boolean; requestTimeoutMs?: number; } /** * Build the MCP endpoint URL from a base URL. * * Hardens against: * - non-http(s) protocols (file://, gopher://, javascript:) * - SSRF via private/loopback hostnames (127.x, 169.254.x AWS metadata, * RFC1918 ranges, ::1, fc00::/7, fe80::/10) unless explicitly allowed * * Tolerates trailing slashes and an existing /mcp suffix. */ export declare function buildMcpEndpoint(baseUrl: string, options?: { allowPrivateNetwork?: boolean; }): URL; interface CallSession { url: URL; bearer: string; timeoutMs: number; } /** * Resolve a credential bundle into the parameters required for one or * more MCP tool calls. Used by the node's execute() loop so we don't * re-validate per item. */ export declare function prepareCallSession(context: IExecuteFunctions, credentials: McpCredentials): CallSession; /** * Open an MCP client session, run a single tool call, close cleanly. * * Each call still creates a fresh client (the n8n SDK does not currently * give us a hook to share one across items without leaking state between * workflows). The session is wrapped in a per-call AbortController so a * hung server cannot block the workflow indefinitely. */ export declare function callMemoryTool(context: IExecuteFunctions, session: CallSession, toolName: string, args: Record): Promise; /** * Parse an MCP tool result into a plain JSON value when possible. * * Memory tools return a `content` array of text blocks. Most blocks are * JSON-encoded, so we try to parse and fall back to the raw string. * If the SDK already provides `structuredContent` we use that directly. * * Hardens against an oversized response by capping the joined text at * MAX_RESPONSE_BYTES so a misconfigured server can't OOM the worker. */ export declare function parseToolResult(result: unknown): unknown; /** * Strip undefined / null / empty values from a tool argument object. * MCP servers reject unknown/invalid types more loudly than missing keys, * so we drop empty optionals on the client side. Preserves zero, false, * and explicit booleans. */ export declare function pruneArgs(args: Record): Record; export {};