Short answer: configure an MCP client for each local or remote server, discover the server’s tools, then pass those tools to a LangChain agent. Python and JavaScript follow that same sequence, but their current adapter packages and error behavior differ. Pin the package generation you use, keep the client alive while the agent runs, and close it during cleanup.
This guide shows the current Python beta namespace and the current LangChain.js MCPAdapter pattern, explains the older APIs you may still encounter, and covers stdio, HTTP, authentication, tool naming, failures, approvals and deployment choices.
How the MCP-to-LangChain integration works
An MCP server advertises tools such as search, ticket updates or file operations. An adapter connects to that server, converts its MCP tool definitions into LangChain tools, and returns results in the format your agent already understands.
- Install and pin LangChain and the language-appropriate MCP adapter.
- Describe each server and its transport (local
stdioor remote HTTP). - Discover tools with the adapter.
- Give the resulting tools to
create_agent. - Invoke the agent while the client/session remains open.
- Close persistent clients in cleanup code and distinguish tool errors from connection failures.
Discovery and agent construction are separate operations. The model does not discover an MCP server by itself; your application must load the tools first.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
Python integration
Choose the Python API deliberately
The current LangChain documentation exposes langchain.mcp. It requires langchain[mcp]>=1.4.0 and is beta, so its API may change. The documented flow is MCPAdapter → list_tools() → create_agent. A separate package, langchain-mcp-adapters, is also used in LangChain support material and provides MultiServerMCPClient, get_tools() and load_mcp_tools. Do not mix imports from those generations without checking the version-specific documentation.
Install and pin
python -m pip install "langchain[mcp]>=1.4.0" langchain-openai
Pin the versions you deploy (for example in a lock file) after checking the API in your installed release. The example below uses the beta namespace documented by LangChain.
Connect to a local stdio server
import asyncio
import os
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter
from langchain_openai import ChatOpenAI
async def main():
adapter = MCPAdapter(
servers={
"local_tools": {
"transport": "stdio",
"command": "python",
"args": ["./mcp_server.py"],
# Put secrets in the environment or a secret manager.
"env": {"JIRA_TOKEN": os.environ["JIRA_TOKEN"]},
}
}
)
try:
tools = await adapter.list_tools()
model = ChatOpenAI(model=os.environ["OPENAI_MODEL"])
agent = create_agent(model=model, tools=tools)
result = await agent.ainvoke({
"messages": [("user", "List my open tickets and summarize them.")]
})
print(result["messages"][-1].content)
finally:
close = getattr(adapter, "close", None)
if close:
await close()
asyncio.run(main())
The server process is started by the client and communicates over standard input/output. Keep its lifetime inside the try block so all agent calls use the same session. The exact authentication and server configuration keys depend on the adapter and server implementation you installed.
Connect to a remote HTTP server
import asyncio
import os
from langchain.agents import create_agent
from langchain.mcp import MCPAdapter
from langchain_anthropic import ChatAnthropic
async def main():
adapter = MCPAdapter(
servers={
"company_mcp": {
"transport": "http",
"url": os.environ["MCP_URL"],
"headers": {
"Authorization": f"Bearer {os.environ['MCP_TOKEN']}"
},
}
}
)
try:
tools = await adapter.list_tools()
agent = create_agent(
model=ChatAnthropic(model=os.environ["ANTHROPIC_MODEL"]),
tools=tools,
)
answer = await agent.ainvoke({
"messages": [("user", "Find the latest deployment status.")]
})
print(answer["messages"][-1].content)
finally:
await adapter.close()
asyncio.run(main())
Use environment variables or a secret store for bearer tokens. Never commit credentials, place them in screenshots, or print them in logs. Remote hosting is optional: a local process is valid when the tool and data are on the same machine.
Recommended Free Tools
Using the separate adapter package
If your project already uses langchain-mcp-adapters, follow that package’s API instead of copying the beta imports above. Its commonly documented pattern is to configure a MultiServerMCPClient, call get_tools() (or load tools through load_mcp_tools), then pass the returned list to create_agent. Check the installed package documentation before choosing synchronous versus asynchronous cleanup.
Python result and error semantics
A server can return a tool result with isError=True. The Python integration represents that as a LangChain ToolMessage with status="error", allowing the model or your application to react. A transport or session failure instead raises an exception because the model cannot recover from a dropped connection. Structured MCP content is attached as an artifact; text and multimodal values are exposed through standardized content blocks.
Rank #2
Approvals, metadata and elicitation
MCP metadata can include server identity and annotations. Destructive hints are useful for routing a tool through LangGraph human-in-the-loop approval. MCP elicitation lets a server pause a tool call and request information from a person. Neither feature is an automatic safety boundary: define which tools require approval, validate arguments, and record the decision.
JavaScript and TypeScript integration
Install the current adapter
npm install @langchain/mcp-adapters @langchain/core @langchain/langgraph
The current adapter README uses MCPAdapter. Older examples use MultiServerMCPClient; both patterns are not interchangeable, so keep the imports and lifecycle instructions from one package generation together.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRemote HTTP example with MCPAdapter
import { MCPAdapter } from "@langchain/mcp-adapters";
import { ChatOpenAI } from "@langchain/openai";
import { createAgent } from "langchain";
const adapter = new MCPAdapter({
servers: {
company_mcp: {
transport: "http",
url: process.env.MCP_URL,
headers: { Authorization: `Bearer ${process.env.MCP_TOKEN}` },
},
},
});
try {
const tools = await adapter.listTools();
const model = new ChatOpenAI({ model: process.env.OPENAI_MODEL });
const agent = createAgent({ model, tools });
const result = await agent.invoke({
messages: [{ role: "user", content: "Find the latest deployment status." }],
});
console.log(result.messages.at(-1)?.content);
} catch (error) {
console.error("Agent or MCP call failed:", error);
} finally {
await adapter.close();
}
Keep the adapter open for every call the agent may make, then await close() in a finally block. The README recommends prefixing tool names with the server name when several servers may expose identical names; apply that convention in your selection or routing code.
Local stdio configuration
const adapter = new MCPAdapter({
servers: {
local_tools: {
transport: "stdio",
command: "python",
args: ["./mcp_server.py"],
},
},
});
const tools = await adapter.listTools();
For a local server, the adapter launches the command and exchanges messages over stdin/stdout. For a hosted server, supply its HTTP URL and the headers required by that service.
The older MultiServerMCPClient pattern
Broader LangChain.js documentation still shows MultiServerMCPClient: configure a stdio server or an HTTP server, call getTools(), and pass the result to createAgent. Treat those examples as versioned guidance. The adapter SDK can negotiate modern and legacy modes; explicit modern mode requires MCP revision 2026-07-28, while legacy mode enables legacy options. Avoid hard-coding a revision unless your server and client require it.
JavaScript error behavior
The JavaScript documentation says an MCP result with isError: true causes @langchain/mcp-adapters to throw ToolException, rather than returning a failed tool message to the model as described for Python. Wrap agent invocation and direct tool calls in try/catch, log a safe error identifier, and decide whether to retry or ask the user for another input. Connection, authentication and session failures also need exception handling.
Free tools Windows power users keep installed
One-click scans. No signup required.
Choosing transport, authentication and deployment
| Choice | Use it when | Operational considerations |
|---|---|---|
| stdio | The MCP server runs locally with your application. | The client launches a process; manage its command, arguments, environment and shutdown. |
| HTTP/streamable HTTP | The server is hosted remotely or shared by several applications. | Configure URL, headers and credentials; ensure the server can reach private systems. |
| SSE or other legacy mode | An older server or adapter requires it. | Check both versions and current protocol documentation before copying legacy settings. |
A self-hosted Jira, Slack or Confluence MCP must have network access to that system and suitable credentials. The adapter does not grant permissions that the MCP server itself lacks. Rotate tokens, use least privilege and keep secrets outside source control.
Using multiple MCP servers safely
- Give every server a stable name such as
jira,slackorconfluence. - Discover tools from each server before constructing the agent.
- Namespace duplicate tool names with the server name.
- Expose only the tools needed for the task; fewer tools reduce accidental actions.
- Require human approval for deletion, sending messages, financial changes or other destructive operations.
LangChain support describes this adapter approach as compatible with OSS chat-model integrations including ChatOpenAI and ChatAnthropic. That is interoperability at the tool interface, not a guarantee that every provider handles every schema identically; configure and test the model account separately.
Performance, reliability and cost decisions
- Reuse sessions: keep one adapter open for a coherent run instead of reconnecting for every tool call.
- Limit discovery: load only the servers and tools an agent needs.
- Set timeouts: use client, HTTP and model timeouts appropriate to the slowest upstream system.
- Retry selectively: retry transient network failures, not validation errors or destructive calls.
- Separate logs: record server, tool, request ID and duration without recording tokens or sensitive arguments.
- Plan for restarts: a dropped stdio process or HTTP session requires reconnection and, if necessary, a fresh tool discovery.
There is no independent performance statistic established for these adapters. Measure your own server latency, model latency and tool-call failure rate under representative workloads.
Troubleshooting
Import or installation errors
Symptom: langchain.mcp or MCPAdapter cannot be imported. Fix: verify the package generation and pinned version. Python’s namespace needs langchain[mcp]>=1.4.0; JavaScript needs the adapter packages shown above. Do not combine langchain.mcp imports with langchain-mcp-adapters examples.
No tools are returned
Cause: the server command, URL, transport or authentication is wrong, or the process exits immediately. Run the server independently, inspect its stderr, verify the URL from the same network, and call the adapter’s list-tools method before creating the agent.
Authentication or authorization failures
Check header spelling, token scope, expiry and server-side permissions. Load values from environment variables and confirm that a reverse proxy is forwarding authorization headers.
Duplicate or confusing tool names
Namespace names with the server identifier and select tools explicitly. This prevents a Jira tool from being confused with a similarly named Slack tool.
Agent hangs or exits before a result
Keep the adapter alive until the final response, set transport and model timeouts, and close it only in cleanup. For stdio, confirm the child process is not writing protocol-breaking output to stdout.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A tool error behaves differently by language
In Python, inspect the returned failed ToolMessage. In JavaScript, catch ToolException and decide whether to retry, report the failure, or request corrected input.
Or skip the browser setup
If an MCP agent needs a screenshot tool, ScreenshotNeo provides a website screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP or PDF; before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status.
One request is enough:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for all 63 options, including full-page and element capture, device and retina settings, dark mode, PDF controls, custom CSS/JavaScript, clicks, waits, request blocking, headers, cookies, geolocation, resizing, caching, signed links, asynchronous webhooks, bulk capture and usage data. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000; every feature is on every plan. Create a free ScreenshotNeo account.
FAQ
Can I connect JIRA, Slack and Confluence MCPs with LangChain?
Yes. Configure each server under a distinct name, discover all tools, namespace duplicates, and pass the combined list to one agent. Give each server only the credentials and network access it needs.
Best Value
Can I use Anthropic models with MCP servers in LangChain?
Yes. The adapter presents standard LangChain tools, and LangChain support lists ChatAnthropic among compatible OSS integrations. You still need a configured Anthropic model account and should verify schema behavior in your chosen model version.
Is HTTP required?
No. A local stdio process is appropriate when the server runs beside your application. HTTP or streamable HTTP is useful for hosted or shared servers.
Should I use Python or JavaScript?
Choose the language already used by your agent. The important differences are adapter generation, cleanup APIs and error handling, not a general superiority of one language.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesFrequently Asked Questions
Is MCP itself a model provider?
No. MCP supplies tools and resources; LangChain still needs a configured chat model to decide when to call those tools.
Do I need to host an MCP server remotely?
No. The documented stdio transport launches a local server process; remote HTTP is an alternative for hosted or shared services.
The Bottom Line
MCP integration is a deliberate pipeline: configure the right adapter, discover tools, pass them to the agent, handle language-specific failures, and close the client after calls finish. Pin versions because both protocol and adapter APIs continue to evolve.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

