可视化流程构建服务

Langflow MCP Server是一款AI驱动的可视化流程构建助手服务,提供基于Claude的对话式流程构建、实时更新和批量操作功能,适用于开发者和团队协作。

  • by llotze
  • MDX
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 llotze/langflow-mcp

使用说明

Langflow MCP服务器

Langflow视觉流构建器的AI辅助服务器,专为Graceful AI构建。 实现模型上下文协议(MCP),以通过Claude实现会话流构建,并为程序化流管理提供HTTP/REST API。


📋 目录


特性

核心能力

  • Hopper AI助手 -Claude驱动的自然语言流构建对话界面
  • 每用户身份验证 -每个用户都提供自己的Langflow API密钥(无共享凭据)
  • 实时更新 -用于实时流同步的服务器发送事件(SSE)
  • 批量操作 -高效的多节点/边缘操作(比单个操作快80-90%)
  • ↩ 撤消/恢复系统 -具有跳到点功能的完整流量历史跟踪
  • 模板系统 -常见用例的预构建流程模板

流量管理

  • 差异更新 -应用有针对性的更改,而不替换整个流程
  • 组件发现 -搜索和探索100多个Langflow组件
  • 智能连接 -通过类型验证自动生成句柄
  • 自动布局 -用于批量节点添加的水平、垂直和网格布局
  • 流程说明 -将markdown文档直接添加到流中

开发者体验

  • 综合JSDoc -所有API的详细内联文档
  • 类型安全 -完整的TypeScript类型定义
  • 预验证 -失败时回滚的原子操作应用程序
  • 灵活的模式 -支持简化和完整的节点/边定义

🏗️ 建筑

┌─────────────────────────────────────────────────────────┐
│     Langflow Frontend (graceful-ai.com)                │
│     ┌──────────────┐         ┌──────────────────┐     │
│     │  Flow Canvas │         │  Hopper Chat     │     │
│     │  (React)     │         │  (Claude UI)     │     │
│     └──────┬───────┘         └────────┬─────────┘     │
│            │                           │               │
│            │ x-api-key: user's key    │               │
│            ▼                           ▼               │
└────────────┼───────────────────────────┼───────────────┘
             │                           │
             │     HTTPS / REST          │
             ▼                           ▼
┌─────────────────────────────────────────────────────────┐
│  MCP Server (Railway)                                   │
│  https://langflow-mcp-production.up.railway.app         │
│                                                          │
│  ┌────────────────────────────────────────────────┐    │
│  │  HTTP Server (Express)                         │    │
│  │  - REST API endpoints                          │    │
│  │  - SSE for real-time updates                   │    │
│  │  - Per-user authentication                     │    │
│  └────────────────┬───────────────────────────────┘    │
│                   │                                     │
│  ┌────────────────▼───────────────────────────────┐    │
│  │  Core Services                                 │    │
│  │  - FlowDiffEngine (operation processor)       │    │
│  │  - FlowValidator (structure validation)       │    │
│  │  - FlowHistory (undo/redo tracking)          │    │
│  │  - LangflowApiService (API client)           │    │
│  │  - ComponentService (catalog access)          │    │
│  └────────────────┬───────────────────────────────┘    │
│                   │                                     │
│  ┌────────────────▼───────────────────────────────┐    │
│  │  Hopper Assistant (Claude Integration)        │    │
│  │  - Multi-turn conversations                   │    │
│  │  - Tool calling (tweak_flow, search, etc.)   │    │
│  │  - Context-aware suggestions                  │    │
│  └────────────────────────────────────────────────┘    │
└─────────────────────┬───────────────────────────────────┘
                      │
                      │ x-api-key: user's key
                      ▼
┌─────────────────────────────────────────────────────────┐
│  Langflow API (graceful-ai.com/api/v1)                 │
│  - Flow CRUD operations                                 │
│  - Component catalog                                    │
│  - Flow execution                                       │
│  - Chat history storage                                 │
└─────────────────────────────────────────────────────────┘

组件概述

组件 用途 技术
HTTP服务器 用于流操作的REST API Express.js
MCP服务器 Claude Desktop的Stdio协议 MCP SDK
FlowDiff发动机 对流应用微分运算 TypeScript
流量验证器 验证流结构和参数 TypeScript
流程历史 管理撤消/重做状态 内存存储
Hopper助理 人工智能驱动的流动建筑 克劳德·索内特4.5

🚀 安装

先决条件

  • Node.js ≥ 20.0.0
  • npm ≥ 10.0.0
  • Langflow实例 (本地或生产)
  • 无烟煤API密钥 (适用于Hopper助理)

克隆存储库

git clone https://github.com/yourusername/langflow-mcp.git
cd langflow-mcp

再进行

npm install

⚙️ 配置

创建一个 .env 项目根目录中的文件:

# Server Configuration
PORT=3001

# Langflow API (required)
LANGFLOW_API_URL=https://www.graceful-ai.com

# Anthropic API Key (required for Hopper assistant)
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx

# CORS Configuration
ALLOWED_ORIGINS=https://www.graceful-ai.com,https://graceful-ai.com,http://localhost:3000

# Node Environment
NODE_ENV=production

环境变量

变量 必填 默认 描述
PORT 没有 3001 HTTP服务器端口
LANGFLOW_API_URL 是 - Langflow实例URL
ANTHROPIC_API_KEY 是 - Claude的Anthropic API密钥
ALLOWED_ORIGINS 没有 * 逗号分隔的CORS源
NODE_ENV 没有 development 节点环境

💻 用法

HTTP服务器模式

启动REST API服务器以供生产使用:

# Development (with hot reload)
npm run dev

# Production
npm run build
npm start

服务器将在 http://localhost:3001.

健康检查

curl http://localhost:3001/health

答复:

{
  "status": "ok",
  "message": "Langflow MCP Server is running",
  "langflowApiEnabled": true,
  "timestamp": "2025-12-10T23:50:00.000Z"
}

MCP服务器模式

作为用于Claude Desktop集成的MCP服务器运行:

npm run dev:mcp

Claude桌面配置

添加 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "langflow": {
      "command": "node",
      "args": [
        "/absolute/path/to/langflow-mcp/dist/api/mcp-server.js"
      ],
      "env": {
        "LANGFLOW_API_URL": "https://www.graceful-ai.com",
        "LANGFLOW_API_KEY": "your-api-key-here",
        "ANTHROPIC_API_KEY": "sk-ant-xxxxx"
      }
    }
  }
}

📚 API 参考

看 API文档 以获取完整的端点参考。

快速示例

修改流

curl -X POST https://langflow-mcp-production.up.railway.app/mcp/api/tweak-flow/abc-123 \
  -H "Content-Type: application/json" \
  -H "x-api-key: lf_your_key_here" \
  -d '{
    "flowId": "abc-123",
    "operations": [
      {
        "type": "updateNode",
        "nodeId": "OpenAI-xyz",
        "updates": {
          "template": {
            "temperature": 0.9
          }
        },
        "merge": true
      }
    ]
  }'

搜索组件

curl https://langflow-mcp-production.up.railway.app/mcp/api/search?keyword=openai \
  -H "x-api-key: lf_your_key_here"

与Hopper聊天

curl -X POST https://langflow-mcp-production.up.railway.app/mcp/api/assistant \
  -H "Content-Type: application/json" \
  -H "x-api-key: lf_your_key_here" \
  -d '{
    "flow_id": "abc-123",
    "session_id": "user-456",
    "message": "Add an OpenAI model to my flow"
  }'

🚢 部署

铁路(推荐)

此项目配置为一键式铁路部署。

第一步:创建铁路项目

# Install Railway CLI
npm install -g @railway/cli

# Login
railway login

# Deploy
railway up

步骤2:设置环境变量

铁路仪表板→ 变量:

PORT=3001
LANGFLOW_API_URL=https://www.graceful-ai.com
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx
ALLOWED_ORIGINS=https://www.graceful-ai.com,https://graceful-ai.com
NODE_ENV=production

步骤3:生成公共域

设置 → 网络 → 生成域

例子: https://langflow-mcp-production.up.railway.app

码头工人

# Build image
docker build -t langflow-mcp .

# Run container
docker run -p 3001:3001 \
  -e LANGFLOW_API_URL=https://www.graceful-ai.com \
  -e ANTHROPIC_API_KEY=sk-ant-xxxxx \
  langflow-mcp

维塞尔

vercel --prod

在Vercel仪表板中设置环境变量。


🔧 发展

项目脚本

# Development server with hot reload
npm run dev

# Build TypeScript
npm run build

# Start production server
npm start

# Run MCP server (stdio mode)
npm run dev:mcp

### **Test Scripts**

⚠️ **Note**: Test scripts are currently outdated and may fail with current API structure. They were built for an earlier version and need refactoring to work with:
- Per-user authentication (now requires `x-api-key` header)
- Updated `tweak_flow` operation format
- New bulk operation schemas

**Available (but outdated):**
```bash
npm run test:api-first          # ⚠️ Needs update for auth
npm run test:flow-diff          # ⚠️ Needs update for new schemas
npm run test:template-tools     # ⚠️ Needs update for auth
npm run test:component-tools  

代码质量

  • TypeScript -已启用严格类型检查
  • JSDoc -全面的内联文档
  • 错误处理 -带有详细消息的优雅错误恢复
  • 验证 -使用原子操作进行预验证

📁 项目结构

langflow-mcp/
├── src/
│   ├── api/
│   │   ├── server.ts              # HTTP/REST server (Express)
│   │   └── mcp-server.ts          # MCP stdio server
│   ├── services/
│   │   ├── flowDiffEngine.ts     # Operation processor
│   │   ├── flowValidator.ts      # Structure validator
│   │   ├── flowHistory.ts        # Undo/redo manager
│   │   ├── langflowApiService.ts # Langflow API client
│   │   ├── LangflowComponentService.ts
│   │   └── LangflowFlowBuilder.ts
│   ├── core/
│   │   └── config.ts              # Environment config loader
│   ├── types/
│   │   └── flowDiff.ts            # Operation type definitions
│   ├── utils/
│   │   ├── templateLoader.ts      # Template management
│   │   └── componentNameMapping.ts
│   ├── types.ts                   # Core type definitions
│   └── tools.ts                   # MCP tools implementation
├── docs/
│   └── API.md                     # API reference (see below)
├── scripts/
│   ├── test-api-first.ts          # Test scripts
│   ├── test-flowdiff-validator.ts
│   ├── test-template-tools.ts
│   └── test-component-tools.ts
├── Dockerfile                     # Production Docker image
├── .dockerignore
├── .gitignore
├── .env.example                   # Environment template
├── package.json
├── tsconfig.json
└── README.md

👤 作者

卢卡斯·洛泽、多米尼克·莱奥萨、丹尼尔·维贾亚


🙏 致谢

  • 朗福团队 -对于令人惊叹的视觉流构建器
  • Anthropic -适用于Claude AI和MCP协议
  • 铁路 -实现无缝部署基础架构

内置于❤️ 为Langflow社区