Skip to main content

archery-sql-mcp

Archery SQL 平台(sql.tec-develop.com)查询工具:自动登录 + 会话自愈 + 只读查询。 双模式运行——无参数启动为 MCP stdio server(任何 MCP 客户端可接入),带子命令则为 CLI。

安装

发布到 PyPI 后(最短路径):

uvx archery-sql-mcp --help          # 免安装直接跑
uv tool install archery-sql-mcp     # 或安装为全局命令

从内部 Git 仓库:

uv tool install git+https://git.tec-do.cn/<group>/archery-mcp.git

本地开发:

git clone <仓库地址> && cd archery-mcp
uv run --project . archery-sql-mcp --help

初始化账号密码(一次性)

archery-sql-mcp init

交互式录入 Archery 地址 / 用户名 / 密码(不回显)/ 默认实例 / 默认库, 写入 ~/.archery-mcp/config.json 并立即登录验证。

密码为本地明文存储(仅存于本机用户目录,不进任何 git 仓库)。 不想落盘的机器可改用环境变量:ARCHERY_USERNAME / ARCHERY_PASSWORD / ARCHERY_BASE_URL / ARCHERY_INSTANCE / ARCHERY_DB

会话缓存于 ~/.archery-mcp/session.json,冷启动自动复用(最长约两周), 过期自动重新登录,调用方无感。

自检与使用

archery-sql-mcp check    # 登录 + SELECT 1 全链路验证
archery-sql-mcp instances # 列出有读权限的数据库实例
archery-sql-mcp query "SELECT id, status, error_message FROM cv_video_script_audit_tasks ORDER BY created_at DESC LIMIT 10"
archery-sql-mcp redis "scan 0 match creator_email:* count 100"   # 只读查线上 Redis

仅允许 SELECT / WITH 开头的语句(可在配置 allowed_prefixes 扩展)。

一键注册到各 agent 客户端

# 注册到全部支持的 agent 的用户级配置(zcode / claude-code / claude-desktop / codex / cursor)
uvx archery-sql-mcp install-mcp

# 仅注册指定 agent,写入当前目录的项目级配置(进 git 共享,command 自动用可移植的 uvx)
uvx archery-sql-mcp install-mcp --agents claude-code,codex --scope project

写入规则:合并式更新(保留配置文件中的既有内容)、幂等(重复执行不产生重复条目)、 用户级默认写入本机 uvx 绝对路径、项目级默认写入可移植的命令名 uvx(加 --portable 强制全局可移植)。 各 agent 写入位置:ZCode ~/.zcode/cli/config.json(mcp.servers)· Claude Code ~/.claude.json / 项目 .mcp.json · Claude Desktop %APPDATA%\Claude\claude_desktop_config.json · Codex ~/.codex/config.toml(mcp_servers 段)· Cursor ~/.cursor/mcp.json / 项目 .cursor/mcp.json。写入后重启对应客户端会话生效。

接入 MCP 客户端(手工方式)

ZCode(~/.zcode/cli/config.json)、Claude Desktop、Cursor(~/.cursor/mcp.json)同构:

{
  "mcpServers": {
    "archery": {
      "command": "uvx",
      "args": ["--from", "git+https://git.tec-do.cn/<group>/archery-mcp.git", "archery-sql-mcp"]
    }
  }
}

Claude Code:

claude mcp add archery -- uvx --from git+https://git.tec-do.cn/<group>/archery-mcp.git archery-sql-mcp

接入后 agent 可调用 5 个工具:

工具 用途
query(sql, db_name?, instance_name?, limit=100) 只读查询(仅 SELECT / WITH),返回 {status, columns, rows, row_count, elapsed_ms}
query_redis(command, db_name?, instance_name?) 只读查询线上 Redis(默认 alisg-haiyun-powerdata-redis-prod-01 db0):get/scan/hgetall/ttl/type 等;写命令拒绝,遍历 key 用 scan 0 match 前缀*(keys 被平台禁用)
get_token() 登录并返回 token 概要(掩码显示,完整值在本机 session.json)
refresh_token() 强制刷新 token(清缓存重新登录)
list_instances() 列出有读权限(can_read)的数据库实例
instance_resources(resource_type, db_name?, instance_name?, schema_name?, tb_name?) 探查实例结构:schema / table / column

配置说明

配置优先级:环境变量 > ~/.archery-mcp/config.json > 内置默认。 配置文件支持多 profile(ARCHERY_PROFILE 选择):

{
  "default_profile": "prod",
  "profiles": {
    "prod": {
      "base_url": "https://sql.tec-develop.com",
      "username": "xxx",
      "password": "yyy",
      "instance_name": "alisg-haiyun-powerdata-pgsql-prod-01",
      "db_name": "creativault_business",
      "limit_num": 100,
      "allowed_prefixes": ["select", "with"],
      "poll_interval_s": 1,
      "query_timeout_s": 60
    }
  }
}

错误行为

场景 行为
session 过期 自动重登并重放请求,调用方无感
密码错 / 账号禁用 明确报错,不重试
非 SELECT 语句 客户端预检拒绝
SQL 语法错 透传数据库错误原文
查询超时 报错并附 query_id

密码与 sessionid 永不出现在日志和工具返回值中。

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

archery_sql_mcp-0.4.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

archery_sql_mcp-0.4.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file archery_sql_mcp-0.4.0.tar.gz.

File metadata

  • Download URL: archery_sql_mcp-0.4.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for archery_sql_mcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3a10c0d166ff0d982eb3de77b39f9a4bf586dc7394749d7d57d4dc688ed1d155
MD5 f485ab36311c873b42b88060bc2bbf80
BLAKE2b-256 e359c9c745989f9f677e70577ba2dc1cc08c1bbecc0e67bc5ee6f21685f87639

See more details on using hashes here.

File details

Details for the file archery_sql_mcp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: archery_sql_mcp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for archery_sql_mcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0a262e9de961825904f46d69dd45475b5f8111e5f23103dcd594bc24c06a1d
MD5 bdc1cf975a98f75b5e5bcc9ddcb88550
BLAKE2b-256 e06e270de4998ef525a74db63b7954061bfb76a5b22169b48f3571b07b42c351

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page