Skip to content
ReyYangPublic

About

本地 MCP 多数据源服务

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

27 Commits

Folders and files

Repository files navigation

EchoBase MCP

本项目提供一个本地常驻的 streamable HTTP MCP 服务,用于以只读方式访问多个命名数据库连接。

当前支持:

  • MySQL
  • PostgreSQL

Build

go build -o bin/echobase-mcp ./cmd/echobase-mcp
go build -o bin/echobase-ctl ./cmd/echobase-ctl

Start And Stop

./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

默认约定:

如果需要直接手动启动服务进程,也可以这样运行:

./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

Config

仓库里当前有三份配置:

如果测试和正式里都存在同名数据源,保留相同的 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'

Client Setup

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/mcp

Claude 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"
    }
  }
}

推荐固定使用:

这样两边即使都存在 evaluation、message_center、myqa 这类同名连接,也不会混淆。

Logs

查看某个环境的日志:

./bin/echobase-ctl logs test
./bin/echobase-ctl logs prod

Tools

服务提供以下只读工具:

  • list_connections
  • list_namespaces
  • list_tables
  • describe_table
  • run_read_query

About

本地 MCP 多数据源服务

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages