mcp-use TypeScript API
    Preparing search index...

    Selects an active MCP server and exposes its LangChain tools.

    Implements

    Index
    • Parameters

      • client: MCPClient

        MCP client that owns the managed servers.

      • adapter: LangChainAdapter

        Adapter used to convert MCP capabilities.

      • OptionalmanagementTools: StructuredToolInterface<ToolInputSchemaBase, any, any>[]

        Optional replacement for the built-in server management tools.

      Returns ServerManager

    activeServer: string | null = null

    Server whose cached tools are currently exposed.

    Adapter used to create LangChain tools.

    client: MCPClient

    MCP client that owns server configurations and sessions.

    initializedServers: Record<string, boolean> = {}

    Whether capabilities have been loaded for each configured server.

    serverTools: Record<string, StructuredToolInterface[]> = {}

    Cached LangChain tools, resources, and prompts by server name.

    • get tools(): StructuredToolInterface<ToolInputSchemaBase, any, any>[]

      Returns StructuredToolInterface<ToolInputSchemaBase, any, any>[]

      Management tools plus cached tools from the active server, if any.

    • Validates that the client contains at least one server configuration.

      Returns void

    • Writes current connection and tool-cache state at debug level.

      Parameters

      • context: string

        Label describing why the state was logged.

      Returns void

    • Connects configured servers as needed and caches all tools, resources, and prompts.

      Returns Promise<void>

    • Replaces the management tools returned by ServerManager.tools.

      Parameters

      • tools: StructuredToolInterface<ToolInputSchemaBase, any, any>[]

        Complete replacement tool list.

      Returns void