Use Langflow as an MCP server
Langflow integrates with the Model Context Protocol (MCP) as both an MCP server and an MCP client.
This page describes how to use Langflow as an MCP server.
For information about using Langflow as an MCP client, see Use Langflow as an MCP client.
As an MCP server, Langflow exposes your flows as tools that MCP clients can use to take actions.
Prerequisites
-
A Langflow project with at least one flow.
-
Any LTS version of Node.js installed on your computer to use MCP Inspector to test and debug flows.
-
ngrok installed and an ngrok authtoken if you want to deploy a public Langflow server.
Select and configure flows to expose as MCP tools
A flow must contain a Chat Output component to be used as a tool by MCP clients.
Each Langflow project has an MCP server that exposes the project's flows as tools that MCP clients can use to generate responses.
By default, all flows in a project are exposed as tools on the project's MCP server.
The following steps explain how to limit the exposed flows and, optionally, rename flows for agentic use:
-
From the Langflow dashboard, select the project that contains the flows you want to serve as tools, and then click the MCP Server tab. Alternatively, you can quickly access the MCP Server tab from within any flow by selecting Share > MCP Server.
The Auto install and JSON tabs display options for connecting MCP clients to the the project's MCP server.
The Flows/Tools section lists the flows that are currently being served as tools.
-
Click Edit Tools.
-
In the MCP Server Tools window, select the flows that you want exposed as tools.
-
Recommended: Edit the Tool Name and Tool Description to help MCP clients determine which actions your flows provide and when to use those actions:
-
Tool Name: Enter a name that makes it clear what the flow does when used as a tool by an agent.
-
Tool Description: Enter a description that accurately describes the specific actions the flow performs.
Name and describe your flows for agentic use
MCP clients use the Tool Name and Tool Description to determine which action to use.
MCP clients like Cursor treat your Langflow project as a single MCP server with all of your enabled flows listed as tools.
This can confuse agents if the flows have unclear names or descriptions. For example, a flow's default name is the flow ID, such as
adbbf8c7-0a34-493b-90ea-5e8b42f78b66
. This provides no information to an agent about the type of flow or it's purpose.To provide more context about your flows, make sure to name and describe your flows clearly when configuring your Langflow project's MCP server.
It's helpful to think of the names and descriptions as function names and code comments, using clear statements describing the problems your flows solve.
For example, assume you have a Document Q&A flow that uses an LLM to chat about resumes, and you give the flow the following name and description:
-
Tool Name:
document_qa_for_resume
-
Tool Description:
A flow for analyzing Emily's resume.
After connecting your Langflow MCP server to Cursor, you can ask Cursor about the resume, such as
What job experience does Emily have?
. Using the context provided by your tool name and description, the agent can decide to use thedocument_qa_for_resume
MCP tool to create a response about Emily's resume. If necessary, the agent asks permission to use the flow tool before generating the response.If you ask about a different resume, such as
What job experience does Alex have?
, the agent can decide thatdocument_qa_for_resume
isn't relevant to this request, because the tool description specifies that the flow is for Emily's resume. In this case, the agent might use another available tool, or it can inform you that it doesn't have access to information about Alex's. For example:_10I notice you're asking about Alex's job experience._10Based on the available tools, I can see there is a Document QA for Resume flow that's designed for analyzing resumes._10However, the description mentions it's for "Emily's resume" not Alex's. I don't have access to Alex's resume or job experience information. -
-
Close the MCP Server Tools window to save your changes.
Connect clients to Langflow's MCP server
The following procedure describes how to connect Cursor to your Langflow project's MCP server to consume your flows as tools. However, you can connect any MCP-compatible client following similar steps.
- Auto install
- JSON
-
Install Cursor.
-
In the Langflow dashboard, select the project that contains the flows you want to serve, and then click the MCP Server tab.
-
To auto install your current Langflow project as an MCP server, click Add. The installation adds the server's configuration file to Cursor's
mcp.json
configuration file.importantAuto installation only works if your HTTP client and Langflow server are on the same local machine. In this is not the case, configure the client with the code in the JSON tab.
-
Install Cursor.
-
In Cursor, go to Cursor Settings > MCP, and then click Add New Global MCP Server. This opens Cursor's global MCP configuration file,
mcp.json
. -
In the Langflow dashboard, select the project that contains the flows you want to serve, and then click the MCP Server tab.
-
Copy the code template from the JSON tab, and then paste it into
mcp.json
in Cursor. For example:_11{_11"mcpServers": {_11"PROJECT_NAME": {_11"command": "uvx",_11"args": [_11"mcp-proxy",_11"http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse"_11]_11}_11}_11}The MCP Server tab automatically includes the correct
PROJECT_NAME
,LANGFLOW_SERVER_ADDRESS
, andPROJECT_ID
values. The default Langflow server address ishttp://localhost:7860
.If you have deployed a public Langflow server, the address is automatically included.
importantIf your Langflow server requires authentication (
LANGFLOW_AUTO_LOGIN
is set tofalse
), you must include your Langflow API key in the configuration. For more information, see MCP server authentication and environment variables. -
Save and close the
mcp.json
file in Cursor. The newly added MCP server will appear in the MCP Servers section.
Cursor is now connected to your project's MCP server and your flows are registered as tools. Cursor determines when to use tools based on your queries, and requests permissions when necessary. For more information, see the Cursor's MCP documentation.
MCP server authentication and environment variables
If your Langflow server requires authentication (LANGFLOW_AUTO_LOGIN
is set to false
), then you must supply a Langflow API key in your MCP client configuration.
When this is the case, the code template in your project's MCP Server tab automatically includes the --header
and x-api-key
arguments:
_14{_14 "mcpServers": {_14 "PROJECT_NAME": {_14 "command": "uvx",_14 "args": [_14 "mcp-proxy",_14 "--headers",_14 "x-api-key",_14 "YOUR_API_KEY",_14 "http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse"_14 ]_14 }_14 }_14}
Click Generate API key to automatically insert a new Langflow API key into the code template.
Alternatively, you can replace YOUR_API_KEY
with an existing Langflow API key.
To include environment variables with your MCP server command, include them like this:
_14{_14 "mcpServers": {_14 "PROJECT_NAME": {_14 "command": "uvx",_14 "args": [_14 "mcp-proxy",_14 "http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse"_14 ],_14 "env": {_14 "KEY": "VALUE"_14 }_14 }_14 }_14}
Replace KEY
and VALUE
with the environment variable name and value you want to include.
Deploy your MCP server externally
To deploy your MCP server externally with ngrok, see Deploy a public Langflow server.
Use MCP Inspector to test and debug flows
MCP Inspector is a common tool for testing and debugging MCP servers. You can use MCP Inspector to monitor your flows and get insights into how they are being consumed by the MCP server:
-
Install MCP Inspector:
_10npx @modelcontextprotocol/inspectorFor more information about configuring MCP Inspector, including specifying a proxy port, see the MCP Inspector GitHub project.
-
Open a web browser and navigate to the MCP Inspector UI. The default address is
http://localhost:6274
. -
In the MCP Inspector UI, enter the connection details for your Langflow project's MCP server:
- Transport Type: Select SSE.
- URL: Enter the Langflow MCP server's
sse
endpoint. For example:http://localhost:7860/api/v1/mcp/project/d359cbd4-6fa2-4002-9d53-fa05c645319c/sse
If you've configured authentication for your MCP server, fill out the following additional fields:
- Transport Type: Select STDIO.
- Command:
uvx
- Arguments: Enter the following list of arguments, separated by spaces. Replace the values for
YOUR_API_KEY
,LANGFLOW_SERVER_ADDRESS
, andPROJECT_ID
with the values from your Langflow MCP server. For example:
_10mcp-proxy --headers x-api-key YOUR_API_KEY http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse -
Click Connect.
If the connection was successful, you should see your project's flows in the Tools tab. From this tab, you can monitor how your flows are being registered as tools by MCP, as well as test the tools with custom input values.
-
To quit MCP Inspector, press Control+C in the same terminal window where you started it.
Troubleshooting MCP server
If Claude for Desktop is not using your server's tools correctly, you may need to explicitly define the path to your local uvx
or npx
executable file in the claude_desktop_config.json
configuration file.
-
To find your UVX path, run
which uvx
. To find your NPX path, runwhich npx
. -
Copy the path, and then replace
PATH_TO_UVX
orPATH_TO_NPX
in yourclaude_desktop_config.json
file.
- uvx
- npx
_11{_11 "mcpServers": {_11 "PROJECT_NAME": {_11 "command": "PATH_TO_UVX",_11 "args": [_11 "mcp-proxy",_11 "http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse"_11 ]_11 }_11 }_11}
_13{_13 "mcpServers": {_13 "PROJECT_NAME": {_13 "command": "PATH_TO_NPX",_13 "args": [_13 "-y",_13 "supergateway",_13 "--sse",_13 "http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse"_13 ]_13 }_13 }_13}