remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
Manages configuration through environment variables using .env files for storing database credentials, server settings, and security parameters.
Supports repository cloning for installation and source code management during development.
Provides example code for API interaction, allowing clients to execute queries and interact with analysis templates.
MCP PostgreSQL 服务器
模型-控制器-提供程序 (MCP) 服务器:
- 连接到 PostgreSQL 数据库
- 将表模式公开为资源
- 提供运行只读 SQL 查询的工具
- 包括常见数据分析任务的提示
特征
- 模式探索:浏览数据库模式、表和列
- 只读查询执行:安全地对数据库运行 SQL 查询
- 数据分析提示:针对常见分析任务的预建 SQL 模板
- 数据可视化:生成可视化数据
- 关系探索:可视化表关系和外键
- API 文档:自动生成的 OpenAPI 规范
建筑学
此应用程序遵循模型-控制器-提供者(MCP)模式:
- 模型层:直接与数据库交互
- 提供层:业务逻辑和数据处理
- 控制器层:API 端点和请求处理
安全功能
- 只读查询验证
- SQL注入保护
- 速率限制
- 参数化查询
- 身份验证支持
- CORS 配置
安装
- 克隆存储库:Copy
- 安装依赖项:Copy
- 根据
.env.template
创建.env
文件:Copy - 使用您的 PostgreSQL 数据库凭证更新
.env
文件。 - 启动服务器:Copy
配置
所有配置都通过环境变量进行管理:
- 服务器:端口、环境、CORS 设置
- 数据库:连接详细信息、池设置
- 安全性:JWT 设置、速率限制
- 查询:执行限制、结果大小限制
API 端点
架构端点
GET /api/schemas
- 列出所有架构GET /api/schemas/:schema/tables
- 列出模式中的表GET /api/schemas/:schema/tables/:table
- 获取表架构详细信息GET /api/schemas/:schema/relationships
- 获取表关系GET /api/structure
- 获取完整的数据库结构GET /api/search?q=term
- 搜索表和列
查询端点
POST /api/query
- 执行 SQL 查询POST /api/query/explain
- 获取查询执行计划GET /api/schemas/:schema/tables/:table/sample
- 获取示例数据GET /api/schemas/:schema/tables/:table/stats
- 获取表统计信息
分析提示端点
GET /api/prompts
- 列出分析提示模板GET /api/prompts/:templateId
- 获取提示模板详细信息POST /api/prompts/:templateId/generate
- 从模板生成 SQLGET /api/schemas/:schema/tables/:table/analysis/suggest
- 获取分析建议
示例查询
基本表查询
Copy
使用分析提示
Copy
发展
- 以开发模式运行:
npm run dev
- 运行测试:
npm test
- Lint 代码:
npm run lint
执照
麻省理工学院
You must be authenticated.
连接到 PostgreSQL 数据库并提供用于安全探索模式、运行只读 SQL 查询以及使用预建模板执行数据分析的工具的服务器。