Skip to main content

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

Select and configure flows to expose as MCP tools

MCP flow requirements

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:

  1. 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.

    MCP server projects page

  2. Click Edit Tools.

  3. In the MCP Server Tools window, select the flows that you want exposed as tools.

    MCP server tools

  4. 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 the document_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 that document_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:


    _10
    I notice you're asking about Alex's job experience.
    _10
    Based on the available tools, I can see there is a Document QA for Resume flow that's designed for analyzing resumes.
    _10
    However, 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.

  5. 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.

  1. Install Cursor.

  2. In the Langflow dashboard, select the project that contains the flows you want to serve, and then click the MCP Server tab.

  3. 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.

    important

    Auto 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.

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.

MCP server tab showing Generate API key button

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:

  1. Install MCP Inspector:


    _10
    npx @modelcontextprotocol/inspector

    For more information about configuring MCP Inspector, including specifying a proxy port, see the MCP Inspector GitHub project.

  2. Open a web browser and navigate to the MCP Inspector UI. The default address is http://localhost:6274.

  3. 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, and PROJECT_ID with the values from your Langflow MCP server. For example:

    _10
    mcp-proxy --headers x-api-key YOUR_API_KEY http://LANGFLOW_SERVER_ADDRESS/api/v1/mcp/project/PROJECT_ID/sse

  4. 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.

  5. 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.

  1. To find your UVX path, run which uvx. To find your NPX path, run which npx.

  2. Copy the path, and then replace PATH_TO_UVX or PATH_TO_NPX in your claude_desktop_config.json file.


_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
}

See also

Search