Token导航 LogoToken导航TokenDH.com
MCP Server Airflow logo
AI代理stdio官方级别未说明来源级核验

MCP Server Airflow

MCP Server

mcp-server-airflow

一个与Apache Airflow REST API全面集成的模型上下文协议服务器,支持AI助手以编程方式管理DAG、监控任务执行和访问日志。

工具数

12

提示词数

0

GitHub Stars

0

资源数

0
工作流管理JavaScriptClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

tomnagengast

提供方

tomnagengast

最后核验

2026/5/17 20:19

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx mcp-server-airflow

详细介绍

Apache Airflow的MCP服务器

模型上下文协议(MCP)服务器,提供与Apache Airflow的REST API的全面集成。该服务器允许AI助手与Airflow工作流交互,监控DAG运行,并以编程方式管理任务。

特性

  • DAG管理:列出、查看详细信息、暂停和取消暂停DAGs
  • DAG运行操作:触发新运行,列出现有运行,并获取详细的运行信息
  • 任务实例监控:查看任务实例及其执行详细信息
  • 通用兼容性:适用于所有流行的Airflow托管平台:

- 天文学家 - 谷歌云编辑器 - 亚马逊 MWAA - 自托管Airflow实例

  • 综合录井:访问和监视日志以进行调试和故障排除:

- 单个任务的实时日志检索 - 整个DAG运行的聚合日志 - 智能日志跟踪最近的活动摘要 - 自动日志格式化和解码

可用工具

DAG管理

  1. 气流列表_天 -列出所有带分页和排序的DAG
  2. 气流get-dag -获取特定DAG的详细信息
  3. 气流_触发器_dag -使用可选配置触发新的DAG运行
  4. 气流_使用量_dag -暂停DAG
  5. 气流损失 --不均匀的DAG

DAG运行监控

  1. 气流_时间_行程 -列出特定DAG运行的DAG
  2. 气流速度 -获取特定DAG运行的详细信息
  3. 气流列表任务状态 -列出DAG运行的任务实例
  4. 气流_任务_状态 -获取详细的任务实例信息

日志记录和调试

  1. 气流_get_task_logs -获取特定任务实例的完整日志
  2. 气流_风速_风速_风向 -获取DAG运行中所有任务的日志
  3. airflow_tail_dag_run -使用最近的活动和日志跟踪/监视DAG运行

安装和部署

地方发展

通过NPX(建议用于Claude Desktop)

npx mcp-server-airflow

HTTP服务器(建议用于云部署)

npx mcp-server-airflow-http

来源

git clone https://github.com/tomnagengast/mcp-server-airflow.git
cd mcp-server-airflow
npm install
npm run build

# For stdio mode (Claude Desktop)
npm start

# For HTTP mode (cloud deployment)
npm run start:http

云部署(推荐)

此服务器支持流式HTTP传输,这是MCP服务器的当前最佳实践。部署到您首选的云平台:

快速部署

npm run deploy

此交互式脚本将指导您部署到:

  • 谷歌云平台(云运行)
  • 亚马逊网络服务(ECS Fargate)
  • 数字海洋应用平台
  • Netlify(无服务器功能)

手动部署选项

🌐 Google Cloud Platform (Cloud Run)

# Build and push to Container Registry
gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/mcp-server-airflow

# Create secrets
echo "https://your-airflow-instance.com" | gcloud secrets create airflow-base-url --data-file=-
echo "your_token_here" | gcloud secrets create airflow-token --data-file=-

# Deploy to Cloud Run
gcloud run deploy mcp-server-airflow \
  --image gcr.io/YOUR_PROJECT_ID/mcp-server-airflow \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated \
  --port 3000 \
  --memory 512Mi \
  --set-secrets AIRFLOW_BASE_URL=airflow-base-url:latest,AIRFLOW_TOKEN=airflow-token:latest

☁️ Amazon Web Services (ECS Fargate)

# Create ECR repository
aws ecr create-repository --repository-name mcp-server-airflow

# Build and push image
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
docker build -t mcp-server-airflow .
docker tag mcp-server-airflow:latest YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mcp-server-airflow:latest
docker push YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/mcp-server-airflow:latest

# Create secrets in Secrets Manager
aws secretsmanager create-secret --name airflow-config --secret-string '{"base_url":"https://your-airflow-instance.com","token":"your_token_here"}'

# Register task definition and create service (use provided template)
aws ecs register-task-definition --cli-input-json file://deploy/aws-ecs-fargate.json

🌊 DigitalOcean App Platform

  1. 将此存储库分叉到您的GitHub帐户
  2. 在DigitalOcean应用平台中创建新应用
  3. 连接您的分叉存储库
  4. 使用提供的应用程序规范: deploy/digitalocean-app.yaml
  5. 在仪表板中设置环境变量:

- AIRFLOW_BASE_URL - AIRFLOW_TOKEN (或 AIRFLOW_USERNAMEAIRFLOW_PASSWORD)

⚡ Netlify (Serverless Functions)

Netlify提供了出色的无服务器部署,内置了CI/CD和全局CDN。

快速部署

# Interactive deployment script (includes environment setup)
node scripts/deploy-netlify.js

# Or manage environment variables separately
npm run env:netlify

手动部署

# Install Netlify CLI
npm install -g netlify-cli

# Authenticate with Netlify
netlify login

# Build for Netlify
npm run build:netlify

# Initialize site (first time only)
netlify init

# Deploy to production
netlify deploy --prod

环境变量

选项1:使用Netlify CLI(推荐)

# Interactive environment setup
npm run env:netlify

# Or manually set variables
netlify env:set AIRFLOW_BASE_URL "https://your-airflow-instance.com"
netlify env:set AIRFLOW_TOKEN "your_api_token"

# For basic auth instead of token
netlify env:set AIRFLOW_USERNAME "your_username"
netlify env:set AIRFLOW_PASSWORD "your_password"

# List current variables
netlify env:list

选项2:Netlify仪表板

在Netlify站点仪表板中设置这些(站点设置→ 环境变量):

  • AIRFLOW_BASE_URL:您的Airflow实例URL
  • AIRFLOW_TOKEN:您的Airflow API代币(推荐)

或者对于基本身份验证:

  • AIRFLOW_USERNAME:您的Airflow用户名
  • AIRFLOW_PASSWORD:您的气流密码

地方发展

# Install dependencies
npm install

# Start local Netlify development server
npm run dev:netlify

您的MCP服务器将在 http://localhost:8888/.netlify/functions/mcp

Docker部署

# Build image
npm run docker:build

# Run with environment file
npm run docker:run

# Or with docker-compose
docker-compose up

配置

服务器需要通过环境变量进行身份验证配置:

选项1:API代币(推荐)

export AIRFLOW_BASE_URL="https://your-airflow-instance.com"
export AIRFLOW_TOKEN="your_api_token_here"

选项2:基本身份验证

export AIRFLOW_BASE_URL="https://your-airflow-instance.com"
export AIRFLOW_USERNAME="your_username"
export AIRFLOW_PASSWORD="your_password"

环境变量

变量必填描述
AIRFLOW_BASE_URL您的Airflow实例的基本URL
AIRFLOW_TOKEN没有用于身份验证的\*API令牌
AIRFLOW_USERNAME否\*基本身份验证的用户名
AIRFLOW_PASSWORD否\*基本身份验证密码

\*要么 AIRFLOW_TOKEN 或两者 AIRFLOW_USERNAMEAIRFLOW_PASSWORD 必须提供。

平台特定设置

天文学家

export AIRFLOW_BASE_URL="https://your-deployment.astronomer.io"
export AIRFLOW_TOKEN="your_astronomer_api_token"

谷歌云编辑器

export AIRFLOW_BASE_URL="https://your-composer-environment-web-server-url"
export AIRFLOW_TOKEN="your_gcp_access_token"

亚马逊 MWAA

export AIRFLOW_BASE_URL="https://your-environment-name.airflow.region.amazonaws.com"
# Use AWS credentials with appropriate IAM permissions

测试

局部测试

测试stdio和HTTP模式:

# Set required environment variables
export AIRFLOW_BASE_URL="https://your-airflow-instance.com"
export AIRFLOW_TOKEN="your_api_token_here"

# Run comprehensive local tests
npm run test:local

HTTP API测试

部署后,测试您的HTTP端点:

# Health check
curl https://your-deployed-url/health

# MCP initialization
curl -X POST https://your-deployed-url/ \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0.0"}}}'

# List available tools
curl -X POST https://your-deployed-url/ \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}'

Claude桌面集成

标准模式(地方发展)

将此添加到您的Claude Desktop MCP设置中:

{
  "mcpServers": {
    "airflow": {
      "command": "npx",
      "args": ["mcp-server-airflow"],
      "env": {
        "AIRFLOW_BASE_URL": "https://your-airflow-instance.com",
        "AIRFLOW_TOKEN": "your_api_token_here"
      }
    }
  }
}

HTTP模式(云部署)

对于可流式传输的HTTP,请配置Claude以使用您部署的端点:

{
  "mcpServers": {
    "airflow": {
      "transport": {
        "type": "http",
        "url": "https://your-deployed-url"
      }
    }
  }
}

特定于平台的端点:

  • Netlify: https://your-site.netlify.app/mcp
  • 谷歌云运行: https://your-service-url.run.app/
  • AWS/数字海洋: https://your-deployed-url/

使用示例

连接后,您可以使用自然语言与Airflow进行交互:

DAG管理

  • “列出我的所有DAGs”
  • “显示data_pipeline DAG的详细信息”
  • “使用自定义配置触发daily_etl DAG”
  • “暂停有问题的dag”

监控和状态

  • “my_workflow的最新运行状态如何?”
  • “显示上次运行中所有失败的任务实例”
  • “列出从今天起my_data_pipeline的所有DAG运行”

日志记录和调试

  • “显示run-daily_etl_2024_01_15中extract_data任务的日志”
  • “每天获取失败的DAG运行的所有日志_etl_2024_01_15”
  • “跟踪当前的DAG运行,并向我展示发生了什么”
  • “显示正在运行的data_pipeline的最近活动”

高级示例

  • “获取DAG'etl_pipeline'中任务'transform_data'的日志,运行'manual_2024_01_15',尝试编号2”
  • “监视DAG运行'scheduled_2024_01_15',并显示每个任务的最后100条日志行”
  • “显示DAG运行失败后前5个任务的日志”

身份验证要求

该服务器使用Airflow的稳定REST API(v1),这需要身份验证。API支持:

  • 承载令牌身份验证:最安全,建议用于生产
  • 基本认证:用户名/密码,对开发有用
  • 会话身份验证:使用基于web的令牌时自动处理

安全注意事项

  • 安全地存储凭据,永远不要将其提交给版本控制
  • 使用环境变量或安全的秘密管理系统
  • 对于生产部署,首选API令牌,而不是用户名/密码
  • 确保您的Airflow实例具有适当的网络安全性(TLS、VPC等)
  • 应用适当的速率限制和监控
  • 将HTTPS端点用于生产部署
  • 在负载均衡器/网关级别实施适当的身份验证和授权

性能和扩展

HTTP模式的优点

  • 无状态:每个请求都是独立的,允许水平缩放
  • 缓存:响应可以在CDN/代理级别缓存
  • 负载平衡:多个实例可以处理请求
  • 监控:标准HTTP监控工具开箱即用
  • 调试:使用标准HTTP工具易于测试和调试

推荐的生产设置

  • 自动缩放:根据CPU/内存使用情况配置云平台以进行扩展
  • 健康检查:使用 /health 负载平衡器运行状况检查的端点
  • 监控:设置日志记录和指标收集
  • 缓存:考虑缓存频繁访问的DAG信息
  • 速率限制:实施速率限制以保护您的Airflow实例

API兼容性

此服务器与Apache Airflow 2.x REST API兼容。它已经过以下测试:

  • 阿帕奇气流2.7+
  • 天文学家软件和云
  • 谷歌云编辑器2
  • 亚马逊MWAA(所有支持的Airflow版本)

发展

# Clone the repository
git clone https://github.com/tomnagengast/mcp-server-airflow.git
cd mcp-server-airflow

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

贡献

欢迎投稿!请随时提交拉取请求。

许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

相关项目

目录标签

目录标签

工作流管理JavaScriptClaude混合部署任务编排日志监控Airflow集成自动化运维

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

mcp-server-airflow

工具数量(toolCount,工具数)

12

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP