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 that exposes your flows as tools that MCP clients can use when generating responses.

For information about using Langflow as an MCP client and managing MCP server connections within flows, see Use Langflow as an MCP client.

Prerequisites

Serve flows as MCP tools

Each Langflow project has an MCP server that exposes the project's flows as tools for use by MCP clients.

By default, all flows in a project are exposed as tools on the project's MCP server. You can change the exposed flows and tool metadata by managing the MCP server settings:

  1. Click the MCP Server tab on the Projects page, or, when editing a flow, click Share, and then select MCP Server.

    MCP server projects page

    The Flows/Tools section lists the flows that are currently being served as tools on this MCP server.

  2. To toggle exposed flows, click Edit Tools, and then select the flows that you want exposed as tools. To prevent a flow from being used as a tool, clear the checkbox in the first column.

  3. Close the MCP Server Tools dialog to save your changes.

    MCP Server Tools

Edit flow tool names and descriptions

Tool names and descriptions help MCP clients determine which actions your flows provide and when to use those actions. It is recommended to provide clear, descriptive names and descriptions for all tools that you serve to MCP clients.

To edit the names and descriptions of flow tools on a Langflow MCP server, do the following:

  1. Click the MCP Server tab on the Projects page, or, when editing a flow, click Share, and then select MCP Server.

  2. Click Edit Tools.

  3. Click the Description or Tool that you want to edit:

    • 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 completely and accurately describes the specific actions the flow performs.

  4. Close the MCP Server Tools dialog to save your changes.

Importance of tool names and descriptions

MCP clients use tool names and descriptions to determine which actions to use when generating responses.

Because MCP clients treat your Langflow project as a single MCP server with all of your enabled flows listed as tools, unclear names and descriptions can cause the agent to select tools incorrectly or inconsistently.

For example, a flow's default tool 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 its 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.

Think of these names and descriptions as function names and code comments. Use clear statements to describe the problems your flows solve.

Example: Tool name and description usage

For example, assume you create a flow based on the Document Q&A template that uses an LLM to chat about resumes, and then 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.

Connect clients to your Langflow MCP server

Langflow provides automatic installation and code snippets to help you deploy your Langflow MCP servers to your local MCP clients.

The JSON option allows you to connect a Langflow MCP server to any local or remote MCP client. You can modify this process for any MCP-compatible client.

  1. Install any MCP-compatible client.

    These steps use Cursor as an example, but the process is generally the same for all clients, with slight differences in client-specific details like file names.

  2. In your client, add a new MCP server using the client's UI or configuration file.

    For example, in Cursor, go to Cursor Settings, select MCP, and then click Add New Global MCP Server to open Cursor's global mcp.json configuration file.

  3. Recommended: Configure authentication for your MCP server.

  4. In Langflow, on the Projects page, click the MCP Server tab.

  5. Click the JSON tab, copy the code snippet for your operating system, and then paste it into your client's MCP configuration file. 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 populates the PROJECT_NAME, LANGFLOW_SERVER_ADDRESS, and PROJECT_ID values.

    The default Langflow server address is http://localhost:7860. If you are using a public Langflow server, the server address is automatically included.

    If your Langflow server requires authentication, you must include your Langflow API key or OAuth settings in the configuration. For more information, see MCP server authentication.

  6. To include other environment variables with your MCP server command, add an env object with key-value pairs of environment variables:


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

  7. Save and close your client's MCP configuration file.

  8. Confirm that your Langflow MCP server is on the client's list of MCP servers. If necessary, restart your client to apply the modified configuration file.

Once your MCP client is connected to your Langflow project's MCP server, 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 MCP documentation for your client, such as Cursor's MCP documentation.

MCP server authentication

Each Langflow project has its own MCP server with its own MCP server authentication settings.

To configure authentication for a Langflow MCP server, go to the Projects page in Langflow, click the MCP Server tab, click Edit Auth, and then select your preferred authentication method:

When authenticating your MCP server with a Langflow API key, your project's MCP server JSON code snippets and Auto install configuration automatically include the --headers and x-api-key arguments.

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 environment variables

The following environment variables set behaviors related to your Langflow projects' MCP servers:

VariableFormatDefaultDescription
LANGFLOW_MCP_SERVER_ENABLEDBooleanTrueWhether to initialize an MCP server for each of your Langflow projects. If false, Langflow doesn't initialize MCP servers.
LANGFLOW_MCP_SERVER_ENABLE_PROGRESS_NOTIFICATIONSBooleanFalseIf true, Langflow MCP servers send progress notifications.
LANGFLOW_MCP_SERVER_TIMEOUTInteger20The number of seconds to wait before an MCP server operation expires due to poor connectivity or long-running requests.
LANGFLOW_MCP_MAX_SESSIONS_PER_SERVERInteger10Maximum number of MCP sessions to keep per unique server.

Deploy your Langflow MCP server externally

To deploy your Langflow MCP server externally, see Deploy a public Langflow server.

Use MCP Inspector to test and debug flows

Node prerequisite

MCP Inspector requires any LTS version of Node.js installed on your computer.

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. The field values depend on your server's method of authentication.

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

Troubleshoot Langflow MCP servers

For troubleshooting advice for MCP servers and clients, see Troubleshoot Langflow: MCP issues.

See also

Search