使用说明
postgres mcp服务器
这是一个PostgresSQL模型上下文协议服务器,用于让LLM与(本地)数据库交互。 警告:这仍然是实验性的,所以不要在真实的数据库上使用它,并且要小心写查询!
先决条件
- 有 nodeJS 安装
- 跑
npm install安装项目依赖项 - 设置以下环境变量:
DATABASE_NAME="your_database_name"
DATABASE_USER="your_database_user"
DATABASE_PASSWORD="your_database_password"
DATABASE_SCHEMA_name="your_database_schema_name" # i.e. standard this is usually `public`
在VSCODE settings.json中轻松配置:
{
"chat.mcp.discovery.enabled": true,
"mcp": {
"postgresql-database": {
"command": "npm",
"type": "stdio",
"args": ["start", "--prefix", "/path/to/code/postgres-mcp-server"],
"env": {
"CUSTOM_INSTRUCTIONS": "The databaseName is specific for the git branch we are on. It always has the same structure: jira_xxxxx, where the jira_xxxxx stands for the Jira ticket number. This Jira ticket number we always use at the start of a git branch. Hence, you should be able to take this from the current branch and create the databaseName from it",
"DATABASE_NAME": "my-database-name",
"DATABASE_USER": "my-user",
"DATABASE_PASSWORD": "my-password",
"DATABASE_SCHEMA_NAME": "public"
}
}
}
}