The
langchain.mcp namespace requires langchain[mcp]>=1.4.0 and is in beta. The API may change.MCPAdapter bridges MCP servers and LangChain agents: it discovers the tools a server advertises and adapts them into standard LangChain tools. Pass the tools from list_tools() to create_agent as you would any other LangChain tool.
This page covers what is specific to that bridge: identifying MCP tools, controlling their execution, handling their outputs, and responding when a server needs input during a call. For the runnable discovery-and-agent example, see the MCP quickstart.
Use MCP tools in an agent
Discover the server’s catalog withMCPAdapter.list_tools, then give the returned tools to create_agent. From the agent’s perspective, they behave like LangChain tools: the model chooses a tool, LangChain invokes it, and the resulting ToolMessage returns to the model.
View example trace
Open a public LangSmith run for this example.
Handle tool outputs
MCP tool results becomeToolMessage objects with content the model can read, an artifact for application data, and a status indicating success or failure.
Multimodal content
The adapter converts model-visible MCP content into LangChain content blocks. For example, a tool that returns an MCP image block with a screenshot reaches the model as animage block.
Structured content
When a tool returns structured content, the adapter attaches it to theToolMessage as an artifact rather than folding it into the model-visible text. Run the agent, then read the artifact from the ToolMessage instances in the result:
MCPToolArtifact, whose structured_content field holds the tool result’s structuredContent. A tool that returns no structured content leaves artifact as None.
Errors
An MCP tool result carries anisError flag. When a server reports isError=True, the adapter converts it into a ToolMessage with status="error" carrying the server’s own message, so the agent can read it and correct itself:
Tool metadata
Each adapted tool may carry its MCP provenance under anmcp namespace on the LangChain tool’s metadata:
_meta, server identity, any combination of those, or none. annotations contains MCP hints such as read_only_hint and destructive_hint; _meta is opaque metadata supplied by the server; and server identifies the MCP implementation that advertised the tool.
Read optional metadata defensively, so a missing field returns a default rather than failing:
Human-in-the-loop
Reading annotations lets you gate a tool based on what the server declares about it, rather than hardcoding tool names. The MCP annotation classifies the tool and LangChain’s human-in-the-loop middleware enforces the approval policy. Read the destructive hint from metadata once during tool discovery. Then give the human-in-the-loop configuration awhen predicate that receives each pending tool call and returns whether the call needs approval:
delete_file call targeting a protected path.
Access the arguments through request.tool_call["args"].
Combine the metadata classification and argument check to gate a tool only when its type and inputs warrant approval. For the full approval workflow, see Human-in-the-loop.
Server requests during tool execution
Most tools finish without asking the client for anything mid-call. When a server needs input,MCPAdapter surfaces elicitation as a LangGraph interrupt.
Elicitation
Elicitation lets an MCP server request input during a tool call. The adapter pauses the run with a LangGraph interrupt. Your application presents the request to the user and resumes the run with their answer. Attach a checkpointer to the agent and use the samethread_id when invoking and resuming it.
This example assumes the booking tool asks for one date and pauses once. Replace the sample date with the user’s answer.
Command(resume={"responses": {key: answer}}). The interrupt payload and answer types live in langchain.mcp.elicitation.
Resuming reruns the tool from the beginning. Any work performed before the server asks for input can repeat. Make that work safe to repeat without duplicating side effects.
accept: Provide formcontentmatching the request’s schema, or confirm completion of a URL interaction withoutcontent.decline: Refuse to provide the requested information.cancel: Indicate that the user canceled the interaction.
Interrupt-driven elicitation answers a server that returns its request as an
InputRequiredResult. A server that only pushes elicitation over a legacy handshake session cannot be answered this way.See also
- Content blocks
- Tools
- Human-in-the-loop
- FastMCP calling tools
- FastMCP client elicitation
- FastMCP server elicitation
- MCP elicitation specification
- MCP tool annotations
Connect these docs to your agent of choice via MCP for real-time answers.

