Vault Sync DB
Overview
Use this skill to refresh the database credentials the PostgreSQL MCP uses. The Vault MCP tool vault_sync_db_creds_to_postgres_mcp generates the dynamic credentials server-side and writes them straight into ~/postgresql-mcp-config/environments.json — the same logic as the Sync button in the Vault Web UI. The username and password never enter the conversation; the tool only returns the MCP environment name and whether it was created or updated.
Some clients expose the tools as mcp__mcp_vault__* or mcp__vault__*; discover the connected prefix if it differs.
Workflow
- Parse the environment (
dev,sat,prod,local) and one or more services from the user prompt. - If the environment or the service is missing, ask only for the missing field. Do not guess an environment.
- Call
vault_loginwith the environment. - For each service, call
vault_sync_db_creds_to_postgres_mcpwithservice: SERVICE. One call per service; reuse the single login for services in the same environment. Different environments need their ownvault_loginfirst, because the target MCP environment name is derived from the currently logged-in environment. - If a sync fails with an authentication error, call
vault_loginfor that environment and retry that sync once. - Report the result per service using the returned
environmentandaction.
Parsing Rules
- Parse by token meaning, not position:
dev accounting,accounting dev, andsync the accounting db on devare the same request. - Treat filler words such as
sync,refresh,db,database,creds,to postgres mcpas noise. - Services are Vault database roles, normally
NAME-service(for exampleaccounting-service,item-management-service). If the user gives a bare name such asaccounting, passaccounting-service. If the tool then reports the path was not found, callvault_listondatabase/rolesto find the matching role and retry once, or ask when several roles are plausible. - A full path such as
database/creds/accounting-serviceis accepted by the tool unchanged. - The resulting MCP environment is
ENV-NAMEwith the-servicesuffix removed, for exampledev-accountingorprod-item-management.
Response Rules
- Never call
vault_readondatabase/creds/...for this workflow, and never open or printenvironments.json: both would expose the credentials. The sync tool is the privacy boundary. - Never edit
environments.jsonyourself. If the tool reports the config file is missing or contains invalid JSON, relay the error and stop; the user must fix the PostgreSQL MCP config. - If creating a new environment fails because
host.db_serveris missing fromsecret/application, relay that blocker and stop. - Keep the confirmation brief and free of secret material. Example:
Synced dev-accounting (updated). Credentials expire in 1h.Mention the expiry only when the tool returnslease_duration. - When
actioniscreated, mention that a new PostgreSQL MCP environment was added and name it, so the user knows what to switch to. - Do not switch the PostgreSQL MCP environment or run queries unless the user separately asks.
Examples
- User request:
sync dev accounting dbAction: callvault_loginwithenvironment: dev, thenvault_sync_db_creds_to_postgres_mcpwithservice: accounting-service. ReplySynced dev-accounting (updated). - User request:
vault-sync-db sat accounting-service backend-payment-gateway-serviceAction: log intosatonce, then sync each service with its own tool call. Report both results. - User request:
refresh my data db credsAction: the environment is missing. Ask whether it isdev,sat,prod, orlocal; do not sync anything yet. - User request:
把 prod 的 item-management-service 同步到 postgres mcpAction: callvault_loginwithenvironment: prod, then syncitem-management-service. If the tool returnsaction: created, reply that the new environmentprod-item-managementwas added.