Deploy LangFlow On A VPS And Build Flows Through MCP

guide2026-06-0210 min read

Run LangFlow as a persistent VPS service, then let Codex or another MCP client create, edit, and run flows through reproducible API calls.

langflowvpsdockermcp

Summary

This note records a practical way to host LangFlow on a VPS and make it useful from an AI coding agent. The server side runs LangFlow in Docker Compose, while the client side uses x-api-key authenticated REST calls and MCP bridges to list flows, create flows, update flow JSON, run flows, and expose a LangFlow project as MCP tools. All domains, API keys, project IDs, and flow IDs in this post are example values. Replace them with your own values and keep the real secrets out of public notes.

What This Solves

The goal is to turn LangFlow from a browser-only canvas into a server-side automation platform. After deployment, a beginner should understand three layers:
  • LangFlow server: runs on the VPS and stores flows.
  • Public entry point: a domain such as https://langflow.example.com points to the server, usually through a reverse proxy such as Caddy or Nginx.
  • Automation control plane: REST APIs and MCP tools let Codex or another agent create and operate flows without clicking through the browser.
Think of the browser UI as the visual editor and the API/MCP layer as the repeatable control surface. The same flow can be edited on the canvas or updated as JSON.

Who This Is For

This is for a beginner who already has a VPS and wants a persistent LangFlow instance that can be controlled by Codex, Claude Desktop, Cursor, or another MCP-capable client. It assumes you can SSH into a VPS, install Docker, edit a compose.yml file, and set environment variables on your local machine.

Prerequisites

  • A VPS with Docker and Docker Compose installed.
  • A domain or subdomain, for example langflow.example.com.
  • A reverse proxy that can forward HTTPS traffic to LangFlow on port 7860.
  • A strong LangFlow admin password.
  • A long random LANGFLOW_SECRET_KEY.
  • A LangFlow API key created from the LangFlow UI.
  • Local tools: curl, jq, uvx, and an MCP-capable client.
Do not publish your real LangFlow domain, API key, secret key, flow IDs, project IDs, or admin password. Use example values like langflow.example.com, $LANGFLOW_API_KEY, $FLOW_ID, and $PROJECT_ID in public writing.

The Workflow

1

Create the server directory

SSH into the VPS and create a dedicated directory:
mkdir -p ~/langflow-docker
cd ~/langflow-docker
Keeping the deployment in one directory makes it easier to inspect, restart, and back up.
2

Write the Docker Compose file

Create compose.yml:
services:
  langflow:
    image: docker.io/langflowai/langflow:latest
    restart: always
    ports:
      - "7860:7860"
    environment:
      - LANGFLOW_HOST=0.0.0.0
      - LANGFLOW_CONFIG_DIR=/app/langflow
      - LANGFLOW_SUPERUSER=admin
      - LANGFLOW_SUPERUSER_PASSWORD=change-this-password
      - LANGFLOW_SECRET_KEY=change-this-to-a-long-random-secret
      - DO_NOT_TRACK=true
      - LANGFLOW_AUTO_LOGIN=false
    volumes:
      - langflow_data:/app/langflow

volumes:
  langflow_data:
LANGFLOW_AUTO_LOGIN=false matters because a public server should require login instead of silently opening the app.
3

Start LangFlow

Start the container:
docker compose up -d
docker compose ps
Check the health endpoint:
curl -fsS http://127.0.0.1:7860/health_check
A healthy server returns JSON similar to:
{"status":"ok","chat":"ok","db":"ok"}
4

Expose LangFlow through HTTPS

Point your domain to the VPS, then configure a reverse proxy to forward traffic to LangFlow:
langflow.example.com {
    reverse_proxy localhost:7860
}
Reload the proxy after editing the config:
sudo systemctl reload caddy
Then open:
https://langflow.example.com
Log in with the superuser credentials from the Compose file.
5

Create a LangFlow API key

In the LangFlow UI, create an API key and store it locally as an environment variable:
export LANGFLOW_BASE_URL="https://langflow.example.com"
export LANGFLOW_API_KEY="paste-your-key-in-your-shell-or-secret-store"
Test the API without printing the key:
curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  "$LANGFLOW_BASE_URL/api/v1/flows/?get_all=true" \
  | jq 'length'
6

Create or inspect flows through REST

List existing flows:
curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  "$LANGFLOW_BASE_URL/api/v1/flows/?get_all=true" \
  | jq '.[] | {id, name, folder_id}'
Create an empty flow:
curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST \
  "$LANGFLOW_BASE_URL/api/v1/flows/" \
  -d '{"name":"API Created Flow","description":"Created from the command line","data":{"nodes":[],"edges":[]}}'
Fetch one flow as JSON:
export FLOW_ID="replace-with-flow-id"

curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  "$LANGFLOW_BASE_URL/api/v1/flows/$FLOW_ID" \
  -o /tmp/langflow-flow.json
7

Edit a flow as JSON

LangFlow stores the canvas as JSON. The safe edit loop is:
fetch flow -> edit a copy -> validate JSON -> PUT complete flow back -> re-fetch and compare
Save a full updated flow:
curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -X PUT \
  "$LANGFLOW_BASE_URL/api/v1/flows/$FLOW_ID" \
  --data-binary @/tmp/langflow-flow.json
Use jq before saving:
jq '{id, name, node_count: (.data.nodes | length), edge_count: (.data.edges | length)}' \
  /tmp/langflow-flow.json
8

Run and debug flows through API

Run a flow:
curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  "$LANGFLOW_BASE_URL/api/v1/run/$FLOW_ID?stream=false" \
  -d '{"inputs":{"input_value":"test input"},"tweaks":{}}' \
  | jq
For debugging, build only until a specific component:
curl --compressed -sS \
  -H "x-api-key: $LANGFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  "$LANGFLOW_BASE_URL/api/v1/build/$FLOW_ID/flow?stop_component_id=ComponentIdHere" \
  -d '{"inputs":{"input_value":"test input"},"tweaks":{}}'
9

Expose a LangFlow project as MCP tools

LangFlow can expose a project through an MCP endpoint:
/api/v1/mcp/project/{project_id}/streamable
Store the project ID in a variable:
export PROJECT_ID="replace-with-project-id"
Bridge the streamable HTTP endpoint into a local MCP server with mcp-proxy:
uvx mcp-proxy \
  --transport streamablehttp \
  "$LANGFLOW_BASE_URL/api/v1/mcp/project/$PROJECT_ID/streamable"
In a Codex-style MCP config, the same idea looks like this:
[mcp_servers.lf-starter_project]
command = "uvx"
args = [
  "mcp-proxy",
  "--transport",
  "streamablehttp",
  "https://langflow.example.com/api/v1/mcp/project/$PROJECT_ID/streamable"
]
startup_timeout_sec = 120.0
10

Use an admin MCP server for direct flow operations

A separate admin MCP server can wrap LangFlow APIs into tools such as list_flows, create_flow, replace_flow, update_flow, run_flow, and langflow_health.The client-side config should point at the remote LangFlow base URL and read the API key from a secret source:
[mcp_servers.langflow-admin.env]
LANGFLOW_BASE_URL = "https://langflow.example.com"
LANGFLOW_API_KEY = "$LANGFLOW_API_KEY"
LANGFLOW_USE_BROWSEROS = "true"
With that in place, Codex can call MCP tools instead of manually writing every curl request.

Common Failure Modes

If the web page does not open, check DNS, the reverse proxy, and whether port 7860 is reachable from the proxy on the VPS.
If API calls return unauthorized, the API key is missing, expired, or sent with the wrong header. LangFlow API calls should use x-api-key: $LANGFLOW_API_KEY.
If a public note contains a real API key, rotate the key immediately. Do not rely on deleting the text from the latest draft.
If flow edits break the canvas, recover from a previously exported flow JSON or re-fetch the last known good version before continuing.
Use REST for precise flow edits and MCP for agent ergonomics. MCP is convenient, but the REST API is still the lower-level source of truth when debugging.

Final Checklist

  • LangFlow starts with docker compose up -d.
  • curl http://127.0.0.1:7860/health_check returns healthy JSON on the VPS.
  • https://langflow.example.com opens through the reverse proxy.
  • Auto-login is disabled for the public server.
  • The API key is stored in an environment variable or secret manager.
  • GET /api/v1/flows/?get_all=true works with x-api-key.
  • Flow JSON is fetched and backed up before editing.
  • MCP project endpoint uses /api/v1/mcp/project/{project_id}/streamable.
  • Public documentation contains example values, not real domains, API keys, project IDs, or flow IDs.

What To Remember

The durable pattern is: host LangFlow with Docker, put HTTPS in front of it, keep secrets out of the repo, and treat flows as JSON documents that can be created, edited, tested, and run through APIs. MCP then sits on top as a usability layer, letting an AI coding agent operate LangFlow without depending on browser clicks.

Metadata

Quick Reference

Typeguide
Statuspublished
Date2026-06-02

Retrieval Tags

langflowvpsdockermcpautomation
Related
LangFlowMCPAPI automationVPS deployment