How to Setup MCP in LangChain / LangGraph

SDK / Framework

Step-by-step setup guide for connecting Model Context Protocol (MCP) servers to LangChain / LangGraph by LangChain.

Configuration File: Programmatic

Code Integration

Example Programmatic Template

Open in Config Generator
from langchain_mcp_adapters.tools import load_mcp_tools
async with stdio_client(server_params) as (read, write):
    tools = await load_mcp_tools(read, write)

Installation Steps

1

Locate Programmatic

Find the configuration file at Code Integration.

2

Add MCP server entries

Open the file and add your server definitions inside the configuration schema.

3

Set environment variables

Provide any required API keys, database URLs, or access tokens in the environment section.

4

Save and reload

Save Programmatic and hot-reload or restart LangChain / LangGraph.

5

Verify in chat

Ask LangChain / LangGraph to list tools or execute a task with the connected MCP server.

LangChain / LangGraph Protocol Support

Stdio Transport Supported

stdio_client transport adapter

SSE / HTTP Transport Supported

sse_client transport adapter

Tool Calling Supported

StructuredTool conversion

Resources API Supported

Document loader wrappers

Prompts API Supported

ChatPromptTemplate conversion

Roots Boundary Unsupported

Custom memory management

Dynamic Hot-Reload Supported

Client runtime connection pool