本项目提供一个本地常驻的 streamable HTTP MCP 服务,用于以只读方式访问多个命名数据库连接。
当前支持:
- MySQL
- PostgreSQL
go build -o bin/echobase-mcp ./cmd/echobase-mcp
go build -o bin/echobase-ctl ./cmd/echobase-ctl./bin/echobase-ctl start test
./bin/echobase-ctl start prod
./bin/echobase-ctl start all
./bin/echobase-ctl status
./bin/echobase-ctl doctor
./bin/echobase-ctl restart test
./bin/echobase-ctl stop prod
./bin/echobase-ctl stop all默认约定:
test使用configs/config.local.yamlprod使用configs/config.prod.yamltest监听127.0.0.1:39001prod监听127.0.0.1:39002- 日志写到
.echobase/logs/*.log - PID 写到
.echobase/run/*.pid
如果需要直接手动启动服务进程,也可以这样运行:
./bin/echobase-mcp --config $PWD/configs/config.local.yaml --listen 127.0.0.1:39001
./bin/echobase-mcp --config $PWD/configs/config.prod.yaml --listen 127.0.0.1:39002健康检查地址:
- test:
http://127.0.0.1:39001/healthz - prod:
http://127.0.0.1:39002/healthz
MCP 地址:
- test:
http://127.0.0.1:39001/mcp - prod:
http://127.0.0.1:39002/mcp
仓库里当前有三份配置:
configs/config.local.yaml:测试环境configs/config.prod.yaml:正式环境configs/config.example.yaml:脱敏示例模板
如果测试和正式里都存在同名数据源,保留相同的 connections[].name 即可;客户端通过外层服务名区分环境,服务列表通过 server.title 提示当前连接的是哪一套环境。
echobase-ctl 不会修改你的客户端配置文件,只负责服务的启动、关闭、状态查看和片段生成。
如果你把完整 DSN 直接写进配置文件,这一步可以跳过。
环境变量示例(仅在配置文件里使用 ${...} 占位符时需要):
export ORDERS_MYSQL_DSN='user:pass@tcp(localhost:3306)/orders'
export ANALYTICS_PG_DSN='postgres://user:pass@localhost:5432/analytics?sslmode=disable'Codex 可直接让控制命令生成官方 config.toml 片段:
./bin/echobase-ctl snippet codex输出示例:
[mcp_servers.echobase_test]
url = "http://127.0.0.1:39001/mcp"
[mcp_servers.echobase_prod]
url = "http://127.0.0.1:39002/mcp"也可以直接用 Codex CLI 添加:
codex mcp add echobase_test --url http://127.0.0.1:39001/mcp
codex mcp add echobase_prod --url http://127.0.0.1:39002/mcpClaude Code 可生成 .mcp.json 风格的片段:
./bin/echobase-ctl snippet claude输出示例:
{
"mcpServers": {
"echobase_test": {
"type": "http",
"url": "http://127.0.0.1:39001/mcp"
},
"echobase_prod": {
"type": "http",
"url": "http://127.0.0.1:39002/mcp"
}
}
}推荐固定使用:
echobase_test对应configs/config.local.yamlechobase_prod对应configs/config.prod.yaml
这样两边即使都存在 evaluation、message_center、myqa 这类同名连接,也不会混淆。
查看某个环境的日志:
./bin/echobase-ctl logs test
./bin/echobase-ctl logs prod服务提供以下只读工具:
list_connectionslist_namespaceslist_tablesdescribe_tablerun_read_query