Langflow Module 9: Langflow and the Model Context Protocol (MCP)
Introduction
The Model Context Protocol (MCP) is an open standard for connecting AI applications to tools. Langflow supports it in both directions: it can act as an MCP server that offers your flows as tools, and as an MCP client that lets an agent use tools from other servers. This module covers both.
Prerequisites
- Module 4 (agents and Tool Mode)
- A client that supports MCP, such as an IDE assistant, for testing
Step-by-Step Guide
Step 1: Use Langflow as an MCP server
Each project has its own MCP server, and its flows are exposed as tools. A flow needs a Chat Output component to work as a tool. Open the Projects page and choose the MCP Server tab (or use Share, then MCP Server). The server uses streamable HTTP at a project-specific URL, with a legacy SSE option.
Step 2: Choose and describe the tools
Use Edit Tools to pick which flows are exposed. A tool's name and description are editable there, and they matter: the client's model reads them to decide when to call your flow. The default tool name is the flow ID, so rename it to something meaningful.
Step 3: Connect an MCP client
The MCP Server tab provides a JSON tab with configuration you can paste into a client, and Auto install for supported desktop clients on the same machine. A typical configuration launches a proxy that points at your project's URL. If you use API key authentication, add the key as a header.
{
"mcpServers": {
"my_project": {
"command": "uvx",
"args": [
"mcp-proxy",
"--transport", "streamablehttp",
"http://localhost:7860/api/v1/mcp/project/PROJECT_ID/streamable"
]
}
}
}Step 4: Use external MCP servers as agent tools
To go the other way, open Settings, then MCP Servers, and click Add MCP Server, or use the MCP sidebar in the flow editor. Choose a connection type: STDIO for a local command (for example uvx with the argument mcp-server-fetch) or HTTP/SSE for a remote URL with optional headers. Then drag the server onto the canvas, enable Tool Mode, and connect its Toolset output to an Agent's Tools port.
Step 5: Secure your MCP setup
Choose the authentication option deliberately, because selecting None makes the server public. Only connect to external servers you trust, since their tools and descriptions are text your agent will act on. You can test a server with the MCP Inspector, and the LANGFLOW_MCP_SERVERS_LOCKED setting stops non-superusers from changing configured servers.
FAQs
- What is the benefit of exposing a flow over MCP?
- Any MCP-compatible application can then call your flow as a tool without custom integration code, so one flow can serve several assistants.
- Which Node.js dependencies might I need?
- Servers launched with npx require Node.js to be installed where Langflow runs. In Docker, make sure it is available in the image.
Summary
Langflow can publish project flows as MCP tools and consume other MCP servers through Tool Mode. Name your tools clearly, pick authentication carefully, and trust only servers you have reviewed.
Comments
Log in or create a free account to join the discussion.