@h1deya/langchain-mcp-tools - v0.2.3
    Preparing search index...

    Function convertMcpToLangchainTools

    • Initializes multiple MCP (Model Context Protocol) servers and converts them into LangChain tools. This function concurrently sets up all specified servers and aggregates their tools.

      Parameters

      • configs: McpServersConfig

        A mapping of server names to their respective configurations

      • Optionaloptions: LogOptions & { logger?: McpToolsLogger }

        Optional configuration settings

        Options for configuring logging behavior.

        • OptionallogLevel?: "trace" | "debug" | "info" | "warn" | "error" | "fatal"
        • Optionallogger?: McpToolsLogger

          Custom logger implementation that follows the McpToolsLogger interface. If provided, overrides the default Logger instance.

      Returns Promise<
          {
              tools: StructuredTool<ZodObjectAny, any, { [key: string]: any }>[];
              cleanup: McpServerCleanupFn;
          },
      >

      A promise that resolves to: - tools: Array of StructuredTool instances ready for use with LangChain - cleanup: Function to properly terminate all server connections

      McpInitializationError if any server fails to initialize

      const { tools, cleanup } = await convertMcpToLangchainTools({
      filesystem: { command: "npx", args: ["-y", "@modelcontextprotocol/server-filesystem", "."] },
      fetch: { command: "uvx", args: ["mcp-server-fetch"] }
      });