Use Langflow as an MCP client
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 client with the MCP connection component.
For information about using Langflow as an MCP server, see Use Langflow as an MCP server.
Use the MCP connection component
The MCP connection component connects to a Model Context Protocol (MCP) server and exposes the MCP server's tools as tools for Langflow agents.
This component has two modes, depending on the type of server you want to access:
- To access tools provided by external, non-Langflow MCP servers, use Stdio mode.
- To use flows from your Langflow projects as MCP tools, use SSE mode.
Use Stdio mode
-
Add an MCP connection component to your flow.
-
In the MCP Command field, enter the command to start the MCP server. For example, to start a Fetch server, the command is
uvx mcp-server-fetch
.uvx
is included withuv
in the Langflow package. To usenpx
server commands, you must first install an LTS release of Node.js. For an example of annpx
MCP server in Langflow, see Connect an Astra DB MCP server to Langflow. -
To use environment variables in your server command, enter each variable in the Env fields as you would define them in a script, such as
VARIABLE=value
. If the Env field isn't shown, enable it in the component's Controls in the component menu.importantLangflow passes environment variables from the
.env
file to MCP, but it doesn't pass global variables declared in the Langflow UI. To define an MCP server environment variable as a global variable, add it to Langflow's.env
file at startup. For more information, see global variables. -
Click to test the command and retrieve the list of tools provided by the MCP server.
-
In the Tool field, select a tool that you want this component to use, or leave the field blank to allow access to all tools provided by the MCP server.
If you select a specific tool, you might need to configure additional tool-specific fields. For information about tool-specific fields, see your MCP server's documentation.
At this point, the MCP connection component is serving a tool, but nothing is using the tool. The next steps explain how to make the tool available to an Agent component so that the agent can use the tool in its responses.
-
In the component menu, enable Tool mode so you can use the component with an agent.
-
Connect the MCP connection component's Toolset port to an Agent component's Tools port.
If not already present in your flow, make sure you also attach Chat input and Chat output components to the Agent component.
-
Test your flow to make sure the MCP server is connected and the selected tool is used by the agent: Click Playground, and then enter a prompt that uses the tool you connected through the MCP connection component. For example, if you use
mcp-server-fetch
with thefetch
tool, you could ask the agent to summarize recent tech news. The agent calls the MCP server functionfetch
, and then returns the response. -
If you want the agent to be able to use more tools, repeat these steps to add more MCP connection components with different servers or tools.
Use SSE mode
Every Langflow project runs a separate MCP server that exposes the project's flows as MCP tools. For more information about your projects' MCP servers, including how to manage exposed flows, see Use Langflow as an MCP server.
To leverage flows-as-tools, use the MCP connection component in Server-Sent Events (SSE) mode to connect to a project's /api/v1/mcp/sse
endpoint:
- Add an MCP connection component to your flow, and then select SSE mode. A default address appears in the MCP SSE URL field.
- In the MCP SSE URL field, modify the default address to point at your Langflow server's SSE endpoint. The default value for Langflow Desktop is
http://localhost:7868/
. The default value for other Langflow installations ishttp://localhost:7860/api/v1/mcp/sse
. - Click to test the endpoint and refresh the Tools list. In SSE mode, all flows available from the targeted server are treated as tools.
- In the Tool field, select a flow that you want this component to use, or leave the field blank to allow access to all flows available from the targeted Langflow server.
- In the component menu, enable Tool mode so you can use the component with an agent.
- Connect the MCP connection component's Toolset port to an Agent component's Tools port. If not already present in your flow, make sure you also attach Chat input and Chat output components to the Agent component.
- Test your flow to make sure the agent uses your flows to respond to queries: Click Playground, and then enter a prompt that uses a flow that you connected through the MCP connection component.
- If you want the agent to be able to use more flows, repeat these steps to add more MCP connection components with different servers or tools selected.
MCP connection component parameters
Inputs
Name | Type | Description |
---|---|---|
command | String | Stdio mode only. The MCP server startup command. Default: uvx mcp-sse-shim@latest . |
sse_url | String | SSE mode only. The SSE URL for a Langflow project's MCP server. Default for Langflow Desktop: http://localhost:7868/ . Default for other installations: http://localhost:7860/api/v1/mcp/sse |
Outputs
Name | Type | Description |
---|---|---|
tools | List[Tool] | A list of tools exposed by the MCP server. |