Setting Up LangChain MCP Server in Cursor 2026
Updated: April 16, 2026
LangChain MCP in Cursor
Quick answer: Install the LangChain MCP server with npx -y langchain-mcp-server, drop the JSON block below into .cursor/mcp.json at your project root, toggle the server on under Settings > Features > MCP Servers, then type @ inside Cursor Composer to see the new tools appear. Setup runs about 4 minutes on a fresh machine, verified on langchain-mcp-server as of April 15, 2026.
The LangChain MCP server gives Cursor Composer a direct tool surface on LangChain. After wiring, the agent mode in Composer can call run_chain, run_agent, load_document, query_index, list_tools without you leaving the editor. For developers who work with LangChain every day, that removes the context switch between code and the LangChain UI or CLI.
This guide walks through the exact config, how to enable MCP inside Cursor's settings panel, how to verify with @ mentions in Composer, five prompt patterns that return clean results, and the four issues that account for most of the support tickets we see in the first week of use.
What Cursor Composer gains with this server
Cursor Composer has two main modes. Ask mode answers questions with read-only context. Agent mode takes actions across files and external systems. The LangChain server fits both: in Ask mode it pulls chains into context for you to reference in a prompt; in Agent mode it reads and writes chains as part of a multi-step task.
Tool calls show up inline in Composer as a collapsed block under the assistant's message. Click to expand and see the exact arguments sent and the response returned. That trace is the single best debug surface when a prompt does not do what you expected, and it makes the server feel less like a black box over time.
Prerequisites
You need LLM provider API key plus optional vector store credentials. Store the value in an env var called OPENAI_API_KEY or paste it directly into the config file you edit in the next step.
Confirm Node.js is on PATH at version 18 or newer. Open Cursor's built-in terminal and run node -v. If Cursor cannot find Node, it will fail to spawn the server and the MCP panel will show a red error. On macOS with nvm, add a default alias (nvm alias default 20) so Cursor picks up a version even when not in a project shell.
You also need Cursor 0.42 or newer. MCP support landed in Cursor 0.41 but the Composer @-mention UI for MCP tools stabilized in 0.42. Check your version under Cursor > About Cursor.
Install via npx
Run the package once in a terminal to verify it starts cleanly before wiring it into Cursor:
npx -y langchain-mcp-server
The first run downloads the package from npm (usually 2 to 10 MB), then starts the server on stdio. The server does not print much on success - it waits for MCP protocol messages on standard input. Press Ctrl-C to stop it. Cursor itself handles launching the process during real use, so this manual run is purely a smoke test.
If the install fails with a registry error, set npm config set registry https://registry.npmjs.org and retry. Behind a corporate proxy, export HTTP_PROXY and HTTPS_PROXY in your shell before launching Cursor.
Add the config block to .cursor/mcp.json
Cursor reads MCP config from .cursor/mcp.json in each project root. Open (or create) that file at the top of your repo and add the following JSON:
{
"mcpServers": {
"langchain": {
"command": "npx",
"args": ["-y", "langchain-mcp-server"],
"env": {
"OPENAI_API_KEY": "your-value-here"
}
}
}
}
If you already have other MCP servers defined, merge this entry into the existing mcpServers object rather than replacing it. JSON comments are not supported so keep the file plain.
For servers you want available across every project, create ~/.cursor/mcp.json with the same structure. Cursor merges project config on top of the global file, so per-project overrides still work.
Enable MCP in Cursor Settings
Open Cursor Settings (Cmd+, on macOS, Ctrl+, on Windows and Linux). Click Features in the left panel and scroll to the MCP Servers section. The langchain server you just added should appear in the list. Toggle the switch next to it to enable the server.
Cursor spawns the server the moment you toggle it on. If the toggle snaps back to off, click the error icon next to it to see stderr from the failed process - 9 times out of 10 that output tells you exactly what is wrong. Common causes: wrong env var name, missing credential, or Node not on PATH for the process Cursor launched.
After a successful start the indicator turns green and a small count appears showing how many tools the server exposes. LangChain registers around 9 tools depending on version.
Verify in Cursor Composer
Open Cursor Composer with Cmd+I (or Ctrl+I). Type @ to bring up the mention picker. Scroll down past the file and symbol suggestions and you should see a Tools section that lists the langchain tools by name. That visual confirmation is the simplest signal the server is wired correctly.
Send a short verification prompt. For read servers, ask for a list of chains. For write servers, ask to describe a known chains first, then try a safe write on a test chains where a mistake does no harm. A response that includes a tool call trace (not just the model's guess) confirms the round trip works.
If @ does not show the tools, go back to Settings > Features > MCP Servers, toggle the server off and on, and watch for errors. Cursor caches MCP state per window, so sometimes a full restart of Cursor is needed after a config change.
Example Cursor Composer prompts
Prompts below tend to produce clean results once the LangChain server is attached. Mix Ask mode for reads and Agent mode for writes:
- Show me every chains I have access to through the langchain server and summarize what each one contains.
- Using the langchain tools, pull the last 10 chains and paste the raw result into a new file called scratch.md.
- In Agent mode, create a new chains with the details I list below, then confirm the ID that came back.
- Walk through each step of the plan I paste and call the appropriate langchain tool for each one, showing me the trace as you go.
- Compare the two chains named A and B using the langchain server and output a diff of the fields that changed.
When a prompt fires too many tool calls, narrow the scope. Specify an exact ID, a date range, or a single field rather than asking Composer to scan everything. For batch operations, tell the model explicitly to group calls into sets of 10 or to page through results, which keeps token usage reasonable.
YOLO mode considerations
Cursor's auto-accept (sometimes called YOLO mode) lets Composer run tool calls and apply edits without asking for confirmation each time. For read-only servers that is usually fine. For a server like langchain that can write chains, enabling YOLO means the agent can mutate real data without a prompt in front of a human reader.
Good practice: keep YOLO off by default, then turn it on for a specific Composer session where you trust the scope. Some teams run a second Cursor profile with a read-only credential and enable YOLO only there, so the blast radius is capped by the token itself rather than by user discipline.
Cursor exposes an allow-list of tools that auto-run even when YOLO is off. Review that list under Settings > Features > Composer. Remove any destructive langchain tool (delete, drop, destroy) from the allow-list so the agent is forced to ask before calling it.
Troubleshooting
Server shows red under Settings > Features > MCP Servers. Click the error icon to see stderr. The message usually names the missing piece - bad credential, wrong env var, Node not found. Fix the cause, then toggle the server off and on; Cursor does not auto-retry after a config edit.
Tools do not appear when I type @ in Composer. Either the server is not running (check the MCP panel), the Composer view was opened before the server started (close and reopen Composer), or the Cursor version is older than 0.42 (update under Cursor > Check for Updates).
Auth error on the first real tool call. The token lives in OPENAI_API_KEY. Double-check spelling of the env var name in .cursor/mcp.json, then restart the server via the toggle. Cursor reads env values from the config file only, not from your shell, so exporting the var in .zshrc has no effect on Cursor-launched processes.
Tool call times out or hangs. Default timeout in Cursor is 60 seconds per call. For long-running langchain operations like large exports or batch writes, break the work into smaller prompts or use tools that support pagination. You can raise the timeout under Settings > Features > MCP but the better fix is narrower prompts.
Next steps
Now that the LangChain server is live in Cursor, the practical follow-up is a short prompt library you keep next to the editor. Write down the 4 or 5 prompts you run most against langchain, tune the wording over a week, and paste them into Composer when the task comes up. That beats typing from scratch every time and captures the knowledge of what actually returns useful results.
For team-wide rollout, commit .cursor/mcp.json to the repo so every teammate gets the same server wired up on first open. Keep secrets out of the file by using env var references or by documenting the setup in your README. Between the repo config and a shared prompt library, onboarding a new engineer to a Cursor-plus-langchain workflow drops from half a day to 20 minutes.
Frequently asked questions
Does the LangChain MCP server work in Cursor the same way it works in Claude Code?
Yes. The MCP protocol is client-agnostic, so the same server binary and the same env vars work in Cursor, Claude Code, Windsurf, and any other MCP client. The only difference is where the config lives: Cursor reads `.cursor/mcp.json`, Claude Code reads `~/.claude/settings.json`. The JSON structure inside is the same.
How do I scope auth for safer use of langchain in Cursor?
When you generate the openai_api_key credential, pick the narrowest scope that covers your task - read-only where possible, write scopes only when needed. Rotate the value on a schedule and never commit it to a tracked file. For shared repos, reference the env var name in `.cursor/mcp.json` but keep the actual value in a teammate-specific shell profile.
Can I pin langchain-mcp-server to a specific version in Cursor?
Yes. Change the args array from `["-y", "langchain-mcp-server"]` to `["-y", "langchain-mcp-server@1.2.3"]` with the version you want. That stops npx from pulling the latest release on every spawn. Lock to a pinned version on shared repos so a surprise breaking change in the server does not take the team down. Update on your own cadence.
Why do my langchain tools disappear after Cursor updates?
Cursor sometimes resets the MCP toggle state after a major update. Reopen Settings > Features > MCP Servers, confirm the `langchain` entry is still there, and toggle it back on. If the entry is gone, check that `.cursor/mcp.json` still lives at the project root and was not moved or renamed by a branch switch. Reloading the window with Cmd+Shift+P > Reload Window usually clears stale state.
Can I use multiple instances of LangChain MCP in one Cursor workspace?
Yes. Give each instance a different key in the `mcpServers` object - for example, `langchain-prod` and `langchain-staging` - with different env values pointing at each environment. Cursor lists them separately in the MCP panel and in the `@` mention picker. A common pattern is one read-only instance and one write instance, so you have to explicitly pick the write tools when you need them.
What shows up in the Composer tool call trace, and is it safe to share?
The trace shows the tool name, the JSON arguments passed from Composer to the server, and the response the server returned. Arguments can include chains IDs, filter values, and any text you asked the agent to send. Responses can include raw chains data. Redact before sharing on a support ticket or public forum, especially if the langchain tokens have broad scope or the data is sensitive.