未来数据库MCP Server应该长这样
未来数据库MCP Server的样子
pg weekly推荐了一款pg mcp server
https://github.com/crystaldba/postgres-mcp
我觉得这是数据库mcp应有的样子,tools汇聚了专业人士的经验。
为什么?
1、模型可以自由选择是采用限制模式还是自由模式, 很多数据库mcp非常简陋, 仅提供1个SQL执行接口, 并且限定为只读操作. postgres-mcp 提供了2个选项, 可以执行任何SQL、或者限定为只读.
2、很多数据库MCP就提供1个tools, 那就是执行SQL. 有点“偷懒”. postgres-mcp 提供了很多常用的抽象, 模型即使不会写SQL也可以了.
Database Health Detect unused/duplicate indexes Monitor cache hit rates Check connection utilization Identify vacuum needs before problems occur Index Tuning Generate optimal indexes using proven algorithms Validate AI-suggested indexes Simulate performance impacts with hypothetical indexes Balance performance gain vs storage costs Schema Intelligence Detailed schema information for tables, views & more Context-aware SQL generation Optimal column selection recommendations Protected Execution Unrestricted Mode: Full read/write for development Restricted Mode: Read-only with resource limits for production Safe SQL parsing to prevent security issues
详见代码: https://github.com/crystaldba/postgres-mcp/blob/main/src/postgres_mcp/server.py
MCP标准定义了各种类型的端点:工具、资源、提示等。
Postgres Pro 提供如下MCP 工具接口:
未来可以添加更多tool进来, 方便大模型根据不同的需求进行调用, 而不是“偷懒”的做法:让模型先思考提供SQL, 然后调用tool的execute sql接口. 虽然这种方式最灵活, 但是万一模型给的SQL是错的呢, 那不得迭代N次? 比较浪费模型的token, 也浪费时间, 个人认为对于可以确定的功能就应该直接提供工具接口即可.
这才是未来靠谱数据库MCP Server的样子, 相信很多想成为流行MCP项目的产品都会跟进.