Skip to main content
Glama
@rubyls/yearning-mcp

@rubyls/yearning-mcp

by rubyLs

@rubyls/yearning-mcp

Yearning SQL 审核平台的 MCP Server(TypeScript)。不只读查询,还覆盖完整工单能力:提交 DDL/DML、审核(同意/驳回)、撤回、查询申请、评论,以及数据源/表结构探查。

基于 Yearning REST / WebSocket API(/api/v2,JWT Bearer)。列表类与查询执行走 WebSocket,其余为 REST。

仓库:https://github.com/rubyLs/yearning_mcp

快速接入(推荐)

在 Cursor / Claude Desktop 的 MCP 配置中:

{
  "mcpServers": {
    "yearning": {
      "command": "npx",
      "args": ["-y", "@rubyls/yearning-mcp"],
      "env": {
        "YEARNING_URL": "http://your-yearning:8000",
        "YEARNING_USERNAME": "your-user",
        "YEARNING_PASSWORD": "your-password",
        "YEARNING_LOGIN_TYPE": "general",
        "YEARNING_READ_ONLY": "false"
      }
    }
  }
}

也可全局安装后使用:

npm i -g @rubyls/yearning-mcp
yearning-mcp

Related MCP server: sql-explorer-mcp

Docker(单容器 HTTP)

镜像已发布到 Docker Hub:rubyls/yearning-mcp

# 直接拉取运行(推荐)
docker run -d --name yearning-mcp -p 8080:8080 \
  -e MCP_AUTH_TOKEN=your-strong-token \
  -e YEARNING_URL=http://your-yearning:8000 \
  -e YEARNING_USERNAME=your-user \
  -e YEARNING_PASSWORD=your-password \
  -e YEARNING_READ_ONLY=false \
  rubyls/yearning-mcp:latest

# 指定版本
# rubyls/yearning-mcp:1.1.3

本地构建(可选):

docker build -t yearning-mcp:latest .
# 或 npm run docker:build
  • 健康检查:GET http://localhost:8080/health

  • MCP 端点:http://localhost:8080/mcp

  • Header:Authorization: Bearer <MCP_AUTH_TOKEN>

Cursor 连接示例:

{
  "mcpServers": {
    "yearning": {
      "url": "http://localhost:8080/mcp",
      "headers": {
        "Authorization": "Bearer your-strong-token"
      }
    }
  }
}

容器内访问宿主机 Yearning 时,macOS/Windows 可用 host.docker.internal 代替 localhost。

维护者推送镜像:

npm run docker:build
npm run docker:push
# 需已 docker login,镜像会打上 rubyls/yearning-mcp:1.1.3 与 :latest

功能一览

只读工具(14)

工具

说明

yearning_user_info

当前用户与可查询数据源

yearning_list_sources

数据源列表

yearning_list_databases

库列表

yearning_list_tables

表列表

yearning_table_fields

表结构(字段 + 索引)

yearning_sql_check

提交前 SQL 审核检测

yearning_my_orders

我的工单列表

yearning_order_detail

工单详情

yearning_order_timeline

审核时间线 / 步骤(含 flag)

yearning_rollback_sql

回滚 SQL

yearning_audit_orders

待我审核的工单

yearning_query_status

查询审核开关与我的查询工单状态

yearning_run_query

只读 SELECT(msgpack WebSocket)

yearning_order_comments

读取工单评论

写工具(5,YEARNING_READ_ONLY=false 时注册)

工具

说明

yearning_submit_order

提交 SQL 工单(需 confirm=true;backup=1 开启回滚备份)

yearning_undo_order

撤回未执行工单(需 confirm=true)

yearning_audit_order

审核:agree / reject / undo(需 confirm=true)

yearning_submit_query_order

提交查询申请

yearning_post_comment

发表工单评论

工单状态:0 已驳回 / 1 执行中 / 2 待审核 / 3 已完成 / 4 已终止 / 5 待执行 / 6 已撤回。

推荐流程:

yearning_sql_check → yearning_submit_order → yearning_order_timeline → yearning_audit_order

环境变量

变量

说明

默认

YEARNING_URL

Yearning 地址

http://localhost:8000

YEARNING_USERNAME

登录用户名

(必填)

YEARNING_PASSWORD

登录密码

(必填)

YEARNING_LOGIN_TYPE

general / ldap

general

YEARNING_TIMEOUT

请求超时(秒)

30

YEARNING_READ_ONLY

true 时不注册写工具

false

YEARNING_INSECURE

跳过 TLS 校验

false

MCP_TRANSPORT

stdio / sse / streamable-http

stdio

MCP_HOST / MCP_PORT

HTTP 监听

0.0.0.0 / 8080

MCP_AUTH_TOKEN

HTTP Bearer 鉴权

(不设则不鉴权)

MCP_STATELESS_HTTP

无状态 HTTP

false

HTTP 远程模式

MCP_TRANSPORT=streamable-http \
MCP_HOST=0.0.0.0 MCP_PORT=8080 \
MCP_AUTH_TOKEN=your-strong-token \
YEARNING_URL=http://your-yearning:8000 \
YEARNING_USERNAME=your-user \
YEARNING_PASSWORD=your-password \
YEARNING_READ_ONLY=false \
npx -y @rubyls/yearning-mcp

客户端连接:http://localhost:8080/mcp,Header:Authorization: Bearer your-strong-token。
健康检查:GET /health(免鉴权)。

从源码运行

git clone https://github.com/rubyLs/yearning_mcp.git
cd yearning_mcp
npm install
npm run build
npm start

Cursor 本地调试:

{
  "mcpServers": {
    "yearning": {
      "command": "node",
      "args": ["/absolute/path/to/yearning_mcp/dist/index.js"],
      "env": {
        "YEARNING_URL": "http://localhost:8000",
        "YEARNING_USERNAME": "your-user",
        "YEARNING_PASSWORD": "your-password",
        "YEARNING_READ_ONLY": "false"
      }
    }
  }
}

对话示例

连上 Yearning,列出我有权限的数据源
把这条建表 SQL 在 dev 数据源做检测,没问题就提工单:
CREATE TABLE t_demo (id INT PRIMARY KEY, name VARCHAR(64));
列出待我审核的工单;工单 XXX 没问题,帮我同意(先看 timeline 拿 flag)
在 order_db 的 user 库查最近 7 天注册账号,前 100 条

开发

npm run dev          # tsx 直接跑 src
npm run build        # 编译到 dist/
npm start            # node dist/index.js
npm publish --access public   # 发布到 npm(需先 npm login)

已知限制

  • 部分 /fetch/* 接口使用 GET + JSON Body;若前置代理丢弃 GET body,列表会静默为空。

  • WebSocket 鉴权依赖 Sec-WebSocket-Protocol 透传裸 JWT,且需正确 Origin。

  • 查询审核开启时,yearning_run_query 需先有已批准的查询工单。

  • 管理端能力(用户/数据源/规则管理)未包含,请在 Yearning 控制台操作。

License

MIT

Available Tools

19 tools
yearning_audit_order审核工单A
Destructive

审核工单:agree 同意(末级步骤会触发 SQL 执行)/ reject 驳回 / undo 撤回。flag 为当前审核步骤序号(用 yearning_order_timeline 确认);reject 必须提供 reason。agree 为高危操作,必须 confirm=true。对应 POST /api/v2/audit/order/state

Inputs: flag (required), action (required), confirm (required), work_id (required), +3 more.

yearning_audit_orders待审工单列表A
Read-onlyIdempotent

分页列出与当前用户相关的待审核工单(审核人视角)。对应 WS /api/v2/audit/order/list

Inputs: page, text, status, work_id, +2 more.

yearning_list_databases列出库B
Read-onlyIdempotent

列出指定数据源下的数据库列表。对应 GET /api/v2/fetch/base

Inputs: source_id (required), hide, response_format.

yearning_list_sources列出数据源B
Read-onlyIdempotent

列出当前账号有权限的数据源(可按 query/dml/ddl/idc 过滤)。对应 GET /api/v2/fetch/source

Inputs: tp, response_format.

yearning_list_tables列出表A
Read-onlyIdempotent

列出指定数据源、指定库下的表。对应 GET /api/v2/fetch/table

Inputs: database (required), source_id (required), response_format.

yearning_my_orders我的工单列表A
Read-onlyIdempotent

分页列出当前用户提交的工单。状态:8=全部 / 2=待审核 / 3=已完成 / 0=已驳回 / 4=已终止 / 6=已撤回 / 1=执行中 / 5=待执行。对应 WS /api/v2/common/list

Inputs: page, text, status, work_id, +2 more.

yearning_order_comments工单评论A
Read-onlyIdempotent

读取指定工单的全部评论。对应 WS /api/v2/fetch/comment

Inputs: work_id (required), response_format.

yearning_order_detail工单详情B
Read-onlyIdempotent

查看工单详情:SQL 明细与完整 SQL。对应 GET /api/v2/fetch/detail + /fetch/sql

Inputs: work_id (required), page, page_size, response_format.

yearning_order_timeline工单审核时间线A
Read-onlyIdempotent

查看工单审核时间线与流程步骤。审核时 flag 取自此处。对应 GET /api/v2/fetch/timeline + /fetch/steps

Inputs: work_id (required), source_id, response_format.

yearning_post_comment发表工单评论C

在指定工单下发表评论。对应 POST /api/v2/fetch/comment

Inputs: comment (required), work_id (required).

yearning_query_status查询审核状态B
Read-onlyIdempotent

查看查询审核开关,以及当前用户查询工单是否有效。对应 GET /api/v2/fetch/is_query + /fetch/query_status

Inputs: response_format.

yearning_rollback_sql回滚 SQLA
Read-onlyIdempotent

获取工单的回滚 SQL。对应 GET /api/v2/fetch/roll

Inputs: work_id (required), response_format.

yearning_run_query执行查询A
Read-onlyIdempotent

在指定数据源执行只读 SELECT 查询。需具备查询权限;若开启查询审核,需先 yearning_submit_query_order。对应 WS /api/v2/query/results(msgpack)

Inputs: sql (required), schema (required), source_id (required), limit, +1 more.

yearning_sql_checkSQL 审核检测A
Read-onlyIdempotent

提交前对 SQL 做审核检测。建议先调用本工具,再 yearning_submit_order。对应 PUT /api/v2/fetch/test。不接受 SELECT(请用 yearning_run_query)。

Inputs: sql (required), database (required), source_id (required), order_type (required), +1 more.

yearning_submit_order提交 SQL 工单A

提交 SQL 工单(DDL/DML)。提交前建议先 yearning_sql_check。对应 POST /api/v2/common/post。必须传 confirm=true 才会真正提交。

Inputs: sql (required), remark (required), confirm (required), database (required), +7 more.

yearning_submit_query_order提交查询申请A

提交数据查询申请。开通查询审核时需审批通过后方可 yearning_run_query。对应 POST /api/v2/query/post

Inputs: remark (required), source_id (required), export.

yearning_table_fields查看表结构A
Read-onlyIdempotent

查看表结构:字段列表(类型/可空/键/默认值/注释)与索引。对应 GET /api/v2/fetch/fields

Inputs: table (required), database (required), source_id (required), response_format.

yearning_undo_order撤回工单A
Idempotent

撤回自己提交、尚未执行的工单。对应 GET /api/v2/fetch/undo。必须传 confirm=true。

Inputs: confirm (required), work_id (required).

yearning_user_info查看当前用户信息A
Read-onlyIdempotent

查看当前登录用户信息、部门、邮箱,以及有权查询的数据源列表。对应 GET /api/v2/fetch/userinfo

Inputs: response_format.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 19 tools

    Disambiguation5/5

    Each tool targets a distinct resource and action: user info, table metadata, SQL validation, order lifecycle steps, query execution, comments, and audit actions. Overlapping concepts like my_orders vs audit_orders and order_detail vs order_timeline are clearly separated by descriptions.

    Naming Consistency3/5

    All tools share a 'yearning_' prefix and use snake_case, but the action-noun pattern is inconsistent. Some use verb-first forms (list_sources, run_query, submit_order), while others are noun-first (user_info, order_detail, sql_check). List-like tools are not uniformly prefixed (my_orders, order_comments vs list_tables).

    Tool Count4/5

    With 19 tools, the set is slightly above the typical well-scoped range but is justified by the breadth of the Yearning platform. The count does not feel bloated, and each tool covers a necessary aspect of SQL order management and querying.

    Completeness5/5

    The toolkit thoroughly covers the domain: schema inspection, SQL pre-check, order submission/query/detail/timeline/comments, rollback, audit workflow, and read-only query execution. No major lifecycle gap is apparent, and the tools form a coherent end-to-end workflow.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A production-ready MCP server for MySQL database operations, providing secure HTTP endpoints for read-only queries, performance analysis, and server monitoring.
      22
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      Read-only MCP server for SQL databases (SQL Server, Postgres, SQLite) with multi-server support and three-layer safety using AST validation and linting.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A generic MCP server for MySQL operations, enabling listing databases/tables, describing schemas, running read-only SQL, and optionally executing write SQL with logging.
      1
      -
    • A
      license
      A
      quality
      B
      maintenance
      MCP server for Yearning SQL audit platform that enables AI assistants to query and manage orders, browse data sources and table structures, submit and review SQL orders, and execute read-only queries.
      14
      MIT