@n8n/n8n-nodes-langchain
Version:
61 lines (60 loc) • 3.28 kB
TypeScript
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { type Result } from '@n8n/utils/result';
import type { ICredentialDataDecryptedObject, IExecuteFunctions, ILoadOptionsFunctions, Logger, McpRegistryCredentialType, McpRegistryConnection, INode, ISupplyDataFunctions, NodeEgressFilter, PrepareMcpRegistryConnectionInput, PrepareMcpRegistryConnectionResult } from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';
import { type McpAuthenticationOption, type McpServerTransport, type McpTool } from './types';
import { type ContentBlock } from '@modelcontextprotocol/sdk/types.js';
export type { ContentBlock as McpContentBlock };
export declare function isMcpContentArray(data: unknown): data is ContentBlock[];
export declare function getAllTools(client: Client, cursor?: string): Promise<McpTool[]>;
type OnUnauthorizedHandler = (headers?: Record<string, string>) => Promise<Record<string, string> | null>;
type ConnectMcpClientError = {
type: 'invalid_url';
error: Error;
} | {
type: 'connection';
error: Error;
} | {
type: 'auth';
error: Error;
} | {
type: 'cancelled';
error: Error;
};
export declare function mapToNodeOperationError(node: INode, error: ConnectMcpClientError): NodeOperationError;
export declare function connectMcpClient({ headers, serverTransport, endpointUrl, name, version, onUnauthorized, signal, allowedDomains, secureEgressFilter, getTraceHeaders, logger, }: {
serverTransport: McpServerTransport;
endpointUrl: string;
headers?: Record<string, string>;
name: string;
version: number;
onUnauthorized?: OnUnauthorizedHandler;
signal?: AbortSignal;
allowedDomains?: string;
secureEgressFilter: NodeEgressFilter;
getTraceHeaders?: () => Record<string, string>;
logger?: Logger;
}): Promise<Result<Client, ConnectMcpClientError>>;
export declare function getAuthHeaders(ctx: IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions, authentication: McpAuthenticationOption): Promise<{
headers?: Record<string, string>;
credentials?: ICredentialDataDecryptedObject;
}>;
export declare function tryRefreshOAuth2Token(ctx: IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions, authentication: McpAuthenticationOption, headers?: Record<string, string>): Promise<{
Authorization: string;
} | null>;
export declare function tryRefreshAiGatewayToken(ctx: IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions, authentication: McpAuthenticationOption, headers?: Record<string, string>): Promise<{
[x: string]: string;
} | null>;
export declare function connectMcpClientForCredential(ctx: IExecuteFunctions | ILoadOptionsFunctions | ISupplyDataFunctions, config: {
authentication: McpAuthenticationOption;
serverTransport: McpServerTransport;
endpointUrl: string;
registryCredential?: {
connection: McpRegistryConnection;
credentialType: McpRegistryCredentialType;
prepareConnection(input: PrepareMcpRegistryConnectionInput): PrepareMcpRegistryConnectionResult;
};
surface: string;
signal?: AbortSignal;
}): Promise<Result<Client, ConnectMcpClientError>>;
export declare function isStructuredContent(value: unknown): value is Record<string, unknown>;