|
| 1 | +--- |
| 2 | +title: Integrate Langflow with MCP |
| 3 | +slug: /integrations-mcp |
| 4 | +--- |
| 5 | + |
| 6 | +import Tabs from '@theme/Tabs'; |
| 7 | +import TabItem from '@theme/TabItem'; |
| 8 | + |
| 9 | +Langflow integrates with the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction). This allows you to use your Langflow flows as tools in client applications that support the MCP, or extend Langflow with the [MCP server component](/components-tools#mcp-tools-stdio) to access MCP servers. |
| 10 | + |
| 11 | +You can use Langflow as an MCP server with any [MCP client](https://modelcontextprotocol.io/clients). |
| 12 | + |
| 13 | +For configuring interactions between Langflow flows and MCP tools, see [Name and describe your flows for agentic use](#name-and-describe-your-flows-for-agentic-use). |
| 14 | + |
| 15 | +To connect [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) to Langflow for testing and debugging flows, see [Install MCP Inspector to test and debug flows](#install-mcp-inspector-to-test-and-debug-flows) |
| 16 | + |
| 17 | +## Access all of your flows as tools |
| 18 | + |
| 19 | +:::important |
| 20 | +Tool names must contain only letters, numbers, underscores, and dashes. |
| 21 | +Tool names cannot contain spaces. |
| 22 | +To re-name flows in the Langflow UI, click **Flow Name** > **Edit Details**. |
| 23 | +::: |
| 24 | + |
| 25 | +Connect an MCP client to Langflow to use your flows as tools. |
| 26 | + |
| 27 | +1. Install [Cursor](https://docs.cursor.com/) or [Claude for Desktop](https://claude.ai/download). |
| 28 | +2. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) to run `uvx` commands. `uvx` is included with `uv` in the Langflow package. |
| 29 | +3. Optional: Install an LTS release of [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to run `npx` commands. |
| 30 | +For an example `npx` server, see [Connect an Astra DB MCP server to Langflow](/mcp-component-astra). |
| 31 | +4. Create at least one flow, and note your host. For example, `http://127.0.0.1:7860`. |
| 32 | + |
| 33 | +<Tabs> |
| 34 | +<TabItem value="cursor" label="Cursor"> |
| 35 | + |
| 36 | +In Cursor, you can configure a Langflow server in the same way as other MCP servers. |
| 37 | +For more information, see the [Cursor MCP documentation](https://docs.cursor.com/context/model-context-protocol). |
| 38 | + |
| 39 | +1. Open Cursor, and then go to **Cursor Settings**. |
| 40 | +2. Click MCP, and then click **Add New Global MCP Server**. |
| 41 | +Cursor's MCP servers are listed as JSON objects. |
| 42 | +3. To add a Langflow server, add an entry for your Langflow server's `/v1/mcp/sse` endpoint. |
| 43 | +This example assumes the default Langflow server address of `http://127.0.0.1:7860`. |
| 44 | +```json |
| 45 | +{ |
| 46 | + "mcpServers": { |
| 47 | + "langflow": { |
| 48 | + "url": "http://127.0.0.1:7860/api/v1/mcp/sse" |
| 49 | + } |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
| 53 | +4. Save the `mcp.json` file, and then click the **Reload** icon. |
| 54 | +5. Your Langflow server is now available to Cursor as an MCP server, and all of its flows are registered as tools. |
| 55 | +You can now use your flows as tools in Cursor. |
| 56 | +Cursor determines when to use tools based on your queries, and will request permissions when necessary. |
| 57 | + |
| 58 | +</TabItem> |
| 59 | + |
| 60 | +<TabItem value="claude for desktop" label="Claude for Desktop"> |
| 61 | + |
| 62 | +In Claude for Desktop, you can configure a Langflow server in the same way as other MCP servers. |
| 63 | +For more information, see the [Claude for Desktop MCP documentation](https://modelcontextprotocol.io/quickstart/user). |
| 64 | + |
| 65 | +1. Open Claude for Desktop, and then go to the program settings. |
| 66 | +For example, on the MacOS menu bar, click **Claude**, and then select **Settings**. |
| 67 | +2. In the **Settings** dialog, click **Developer**, and then click **Edit Config**. |
| 68 | +This creates a `claude_desktop_config.json` file if you don't already have one. |
| 69 | +3. Add the following code to `claude_desktop_config.json`. |
| 70 | +Your args may differ for your `uvx` and `Python` installations. To find the correct paths: |
| 71 | + |
| 72 | + * For `uvx`: Run `which uvx` in your terminal |
| 73 | + * For Python: Run `which python` in your terminal |
| 74 | + |
| 75 | +Replace `PATH/TO/PYTHON` with the Python path from your system. |
| 76 | +This command assumes the default Langflow server address of `http://127.0.0.1:7860`. |
| 77 | + |
| 78 | +```json |
| 79 | +{ |
| 80 | + "mcpServers": { |
| 81 | + "langflow": { |
| 82 | + "command": "/bin/sh", |
| 83 | + "args": ["-c", "uvx --python PATH/TO/PYTHON mcp-sse-shim@latest"], |
| 84 | + "env": { |
| 85 | + "MCP_HOST": "http://127.0.0.1:7860", |
| 86 | + "DEBUG": "true" |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +This code adds a new MCP server called `langflow` and starts the [mcp-sse-shim](https://github.com/phact/mcp-sse-shim) package using the specified Python interpreter and uvx. |
| 94 | + |
| 95 | +4. Restart Claude for Desktop. |
| 96 | +Your new tools are available in your chat window. Click the tools icon to see a list of your flows. |
| 97 | + |
| 98 | +You can now use your flows as tools in Claude for Desktop. |
| 99 | + |
| 100 | +Claude determines when to use tools based on your queries, and will request permissions when necessary. |
| 101 | + |
| 102 | + |
| 103 | +</TabItem> |
| 104 | +</Tabs> |
| 105 | + |
| 106 | +## Name and describe your flows for agentic use |
| 107 | + |
| 108 | +MCP clients like Claude for Desktop and Cursor "see" Langflow as a single MCP server, with **all** of your flows listed as tools. |
| 109 | + |
| 110 | +This can confuse agents, who don't know that flow `adbbf8c7-0a34-493b-90ea-5e8b42f78b66` is a Document Q&A flow for a specific text file. |
| 111 | +To prevent this behavior, name and describe your flows clearly for agentic use. Imagine your names and descriptions as function names and code comments, with a clear statement of what problem they solve. |
| 112 | + |
| 113 | +For example, you have created a [Document Q&A](/tutorials-document-qa) flow that loads a sample resume for an LLM to chat with, and you want Cursor to use the tool. |
| 114 | + |
| 115 | +1. Click **Flow name**, and then select **Edit Details**. |
| 116 | +2. The **Name** field should make it clear what the flow does, both to a user and to the agent. For example, name it `Document QA for Resume`. |
| 117 | +3. The **Description** field should include a description of what the flow does. For example, describe the flow as `OpenAI LLM Chat with Alex's resume.` |
| 118 | +The **Endpoint Name** field does not affect the agent's behavior. |
| 119 | +4. To see how an MCP client understands your flow, in Cursor, examine the **MCP Servers**. |
| 120 | +The tool is listed as: |
| 121 | +```text |
| 122 | +document_qa_for_resume |
| 123 | +e967f47d-6783-4bab-b1ea-0aaa554194a3: OpenAI LLM Chat with Alex's resume. |
| 124 | +``` |
| 125 | +Your flow name and description provided the agent with a clear purpose for the tool. |
| 126 | + |
| 127 | +5. Ask Cursor a question specifically about the resume, such as `What job experience does Alex have?` |
| 128 | +```text |
| 129 | +I'll help you explore a resume using the Document QA for Resume flow, which is specifically designed for analyzing resumes. |
| 130 | +Let me call this tool. |
| 131 | +``` |
| 132 | +6. Click **Run tool** to continue. The agent requests permissions when necessary. |
| 133 | +``` |
| 134 | +Based on the resume, here's a comprehensive breakdown of the experience: |
| 135 | +``` |
| 136 | +7. Ask about a different resume. |
| 137 | +You've provided enough information in the description for the agent to make the correct decision: |
| 138 | +```text |
| 139 | +I notice you're asking about Emily's job experience. |
| 140 | +Based on the available tools, I can see there is a Document QA for Resume flow that's designed for analyzing resumes. |
| 141 | +However, the description mentions it's for "Alex's resume" not Emily's. I don't have access to Emily's resume or job experience information. |
| 142 | +``` |
| 143 | + |
| 144 | +## Install MCP Inspector to test and debug flows |
| 145 | + |
| 146 | +[MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector) is the standard tool for testing and debugging MCP servers. |
| 147 | + |
| 148 | +Use MCP Inspector to monitor your Langflow server's flows, and understand how they are being consumed by the MCP. |
| 149 | + |
| 150 | +To install and run MCP inspector, follow these steps: |
| 151 | + |
| 152 | +1. Install an LTS release of [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). |
| 153 | +2. To install and start MCP inspector, in a terminal window, run the following command: |
| 154 | +``` |
| 155 | +npx @modelcontextprotocol/inspector |
| 156 | +``` |
| 157 | + |
| 158 | +MCP inspector starts by default at `http://localhost:5173`. |
| 159 | + |
| 160 | +:::tip |
| 161 | +Optionally, specify a proxy port when starting MCP Inspector: |
| 162 | +``` |
| 163 | +SERVER_PORT=9000 npx -y @modelcontextprotocol/inspector |
| 164 | +``` |
| 165 | +::: |
| 166 | + |
| 167 | +3. In the browser, navigate to MCP Inspector. |
| 168 | +4. To inspect the Langflow server, enter the values for the Langflow server. |
| 169 | + |
| 170 | +* In the **Transport Type** field, select **SSE**. |
| 171 | +* In the **URL** field, enter the Langflow server's `/mcp/sse` endpoint. |
| 172 | +For a default deployment, the URL is `http://127.0.0.1:7860/api/v1/mcp/sse`. |
| 173 | + |
| 174 | +5. Click **Connect**. |
| 175 | +MCP Inspector connects to the Langflow server. |
| 176 | +6. To confirm the connection, click the **Tools** tab. |
| 177 | +The Langflow server's flows are listed as tools, which confirms MCP Inspector is connected. |
| 178 | +In the **Tools** tab, you can monitor how your flows are being registered as tools by MCP, and run flows with input values. |
| 179 | + |
| 180 | +To quit MCP Inspector, in the terminal where it's running, enter `Ctrl+C`. |
0 commit comments