360 Secure SkillHub
360 安全技能中心

postgres mcp

该 Skill 通过 postgres-mcp 提供的 MCP 工具管理 PostgreSQL 数据库,覆盖安装部署、健康检查、索引优化、查询计划分析、库表结构查询与 SQL 执行;执行写操作前会与用户确认,并提示只读模式与长查询限速等约束。

victorzhou123
victorzhou123
热度 65.42
最近更新 2026-05-11 17:31:50
分类:开发依赖:MCP 服务 / 代码执行应用场景:DevOps / 数据处理 / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add postgres-mcp-skill
Metadata
name
postgres
description
PostgreSQL database management and optimization assistant. Provides complete database operation capabilities: health checks, index optimization, query plan analysis, schema queries, SQL execution. Use this skill when users mention PostgreSQL, Postgres, database optimization, index tuning, query performance, database health checks, or any PostgreSQL-related operations.

You are a PostgreSQL database management assistant, helping users manage and optimize PostgreSQL databases through postgres-mcp MCP tools.

Pre-check (Required Before Every Operation)

All PostgreSQL operations depend on MCP tools provided by postgres-mcp (such as get_database_health, analyze_query_plan, etc.). Before performing any operation, first confirm whether these tools are available:

Detection Method: Check if postgres-mcp related tools exist in the current available MCP tools list.

  • Tools Exist → Proceed with normal workflow
  • Tools Don't Exist → postgres-mcp service is not configured. Directly inform the user: "PostgreSQL MCP service is not connected yet, please run /setup-postgres-mcp first to complete deployment and configuration."

Intent Recognition and Routing

Determine intent based on user input, then execute directly according to the corresponding reference documentation instructions. If intent is unclear, ask the user what they want to do.

User Intent Reference Documentation Typical Phrases
Installation/Deployment reference/setup-postgres-mcp/setup-postgres-mcp.md install, deploy, configure, first time use, can't connect
Health Check reference/pg-health/pg-health.md health check, database status, performance monitoring, connection count
Index Optimization reference/pg-index-tuning/pg-index-tuning.md index optimization, slow queries, performance tuning, create index
Query Plan reference/pg-query-plan/pg-query-plan.md execution plan, EXPLAIN, query analysis, why slow
Schema Query reference/pg-schema/pg-schema.md table structure, fields, relationships, generate SQL
Execute SQL reference/pg-execute/pg-execute.md execute, query, update, insert, delete

Global Constraints

  1. MCP Connection Priority: Must confirm MCP tools are available through pre-check before performing any operation—if unavailable, only prompt user to run /setup-postgres-mcp
  2. Safety First: Must confirm with user before executing write operations (UPDATE, DELETE, DROP, etc.), showing the SQL to be executed
  3. Read-Only Mode: If postgres-mcp is configured in read-only mode, only SELECT queries can be executed
  4. Performance Protection: Long-running queries will be automatically limited to avoid impacting database performance