WEIR

LangGraph MCP in 2026: Adapters, Headers and ToolNode

Load LangGraph MCP tools from a remote server: MultiServerMCPClient with a header, a ToolNode graph, the archived-adapter catch, a real 401 and X output.


Published · Updated · 6 min read

Cover image: MCP tools in a LangGraph graph

LangGraph MCP support comes from LangChain's adapters: load a server's tools with MultiServerMCPClient, then hand them to a ToolNode.

This guide connects a LangGraph agent to Weir's remote MCP server for public X (Twitter) data, with an API key. It covers the adapter's archived status, the async trap and a real call. We run Weir.

import asyncio, os
from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient({"weir": {
    "transport": "http",
    "url": "https://api.weirapp.io/mcp",
    "headers": {"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
}})
tools = asyncio.run(client.get_tools())
print([t.name for t in tools])

How to connect LangGraph to a remote MCP server

Weir takes an API key in the Authorization header, so there's no browser sign-in.

  1. Installpip install langgraph langchain-mcp-adapters "langchain[anthropic]"
  2. Get a Weir keyCreate one under API keys in your Weir dashboard. Keep it in WEIR_API_KEY.
  3. Set a model keyAnthropic models read ANTHROPIC_API_KEY.
  4. Run the graphBuild it with ToolNode and call ainvoke, as below.

As of 24 October 2026, PyPI lists langgraph 1.2.17 and langchain-mcp-adapters 0.3.2, both for Python 3.10 or later. The adapter pins the mcp SDK below 2.0.

Which LangGraph MCP adapter should you use?

Both packages turn MCP tools into LangChain tools that a LangGraph ToolNode accepts. They differ in status and auth:

langchain-mcp-adapters langchain[mcp]
Status, 24 Oct 0.3.2, archived langchain 1.4.7, beta
Main class MultiServerMCPClient MCPAdapter
Where the key goes headers FastMCP auth
Built on mcp SDK 1.x FastMCP 4
We ran it on Weir Yes No

Our pick is the adapter when you need it working today: its API won't change, and we ran it against Weir. Plan the move to langchain[mcp] once it leaves beta.

As of 24 October 2026, the adapter's GitHub repo is archived. Its README says it's "no longer actively maintained" and points to langchain.mcp.

LangGraph.js isn't affected: npm lists @langchain/mcp-adapters 2.0.1, released on 6 October 2026.

LangGraph MCP example: a StateGraph with ToolNode

The graph has two nodes: the model, and a ToolNode that runs Weir's tools. This part follows the adapter README's StateGraph example:

from langchain.chat_models import init_chat_model
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode, tools_condition

def build_graph(tools):
    model = init_chat_model("anthropic:claude-sonnet-5-5").bind_tools(tools)
    async def call_model(state: MessagesState):
        return {"messages": [await model.ainvoke(state["messages"])]}
    graph = StateGraph(MessagesState)
    graph.add_node("model", call_model)
    graph.add_node("tools", ToolNode(tools))
    graph.add_edge(START, "model")
    graph.add_conditional_edges("model", tools_condition)
    graph.add_edge("tools", "model")
    return graph.compile()

tools_condition sends the graph to the tools node when the model asks for a tool, and ends the run when it doesn't.

Then load the X tools with the client from the top of this page, and ask:

async def main(question: str) -> None:
    tools = await client.get_tools()
    x_tools = [t for t in tools if t.name.startswith(("search_x", "get_x_"))]
    result = await build_graph(x_tools).ainvoke({"messages": [("user", question)]})
    print(result["messages"][-1].content)

asyncio.run(main("What have @crewAIInc and @LangChain posted about MCP? Use limit 3."))

Three things in there matter:

  • Async all the way. The adapter's tools have no sync version. A sync call got us "StructuredTool does not support sync invocation."
  • One session per tool call. get_tools() opens a fresh MCP session for each call. To hold one, use client.session("weir") with load_mcp_tools.
  • Same list in both places. The model knows only the tools in bind_tools, and ToolNode runs only its own.

Want a prebuilt loop? create_react_agent in langgraph.prebuilt is deprecated since LangGraph 1.0. Use create_agent, as in our LangChain Twitter tools post.

What does the graph get back?

To answer, the model calls search_x with both handles. We made that call through Weir's MCP server on 24 October 2026:

→ search_x {"fromUsers": ["crewAIInc", "LangChain"], "query": "MCP -filter:nativeretweets",
            "onlyOriginal": true, "limit": 3}
← 3 posts · 4 credits · nextCursor set
  2026-10-07  37 likes  @LangChain  "Managed Deep Agents v0.9 is here!", MCP servers per run
  2026-10-01  33 likes  @LangChain  "@langchain / MCP-adapters 2.0", quoting @LangChain_JS
  2026-09-15  88 likes  @LangChain  "Every Managed Deep Agent is an MCP server."

The ToolMessage holds two text blocks: the JSON result, then a line like "Charged 4 credits; 617 credits left."

Its artifact carries the same JSON for your code, not the model. Read message.artifact["structured_content"]["data"] to save the posts without parsing text.

The result also has meta.next, the follow-up call with the new cursor. Weir's docs say only a null cursor marks the end.

4credits for the search above
11credits for a 10-post search
1credit for a search that finds nothing
5,000free Weir credits every month

Weir bills 1 credit per call plus 1 per X post, and failed calls are free. Packs start at $5 for 25,000 credits, as of October 2026. See our pricing page.

Moving to langchain.mcp, the beta replacement

LangChain's migration guide swaps MultiServerMCPClient for MCPAdapter. Auth moves onto a FastMCP Client:

import os
from fastmcp.client import Client
from langchain.mcp import MCPAdapter

async def load_x_tools():
    weir = Client("https://api.weirapp.io/mcp", auth=os.environ["WEIR_API_KEY"])
    async with MCPAdapter(weir) as adapter:
        tools = await adapter.list_tools()
    return [t for t in tools if t.name.startswith(("search_x", "get_x_"))]

Install it with pip install "langchain[mcp]". Pass the bare key to auth, since FastMCP's docs say it adds Bearer itself. Expect a LangChainBetaWarning on import.

The tools stay callable after the async with block ends. Hand them to the same build_graph.

If it doesn't work

Here's what the adapter raised when we connected with no key:

ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://api.weirapp.io/mcp'
  www-authenticate: Bearer resource_metadata="https://api.weirapp.io/.well-known/
    oauth-protected-resource/mcp", scope="read:social usage:read monitors:read"

That challenge is for apps that sign in through a browser. A script sends the key instead, and Weir's free GET /v1/whoami checks it. Other errors:

  • Illegal header value b'Bearer '. WEIR_API_KEY is empty in that shell, so httpx won't send the header. We hit this one too.
  • NotImplementedError on async with MultiServerMCPClient. That form was removed in 0.1.0. Call get_tools() directly.
  • "StructuredTool does not support sync invocation". Switch invoke to ainvoke.
  • A call hangs for minutes. The adapter waits up to 5 minutes to read a reply. Lower "sse_read_timeout" in the connection.
  • A tool returns 402. Your Weir credits ran out. The model gets an error ToolMessage, and retrying won't help.

When not to use Weir

  • Your graph has to post or DM on X. Weir is read-only.
  • You want private data. Weir reads public posts, not bookmarks, DMs or home timelines.
  • Price per post matters most. TwitterAPI.io lists $0.15 per 1,000 tweets as of October 2026, less than our $5 pack.
  • You need a guarantee. Weir isn't licensed by X or affiliated with it, so access can change.

FAQ

Does LangGraph support MCP?

Yes, through LangChain. langchain-mcp-adapters or langchain[mcp] turns MCP tools into LangChain tools. A ToolNode runs them, or create_agent builds the whole loop.

Is langchain-mcp-adapters deprecated?

Its repo is archived, and its README says it's no longer actively maintained. Version 0.3.2 still installs, and it reached Weir in our test. LangChain points new work to langchain[mcp], which its docs mark as beta.

How do I pass headers to an MCP server in LangGraph?

With the adapter, put headers in the server's connection dict. With langchain.mcp, set auth on a FastMCP Client, or headers on its StreamableHttpTransport.

Can LangGraph be an MCP server?

Yes. LangChain's docs say Agent Server exposes deployed agents as MCP tools at /mcp, over Streamable HTTP. It needs langgraph-api 0.2.3 or later.

Sources

All checked on 24 October 2026.