mcp_kit.adapters.langgraph
LangGraph adapter for MCP targets.
LangGraphMultiServerMCPClient
class LangGraphMultiServerMCPClient()
Adapter class for LangGraph compatibility with MCP targets.
This adapter provides an interface similar to MultiServerMCPClient from langchain-mcp-adapters, allowing MCP targets to be used with LangGraph workflows.
__init__
def __init__(target: Target)
Initialize the LangGraph MCP client adapter.
Arguments:
target
: The MCP target to adapt for LangGraph use
Raises:
ImportError
: If langchain_mcp_adapters is not installed
session
@asynccontextmanager
async def session(server_name: str,
*,
auto_initialize: bool = True) -> AsyncIterator[Any]
Create a new client session for the specified server.
Arguments:
server_name
: Name of the server to connect toauto_initialize
: Whether to automatically initialize the target
Raises:
ValueError
: If the server name doesn't match the target name
Returns:
ClientSessionAdapter for the target
get_tools
async def get_tools(*, server_name: str | None = None) -> list[BaseTool]
Get LangChain tools from the MCP server.
Converts MCP tools to LangChain-compatible tools using the langchain_mcp_adapters.
Arguments:
server_name
: Optional server name to validate against
Raises:
ValueError
: If the server name doesn't match the target name
Returns:
List of LangChain tools