Skip to main content
Glama
DolphinScheduler MCP Server

DolphinScheduler MCP Server

by Chris-Lea

DolphinScheduler MCP Server

把 Apache DolphinScheduler 的 REST API 封装成 Model Context Protocol 工具,让 AI Agent 可以直接查询和操作 DolphinScheduler。

  • 传输方式:stdio(由 MCP 客户端拉起子进程,无需常驻端口)

  • 工具数量:169 个,覆盖项目、工作流定义/任务定义、工作流实例、任务日志、监控与统计、告警、环境、集群、任务组、定时调度、数据源、Worker 分组、审计日志、令牌等

  • 实测环境:DolphinScheduler 2.0 风格 REST API(/dolphinscheduler 上下文路径)

上游 README 中「pip install dolphinscheduler-mcp」和「HTTP 8089 端口」的说法与实际代码不符:该包未发布到 PyPI,且 FastMCP.run() 默认就是 stdio。本仓库按实际实现整理。

环境要求

  • Python >= 3.10(依赖 mcp>=1.2,<2,mcp 1.x 要求 3.10+)

  • 可访问的 DolphinScheduler API,例如 http://localhost:12345/dolphinscheduler

  • 一枚 DolphinScheduler 令牌

Related MCP server: airflow-mcp-server

安装

git clone <本仓库地址> dolphinscheduler-mcp
cd dolphinscheduler-mcp
python -m venv .venv
source .venv/bin/activate
pip install -e .

安装后可用入口命令:ds-mcp。

配置

通过环境变量配置,也可以在 MCP 客户端的配置里用 env 传入:

变量

说明

默认值

DOLPHINSCHEDULER_API_URL

DS API 地址(含 /dolphinscheduler)

http://localhost:12345/dolphinscheduler

DOLPHINSCHEDULER_API_KEY

DS 访问令牌,请求时作为 Token 头

空

DOLPHINSCHEDULER_MCP_LOG_LEVEL

日志级别

INFO

令牌获取:登录 DS Web UI → 右上角用户名 → 安全中心 → 令牌管理 → 创建令牌(需管理员或有权限的账号),复制后填入配置。

接入 MCP 客户端

以 Trae / Claude Desktop 的 mcp.json 为例:

{
  "mcpServers": {
    "dolphinscheduler": {
      "command": "/path/to/.venv/bin/python",
      "args": ["-m", "dolphinscheduler_mcp"],
      "env": {
        "DOLPHINSCHEDULER_API_URL": "http://localhost:12345/dolphinscheduler",
        "DOLPHINSCHEDULER_API_KEY": "你的令牌"
      }
    }
  }
}

也可以直接用入口命令:

{
  "mcpServers": {
    "dolphinscheduler": {
      "command": "ds-mcp",
      "env": {
        "DOLPHINSCHEDULER_API_URL": "http://localhost:12345/dolphinscheduler",
        "DOLPHINSCHEDULER_API_KEY": "你的令牌"
      }
    }
  }
}

配置完成后重启客户端,MCP 列表出现 dolphinscheduler 即接入成功。

工具清单

领域

数量

主要工具

工作流定义

12

list_process_definitions、get_process_definition、get_process_definition_tasks、get_process_definition_versions、create/update/delete/batch_delete_process_definitions、release_process_definition、switch_process_definition_version、verify_process_definition_name、generate_task_codes

工作流实例

12

list_process_instances、get_process_instance、get_process_instance_tasks、get_process_instance_gantt、list_task_instances、execute_process_instance、run_process_definition、batch_delete_process_instances、batch_start_process_instances、get_process_instance_variables、get_process_definition_variables、get_process_definition_tree

任务日志

2

query_task_log(分页读行)、download_task_log(整份下载,可落盘)

实例运维

3

start_task_instance、stop_task_instance、force_success_task_instance

监控与统计

6

get_monitor_servers(masters/workers)、get_database_state、get_process_state_count、get_task_state_count、get_command_state_count、get_project_define_user_count

任务定义

10

list_task_definitions、get/create/update/delete_task_definition、release_task_definition、save_single_task_definition、list_task_definition_versions、switch/delete_task_definition_version

告警

12

list/get/create/update/delete_alert_group、verify_alert_group_name、list/get/create/update/delete_alert_plugin_instance、test_send_alert_plugin_instance

环境

7

list_environments、list_environments_paging、get/create/update/delete_environment、verify_environment_name

集群

7

list_clusters、list_clusters_paging、get/create/update/delete_cluster、verify_cluster_name

任务组(资源队列)

10

create/update_task_group、start/close_task_group、force_start_task_group、modify_task_group_priority、list_task_groups_paging、list_task_groups_by_status、list_task_groups_by_project、list_task_group_queue

定时调度

7

list_schedules、create_schedule、update_schedule、delete_schedule、online_schedule、offline_schedule、preview_schedule_times

数据源

15

create/get/update/delete_datasources、list_datasources_tables、list_datasources_tablecolumns、create_datasources_connect 等

项目

13

get_projects、list_projects_list、create_projects、update_projects、delete_projects 等

任务关系/血缘

12

create_process_task_relation、query_upstream_relation、query_downstream_relation、list_projects_lineages 等

Worker 分组

7

create/get/delete_worker_groups、get_worker_groups_worker_address_list 等

命名空间

7

create_k8s_namespace、get_k8s_namespace 等

项目参数

6

create/get/update/delete_projects_project_parameter 等

访问令牌

6

create/get/update/delete_access_tokens、create_access_tokens_generate 等

审计日志

3

get_projects_audit_audit_log_list 等

项目偏好

3

get/update_projects_project_preference 等

Azure Data Factory

3

list_cloud_azure_datafactory_*

其他

6

UI 插件、动态任务类型、环境检查等

版本兼容说明

不同 DolphinScheduler 版本的接口路径不一致,本仓库按 DS 2.0 风格实现:

  • 工作流定义为单数:/projects/{projectCode}/process-definition

  • 工作流实例、任务实例、定时调度为复数:/process-instances、/task-instances、/schedules

  • list_schedules 必须传 process_definition_code,否则 DS 返回 10080 query schedule list paging error

  • create_schedule / update_schedule 以 query 参数 传递 schedule JSON 字符串(DS 2.0 风格)

  • 统计接口 startDate / endDate 必须传 yyyy-MM-dd HH:mm:ss 格式,只传日期会返回 10001 request parameter startDate,endDate is not valid

实测 DS 3.1.9 上以下接口不可用,故未封装:GET /projects/{p}/process-instances/top-n(稳定报 10116 query process instance by id error)、/projects/analysis/listErrorCommand 与 listCommand(返回 UI 页面 HTML 而非 JSON)。

升级到 DS 3.x 时,工作流定义需改为复数路径 /process-definitions,其余按目标版本接口文档调整。

开发

新增工具:在 src/dolphinscheduler_mcp/tools_generated/ 下新建 *_tools.py,实现 register_xxx_tools(mcp),并在同目录 __init__.py 中导入与调用。参考 process_definition_tools.py 的写法(使用 @mcp.tool 装饰器,异步函数 + 类型注解生成参数 schema)。

pip install -e ".[dev]"
pytest

自动化巡检(可选)

scripts/triage_github.py 每日拉取新增/更新的 Issue 与 PR,按 bug / pr / feature / docs / question 分诊,生成 .agent/reports/YYYY-MM-DD.md(已在 .gitignore 中忽略)。脚本只读:不评论、不打标签、不改代码;状态记录在 .agent/state.json,同一条目更新后会重新进入报告。

cron 示例(每天 08:00,凭据单独存放并 chmod 600):

0 8 * * * set -a; . ~/.config/ds-mcp-triage.env; set +a; cd /path/to/dolphinscheduler-mcp && python3 scripts/triage_github.py >> .agent/triage.log 2>&1

~/.config/ds-mcp-triage.env 内容:

GITHUB_TOKEN=你的_PAT
GITHUB_REPO=Chris-Lea/dolphinscheduler-mcp

处理约定(Agent 或人工执行):

  1. 逐条判断:可复现 → 从 main 拉 agent/issue-<n> 分支修复并开 PR;需澄清 → 在 issue 下回复;不处理 → 说明原因并标记 wontfix

  2. 不直接推 main,所有代码改动必须走 PR 并通过 CI

  3. 回复注明「由 AI 辅助生成,已人工确认」,并附 PR 链接

  4. 单日配额:5 个 PR / 20 条评论,超出转人工

  5. 危险改动(.github/workflows、依赖版本、删除文件、权限)只评论不改码

  6. 不 checkout 或执行外部 PR 的代码,只在主分支上改

License

Apache License 2.0,见 LICENSE。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables Claude to inspect and operate Apache Airflow over its REST API, providing read tools and safe write operations (gated by read-only mode) for managing DAGs, runs, tasks, and pools.
      14
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A comprehensive MCP server and CLI that exposes the entire Dify console API as 138 tools, enabling AI agents to programmatically build, test, and publish Dify workflows and manage all aspects of the Dify platform.
      33
      Apache 2.0
    • A
      license
      B
      quality
      B
      maintenance
      Production-ready MCP server for Apache DolphinScheduler. Enables AI agents to operate data workflows end-to-end with 58 tools covering DAG creation, schedule management, instance control, guided troubleshooting, serial backfills, and version rollback.
      58
      26
      Apache 2.0