This document describes Langflow's Model Context Protocol (MCP) integration, which enables bidirectional communication with MCP-compatible systems. Langflow supports both MCP server and MCP client functionality, allowing flows to be exposed as tools for MCP clients and enabling Langflow to consume tools from external MCP servers.
For information about creating flows that can be exposed as MCP tools, see Flow Patterns and Examples. For general information about extending Langflow with custom components, see Custom Component Development.
Langflow's MCP integration serves two primary purposes:
The integration supports both streamable HTTP transport (added in version 1.7.0) and SSE transport for backwards compatibility.
Sources: README.md16 README.md25 docs/docs/Support/release-notes.mdx87-92
Langflow MCP Integration — Code Entity Map
Sources: src/backend/base/langflow/inputs/inputs.py1-76 src/backend/base/langflow/inputs/input_mixin.py1-51 src/backend/base/langflow/io/__init__.py1-63 src/frontend/src/components/core/parameterRenderComponent/index.tsx20 src/frontend/src/components/core/parameterRenderComponent/index.tsx321-330
MCP Bidirectional Communication
Sources: README.md25 docs/docs/Support/release-notes.mdx87-92
McpInput Type and McpMixinLangflow includes a dedicated input type, McpInput, for components that accept an MCP server connection as a parameter. This input type is defined in the lfx package and re-exported throughout the backend.
| Symbol | Location | Role |
|---|---|---|
McpMixin | lfx.inputs.input_mixin | Base mixin adding MCP-specific field metadata |
McpInput | lfx.inputs.inputs | Concrete input class combining McpMixin with base input |
McpInput (re-export) | langflow.inputs.inputs | Compatibility re-export for langflow-base consumers |
McpInput (re-export) | langflow.io | Public API re-export |
Sources: src/backend/base/langflow/inputs/inputs.py24 src/backend/base/langflow/inputs/input_mixin.py11 src/backend/base/langflow/io/__init__.py14 src/backend/base/langflow/inputs/__init__.py19
"mcp"When a component declares an McpInput field, the field serializes with type: "mcp". The frontend's ParameterRenderComponent dispatches on this type string in its switch statement and renders a specialized McpComponent:
case "mcp":
return <McpComponent ... />
This gives users a dedicated UI for selecting or configuring the MCP server connection, distinct from plain text or dropdown inputs.
Sources: src/frontend/src/components/core/parameterRenderComponent/index.tsx321-330
McpComponentMcpComponent (located at src/frontend/src/components/core/parameterRenderComponent/components/mcpComponent) renders the MCP server selection UI. It is imported in ParameterRenderComponent and displayed when a node has a parameter of type "mcp".
The component receives the standard BaseInputProps plus:
id — unique field identifiereditNode — whether the node is in edit modedisabled — whether the field is interactivevalue — current MCP server selectionSources: src/frontend/src/components/core/parameterRenderComponent/index.tsx20 src/frontend/src/components/core/parameterRenderComponent/index.tsx321-330
When Langflow operates as an MCP server, it exposes flows as callable tools that external MCP clients can discover and invoke. Each flow becomes a tool with a JSON schema describing its inputs and outputs.
MCP Server Flow Execution Sequence
The server mode converts flow definitions into MCP tool schemas and handles tool invocation by executing the corresponding flows.
Sources: README.md25 docs/docs/Support/release-notes.mdx342-343
Langflow's MCP server supports two transport protocols:
| Transport | Description | Use Case | Since Version |
|---|---|---|---|
| Streamable HTTP | Bidirectional HTTP streaming | Modern MCP clients, better performance | 1.7.0 |
| SSE (Server-Sent Events) | Server-to-client event streaming | Legacy compatibility, simple clients | <1.7.0 |
Both transports support the same MCP protocol features, with streamable HTTP providing better bidirectional communication capabilities.
Sources: docs/docs/Support/release-notes.mdx87-92
The MCP server is initialized as part of the application startup sequence. The init_mcp_servers() function (in langflow.api.v1.mcp_projects) is responsible for this process:
MCP Server Initialization Flow
The initialization process loads flows from the database, generates MCP-compatible JSON schemas describing each flow's inputs and outputs, and mounts the transport endpoints for clients to connect.
Sources: docs/docs/Support/release-notes.mdx279-281
Langflow can act as an MCP client to connect to external MCP servers and use their tools within flow execution. This allows flows to access capabilities provided by other services through the MCP protocol.
MCP Client Integration in Flows
The client functionality enables flows to dynamically discover and invoke tools from external MCP servers during execution.
Sources: docs/docs/Support/release-notes.mdx89-91
The Langflow settings UI (described in Settings and Configuration) includes an MCP servers section where users can add, remove, and edit external MCP server connections. These configured servers are then available through the McpComponent input UI when building flows.
The MCP Tools component under the Agents category in the visual editor exposes this client functionality as a flow component.
Sources: docs/docs/Support/release-notes.mdx283-286
MCP client connections support the same transport protocols as the server:
| Transport | Notes |
|---|---|
| Streamable HTTP | Bidirectional streaming; supported since Langflow 1.7.0 |
| SSE | Legacy fallback; supported in all versions |
The transport is configured when establishing the connection to the external MCP server.
Sources: docs/docs/Support/release-notes.mdx87-92
MCP functionality is configured through Langflow's settings system. Key configuration options:
| Variable | Description | Default |
|---|---|---|
LANGFLOW_AGENTIC_EXPERIENCE | Enable agentic mode with additional MCP configuration | false |
Transport (HTTP streamable vs SSE) is negotiated automatically based on client capability.
Since Langflow 1.5.0, the project's MCP server settings page includes an Auto install button. Clicking it installs the Langflow MCP server into supported MCP clients (e.g., Claude Desktop) using a JSON configuration file, without manual CLI setup.
Sources: docs/docs/Support/release-notes.mdx277-281
MCP integration requires the following Python packages:
| Package | Role |
|---|---|
mcp | Core MCP protocol implementation |
fastmcp | Alternative MCP server backend |
langchain-mcp-adapters | LangChain adapter for MCP tool integration |
The frontend includes @modelcontextprotocol/server-everything as a dev/reference dependency.
Sources: README.md16
MCP Session State Machine
MCP sessions are managed throughout their lifecycle, with automatic cleanup on shutdown or disconnection.
Sources: src/backend/base/langflow/main.py50
A cleanup_mcp_sessions() function is called during the application shutdown phase (inside the lifespan context manager) to properly close all MCP connections and release resources:
MCP Cleanup Sequence
Cleanup ensures proper resource deallocation when the application stops or when MCP sessions time out.
MCP API endpoints are defined in langflow.api.v1.mcp_projects. The init_mcp_servers() function from that module is called during application startup and registers the transport-layer endpoints (HTTP streamable and SSE) into the FastAPI application.
These endpoints serve:
The frontend communicates with these endpoints through the MCP servers settings page and the McpComponent field UI.
Sources: docs/docs/Support/release-notes.mdx277-281 src/frontend/src/components/core/parameterRenderComponent/index.tsx321-330
MCP Tool Integration with Flow Execution
MCP tools are integrated into flow execution through an adapter layer. Local flows are wrapped as MCP tools by init_mcp_servers(), and external tools are consumed through the MCP client transport. The langchain-mcp-adapters package bridges MCP tool calls into the LangChain tool interface used by the Agent component.
Sources: docs/docs/Support/release-notes.mdx342-343 docs/docs/Support/release-notes.mdx87-92
When a flow is created in Langflow with specific inputs and outputs, it is automatically exposed as an MCP tool by init_mcp_servers():
ChatInput, FileInput, etc.)ChatOutput, data outputs, etc.)Sources: README.md25 docs/docs/Support/release-notes.mdx342-343
To use an external MCP server's tools within a Langflow flow:
McpInput field on a componentlangchain-mcp-adapters package translates the MCP tool protocol into LangChain's tool interfaceSources: docs/docs/Support/release-notes.mdx283-286 docs/docs/Support/release-notes.mdx89-91
When operating as an MCP server, Langflow applies its standard authentication model (API key or JWT) to MCP endpoint access. Requests to MCP endpoints require valid credentials in the same way as other Langflow API endpoints. See Authentication and Security for details on the auth system.
When operating as an MCP client, credentials for external MCP servers are stored as part of the server configuration in Langflow's settings and passed through the transport connection.
Sources: docs/docs/Support/release-notes.mdx96-100
| Issue | Possible Cause | Resolution |
|---|---|---|
| MCP server not starting | Missing dependencies | Install mcp>=1.17.0 package |
| Client cannot connect | Transport mismatch | Ensure client and server support same transport |
| Tools not appearing | Flow not properly configured | Verify flow has defined inputs/outputs |
| Session timeout | Long-running operations | Check session timeout settings |
| Agentic mode issues | Global variables not initialized | Ensure LANGFLOW_AGENTIC_EXPERIENCE=true |
Sources: src/backend/base/langflow/main.py230-238 pyproject.toml84
To debug MCP integration issues:
init_mcp_servers() function completed successfullycleanup_mcp_sessions() is called on shutdownSources: src/backend/base/langflow/main.py31 src/backend/base/langflow/main.py50
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.