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 扩展)。
接入 MCP 客户端
ZCode(~/.zcode/mcp.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file archery_sql_mcp-0.2.1.tar.gz.
File metadata
- Download URL: archery_sql_mcp-0.2.1.tar.gz
- Upload date:
- Size: 9.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c26993b6e9648c25386c38dff5a1dcbfcce08291aa85741870c6f512eefecd1
|
|
| MD5 |
af8b9a556042bfcc80e501c9d5b342b0
|
|
| BLAKE2b-256 |
df951dded34c226eed8e4d47e8e1b1a00a86ad00a0b5e3d0cdbe267437d76d9d
|
File details
Details for the file archery_sql_mcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: archery_sql_mcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1eed348c55030dd82ff1917048c84166e670bf6d24ba81e5e455181de775e92
|
|
| MD5 |
52cda26e397cbd113dc950105d737f75
|
|
| BLAKE2b-256 |
32edec80d98435a2297e72df8defd899a9c9f909273448e2bc0ecd8c03690b1e
|