Reference Servers · MODEL CONTEXT PROTOCOL

a21071 mcp postgres

MCP example for postgres

连接能力

a21071 mcp postgres 为 AI Agent 提供什么

  • CRUD operations for User and Post entities
  • Type-safe database operations using Prisma
  • MCP-compatible tool interface
  • Built with TypeScript for type safety
  • Clone the repository
  • Install dependencies:
  • Set up PostgreSQL database:
  • Run database migrations:
  • Build the project:
  • **getData**: Retrieve user data from PostgreSQL
  • **addUserData**: Add new user to database
  • **deleteUserData**: Delete user by ID, email or name
  • **updateUserData**: Update user information
  • Watch mode:
  • [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk) - MCP server SDK
  • [Prisma](https://www.prisma.io/) - Type-safe database client
  • [TypeScript](https://www.typescriptlang.org/) - Type checking

安全

MCP 收录不等于安全审核

MCP 服务器可能获得模型上下文、凭据、本地文件或调用外部系统的权限。连接 Agent 前,请检查代码、环境变量、网络行为、软件包来源与维护状态。

README

仓库文档

MCP PostgreSQL Server

-MCP Postgres Logo

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

  1. Clone the repository
  2. Install dependencies:
git clone https://github.com/a21071/mcp-postgres.git
cd mcp-postgres
npm install
  1. Set up PostgreSQL database:
docker-compose up -d
  1. Run database migrations:
npx prisma migrate dev
  1. Build the project:
npm run build

Usage

Run the server:

npm start

Available MCP Tools

  • getData: Retrieve user data from PostgreSQL

    {
      "tableName": "user"
    }
  • 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

  • Watch mode:
npm run watch

Dependencies

License

MIT

在 GitHub 查看 README

社区

收藏、评分与讨论

正在载入社区数据…