AI辅助n8n工作流构建器

一个基于FastAPI和OpenAI Agent SDK的服务器,用于通过AI辅助构建n8n工作流,集成了n8n-MCP和1000+节点支持。

  • by roniotakahashi
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 roniorque/openai-agent-sdk-n8n-mcp

使用说明

n8n Workflow Builder API

A FastAPI server powered by OpenAI Agent SDK and n8n-MCP for building n8n workflows with AI assistance.

Features

  • 🚀 FastAPI - Modern, high-performance Python web framework
  • 🤖 OpenAI Agent SDK - AI-powered workflow building
  • 🔧 n8n-MCP Integration - Access to 20+ n8n workflow tools
  • 📚 1,084+ n8n Nodes - Full documentation at your fingertips
  • 🐳 Docker Support - Production-ready containerization

Quick Start

Prerequisites

  • Python 3.11+
  • OpenAI API Key
  • n8n instance with API access (optional, for management features)

Installation

  1. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # Linux/Mac
    # or
    venv\Scripts\activate  # Windows
    
  2. Install dependencies

    pip install -r requirements.txt
    
  3. Configure environment

    cp .env.example .env
    # Edit .env with your credentials:
    # - OPENAI_API_KEY (required)
    # - N8N_API_URL (optional, for workflow management)
    # - N8N_API_KEY (optional, for workflow management)
    
  4. Run the server

    uvicorn app.main:app --reload
    
  5. Access the API

    • Swagger UI: http://localhost:8000/docs
    • ReDoc: http://localhost:8000/redoc

API Endpoints

n8n Chat

POST /api/v1/n8n/chat
Content-Type: application/json

{
  "message": "Search for nodes that can connect to Slack"
}

List Available Tools

GET /api/v1/n8n/tools

Health Check

GET /api/v1/health

n8n-MCP Tools

The agent has access to 20 powerful tools:

Core Tools (Always Available)

Tool Description
search_nodes Search across 1,084+ n8n nodes
get_node Get detailed node documentation
validate_node Validate node configuration
validate_workflow Validate complete workflows
search_templates Search 2,700+ templates
get_template Get workflow JSON from templates

Management Tools (Requires n8n API)

Tool Description
n8n_create_workflow Create new workflows
n8n_get_workflow Retrieve workflows
n8n_update_full_workflow Update entire workflow
n8n_list_workflows List all workflows
n8n_test_workflow Execute/test workflows
n8n_executions Manage execution history

Environment Variables

Variable Required Default Description
OPENAI_API_KEY Yes - OpenAI API key
N8N_API_URL No - Your n8n instance API URL
N8N_API_KEY No - Your n8n instance API key
N8N_MCP_URL No https://n8n-mcp.com/sse n8n-MCP server URL
DEBUG No false Enable debug mode
LOG_LEVEL No INFO Logging level

Docker Deployment

docker-compose up --build

Testing

pip install pytest pytest-asyncio httpx
pytest tests/ -v

License

MIT