MCP PostgreSQL Server
-
A Model Context Protocol (MCP) server that provides PostgreSQL database operations through MCP tools.
Features
- CRUD operations for User and Post entities
- Type-safe database operations using Prisma
- MCP-compatible tool interface
- Built with TypeScript for type safety
Installation
- Clone the repository
- Install dependencies:
git clone https://github.com/a21071/mcp-postgres.git
cd mcp-postgres
npm install
- Set up PostgreSQL database:
- Run database migrations:
- Build the project:
Usage
Run the server:
- getData: Retrieve user data from PostgreSQL
- addUserData: Add new user to database
{
"email": "user@example.com",
"name": "John Doe",
"age": 30
}
- deleteUserData: Delete user by ID, email or name
{
"id": "clxyz...",
"email": "user@example.com",
"name": "John Doe"
}
- updateUserData: Update user information
{
"id": "clxyz...",
"email": "new@example.com",
"name": "New Name"
}
Database Schema
The server uses the following Prisma schema:
model User {
id String @id @default(cuid())
email String @unique
name String?
age Int?
createdAt DateTime @default(now())
posts Post[]
}
Development
Dependencies
License
MIT