はじめに
CursorとMCPサーバを連携し、PostgreSQLを操作する。
動かし方
下記リポジトリをcloneしてきます。
src/postgres
で下記コマンドを実行する
npx @modelcontextprotocol/server-postgres
postgresql://user:password@host:port/db-name
Cursor側の設定
mcp.jsonの内容修正します。
mcp.json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@host:port/db-name"
]
}
}
}