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 query "SELECT count(*) FROM open_api_request_logs WHERE created_at > now() - interval '1 day'" --limit 10

仅允许 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}
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.3.0.tar.gz (12.4 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.3.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: archery_sql_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 12.4 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.3.0.tar.gz
Algorithm Hash digest
SHA256 e80e954a5be2e76eadc9ef8d8e49cf91278f173de56f4e6f97732a0e4795cb79
MD5 63613c2a85ef7fa8771830ce8ed90d06
BLAKE2b-256 edfa40e6bafa46dc387b35d34be4a03577d6a94095194b7a1333ff8f339fca66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: archery_sql_mcp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e11b48e7b31002cbb7b12a622e1324b9ea99b567939727da146a9302b7c515bc
MD5 25a9c328218537f45b3995984d1672a1
BLAKE2b-256 304e1a2db677a7ec84c7a1e85771a177b3616cd9c03c1a32dc77aaf6fa95dd7b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.1

2 files

This release

0.3.0 This release

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