多功能数据库模式MCP服务器
一个强大的MCP服务器,用于读取和暴露多种数据库类型的模式信息。
快速入门
安装依赖
- 创建并激活虚拟环境:
- Unix/macOS:
python -m venv venv && source venv/bin/activate
- Windows:
python -m venv venv && venv\Scripts\activate
- Unix/macOS:
- 安装依赖:
pip install -r requirements.txt
启动服务
运行以下命令启动服务器:python src/server.py
使用示例
- 连接数据库
config = { "type": "postgresql", "host": "localhost", "port": 5432, "database": "mydb", "username": "user", "password": "password" } result = await connect_database(config)
- 列出表
tables = await list_tables("postgresql://user:password@localhost:5432/mydb")
- 获取表结构
schema = await get_table_schema("postgresql://user:password@localhost:5432/mydb", "users")
- 获取完整数据库结构
schema = await get_database_schema("postgresql://user:password@localhost:5432/mydb")