point-readme-to-lfx-mcp-document

This commit is contained in:
Mendon Kissling
2026-04-23 17:10:41 -04:00
parent 9b589d58ee
commit b0a5a3f1dc
2 changed files with 186 additions and 3 deletions

158
src/lfx/LFX-MCP.md Normal file
View File

@ -0,0 +1,158 @@
# LFX MCP Server
`lfx-mcp` is an MCP (Model Context Protocol) server that gives any MCP-compatible client full programmatic control over a Langflow instance to build and run flows.
The server is implemented in `src/lfx/src/lfx/mcp/` using [FastMCP](https://github.com/jlowin/fastmcp).
It connects to Langflow's REST API.
Flow data is never cached server-side, so every mutating tool does a GET → modify → PATCH cycle.
The component registry is cached on first access per session.
## Prerequisites
- A running Langflow instance
- A Langflow API key
- `lfx` installed (`uv pip install lfx`), **or** `uv` installed if you want to run via `uvx` without a permanent install
## Connect a client
`lfx-mcp` runs over **stdio**: your MCP client spawns it as a subprocess and communicates over stdin and stdout. There is no HTTP port to connect to.
Any client that supports stdio MCP servers can connect to the `lfx-mcp` server.
Set the command to `lfx-mcp` (or `uvx lfx-mcp`) and pass the following environment variables:
| Variable | Description | Default |
|----------|-------------|---------|
| `LANGFLOW_SERVER_URL` | URL of your Langflow instance | `http://localhost:7860` |
| `LANGFLOW_API_KEY` | API key for authentication | — |
For example, to connect to Claude Desktop, add the following to the Claude Desktop configuration file at `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"langflow": {
"command": "lfx-mcp",
"env": {
"LANGFLOW_SERVER_URL": "http://localhost:7860",
"LANGFLOW_API_KEY": "<your-api-key>"
}
}
}
}
```
If `lfx` is not installed globally, use it through `uvx` instead.
```json
{
"mcpServers": {
"langflow": {
"command": "uvx",
"args": ["lfx-mcp"],
"env": {
"LANGFLOW_SERVER_URL": "http://localhost:7860",
"LANGFLOW_API_KEY": "<your-api-key>"
}
}
}
}
```
## Server tools
The server exposes the following tool groups to the connected MCP client.
### Auth
| Tool | Description |
|------|-------------|
| `login` | Authenticate with a Langflow server using username and password. Not needed if `LANGFLOW_API_KEY` is set. |
### Flows
| Tool | Description |
|------|-------------|
| `create_flow` | Create a new empty flow |
| `create_flow_from_spec` | Create a complete flow from a compact text spec (nodes, edges, config in one call) |
| `list_flows` | List flows on the server, with ASCII graph diagrams |
| `get_flow_info` | Get detailed info about a flow: components, connections, graph |
| `delete_flow` | Delete a flow |
| `duplicate_flow` | Copy an existing flow |
| `rename_flow` | Update a flow's name or description |
| `update_flow_from_spec` | Replace an existing flow's nodes, edges, and config from a spec |
| `export_flow` | Export a flow as JSON with sensitive fields redacted |
### Starter projects
| Tool | Description |
|------|-------------|
| `list_starter_projects` | List Langflow's built-in example flows |
| `use_starter_project` | Create a new flow from a starter project template |
### Components
| Tool | Description |
|------|-------------|
| `search_component_types` | Find component types by name, category, or output type |
| `describe_component_type` | Get a component type's inputs, outputs, fields, and advanced fields |
| `components` | Search or describe component types in one call |
| `add_component` | Add a component to a flow |
| `remove_component` | Remove a component and its connections from a flow |
| `configure_component` | Set parameter values on a component |
| `list_components` | List all components in a flow |
| `get_component_info` | Get a component's current parameter values (sensitive fields redacted) |
| `freeze_component` | Freeze a component so it uses cached output and skips re-execution |
| `unfreeze_component` | Unfreeze a component so it re-executes on the next run |
### Connections
| Tool | Description |
|------|-------------|
| `connect_components` | Connect an output of one component to an input of another |
| `disconnect_components` | Remove connections between two components |
### Execution
| Tool | Description |
|------|-------------|
| `run_flow` | Run a flow and return the output; streams progress events when the client supports it |
| `build_flow` | Trigger a server-side build to validate components and connections |
| `validate_flow` | Validate a flow and return structured per-component results |
| `get_build_results` | Get per-component build results from the last run |
| `get_component_output` | Get a specific component's output from the last run |
### Utility
| Tool | Description |
|------|-------------|
| `layout_flow` | Re-layout a flow's components using the Sugiyama algorithm |
| `notify_done` | Signal that you are done modifying a flow so the UI updates immediately |
| `batch` | Execute multiple actions in sequence; use `$N.field` to reference results from previous steps |
## How to use the server
The server's instructions describe the intended usage pattern:
1. Authenticate — call `login`, or set `LANGFLOW_API_KEY` before starting
2. Discover components — use `search_component_types` or `describe_component_type`
3. Build a flow — use `create_flow_from_spec` for a complete flow in one call, or step-by-step with `create_flow``add_component``configure_component``connect_components`
4. Run the flow — call `run_flow`
The `batch` tool lets you send multiple actions in a single call, with `$N.field` references to chain results:
```json
[
{"tool": "create_flow", "args": {"name": "My Chatbot"}},
{"tool": "add_component", "args": {"flow_id": "$0.id", "component_type": "ChatInput"}},
{"tool": "add_component", "args": {"flow_id": "$0.id", "component_type": "OpenAIModel"}},
{"tool": "add_component", "args": {"flow_id": "$0.id", "component_type": "ChatOutput"}},
{"tool": "connect_components", "args": {
"flow_id": "$0.id", "source_id": "$1.id", "source_output": "message",
"target_id": "$2.id", "target_input": "input_value"
}},
{"tool": "connect_components", "args": {
"flow_id": "$0.id", "source_id": "$2.id", "source_output": "text_output",
"target_id": "$3.id", "target_input": "input_value"
}}
]
```

View File

@ -12,10 +12,29 @@ Operations that depend on `langflow.db` will not work as they do in the full Lan
Memory operations are dispatched at call time, not at import time.
If the `langflow` package is installed in the same Python environment as `lfx` and a real database service is registered, memory operations are routed to the full `langflow.memory` implementation instead. This applies when `lfx` is used as a Python library inside a running Langflow server, not when running `lfx run` or `lfx serve` from the command line.
LFX includes two commands for executing flows:
## Commands
- **`lfx serve`**: Starts a FastAPI server hosting a Langflow API endpoint with your flow available at `/flows/{flow_id}/run`. The flow graph is stored in memory at all times, so there is less overhead for loading the graph from a database.
- **`lfx run`**: Executes a flow locally and returns the results to `stdout`.
**Runtime commands** — documented in this README:
| Command | Description |
|---------|-------------|
| [`lfx serve`](#serve-the-simple-agent-starter-flow-with-lfx-serve) | Serve a flow as a FastAPI endpoint at `/flows/{flow_id}/run` |
| [`lfx run`](#run-the-simple-agent-flow-with-lfx-run) | Execute a flow locally and stream results to `stdout` |
| [`lfx-mcp`](#lfx-mcp) | Start an MCP server that connects to a running Langflow instance |
**Flow DevOps SDK commands** — documented in the [Flow DevOps Toolkit](https://docs.langflow.org/flow-devops-sdk):
| Command | Description |
|---------|-------------|
| `lfx init` | Scaffold a versioned flow project with CI templates |
| `lfx login` | Validate credentials against a remote Langflow instance |
| `lfx create` | Create a new flow JSON from a built-in or custom template |
| `lfx validate` | Validate flow JSON before pushing |
| `lfx requirements` | Generate `requirements.txt` from a flow's component dependencies |
| `lfx status` | Compare local flow files against a remote Langflow instance |
| `lfx push` | Push flows to a remote instance by stable ID |
| `lfx pull` | Pull flows from a remote instance to local files |
| `lfx export` | Normalize flow JSON for clean git diffs |
## Prerequisites
@ -420,6 +439,12 @@ Install dependencies and set your OpenAI API key, then run:
uv run lfx run simple_agent.py "How are you?" --verbose
```
## lfx-mcp
`lfx-mcp` is a separate binary installed with `lfx`. It starts an MCP server that gives any MCP-compatible client programmatic control over a Langflow instance for building flows, managing components, and running executions.
For more information, see [LFX-MCP.md](./LFX-MCP.md).
## Development
```bash