MCP Server PostgreSQL
A Model Context Protocol (MCP) server for PostgreSQL built with Spring Boot and Spring AI. This server provides read-only access to PostgreSQL databases through dynamic connections.
Power your agent
การติดตั้งจากผู้เผยแพร่ ไม่ใช่เอนด์พอยต์ของ PlugMCP
URL แบบรีโมตหรือคำสั่งบนเครื่องของคุณ? การติดตั้งสองแบบต่างกันอย่างไร
รันบน PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
เปิดจากผู้เผยแพร่
COMPLETED: The MCP server is fully functional with the following features:
list_schemas: List all schemas in a databaselist_tables: List all tables in a specific schemaselect: Select rows from a table with optional conditions and orderingexecute_query: Execute read-only SQL queriesClone and build the project:
git clone https://github.com/luanvuhlu/mcp-server-postgres.git
cd mcp-server-postgres
mvn clean compile
Start test PostgreSQL database:
docker-compose up -d
Run the MCP server:
mvn spring-boot:run
The MCP server will start and be ready to accept connections via the Model Context Protocol.
The Docker Compose setup includes a PostgreSQL instance with sample data:
Sample schemas and tables are automatically created:
public schema: users, productssales schema: orders, order_itemsinventory schema: stockThis server can be used with any MCP-compatible client. Here are some examples:
Add the following to your Claude Desktop configuration file:
{
"mcpServers": {
"postgres": {
"command": "java",
"args": ["-jar", "target/mcp-server-postgres-1.0.0-SNAPSHOT.jar"]
}
}
}
The server implements the standard MCP protocol and can be used with any compatible client by running:
java -jar target/mcp-server-postgres-1.0.0-SNAPSHOT.jar
List all schemas in a PostgreSQL database:
{
"name": "list_schemas",
"arguments": {
"host": "localhost",
"database": "postgres",
"username": "postgres",
"password": "your_name"
}
}
List all tables in a specific schema:
{
"name": "list_tables",
"arguments": {
"host": "localhost",
"database": "postgres",
"username": "postgres",
"password": "your_name",
"schema": "public"
}
}
Select rows from a table with optional conditions and ordering:
{
"name": "select",
"arguments": {
"host": "localhost",
"database": "postgres",
"username": "postgres",
"password": "your_name",
"table": "users",
"schema": "public",
"conditions": "id > 1",
"orderBy": "username ASC",
"limit": 10
}
}
Execute a read-only SQL query:
{
"name": "execute_query",
"arguments": {
"host": "localhost",
"database": "postgres",
"username": "postgres",
"password": "your_name",
"query": "SELECT * FROM users LIMIT 10"
}
}
Configure the MCP server in src/main/resources/application.yml:
spring:
ai:
mcp:
server:
enabled: true
port: 3000
All database connections are dynamic and provided per request. No default database connection is configured.
This server implements the Model Context Protocol (MCP) specification and communicates via JSON-RPC over stdio or TCP. The server registers the following tools that can be called by MCP-compatible clients.
src/main/java/com/luanvv/mcp/
├── McpServerPostgresApplication.java # Main application
├── config/
│ └── McpServerConfig.java # MCP configuration
├── model/
│ └── DatabaseConnection.java # Connection model
├── service/
│ └── PostgresService.java # Database operations
└── tools/
├── ListSchemaTool.java # List schemas tool
├── ListTablesTool.java # List tables tool
├── SelectTool.java # Select queries tool
└── ExecuteQueryTool.java # Execute query tool
# Compile
mvn clean compile
# Run tests
mvn test
# Package
mvn clean package
# Run
mvn spring-boot:run
Build and run with Docker:
# Build image
docker build -t mcp-server-postgres .
# Run container
docker run -p 3000:3000 mcp-server-postgres
This project is licensed under the MIT License.
For issues and questions, please use the GitHub issue tracker.
Model Context Protocol (MCP) Server for PostgreSQL with Spring Boot and Spring AI
เครื่องมือ
ยังไม่มีรายการเครื่องมือ เซิร์ฟเวอร์แบบรีโมตจะได้รายการหลังการตรวจสอบสถานะครั้งแรก
FAQ
คัดลอกคอนฟิก stdio สำหรับ Cursor, Claude Desktop, Claude Code หรือ VS Code ได้ในหน้านี้ คอนฟิกนี้ใช้การติดตั้งของผู้เผยแพร่ ไม่ใช่พร็อกซีของ PlugMCP
ระเบียนนี้ไม่ได้ระบุตัวแปรสภาพแวดล้อมที่จำเป็น
MCP Server Postgres ทำงานแบบโลคัลผ่าน stdio
ตรวจสอบล่าสุดเมื่อ 2026-10-28 Model Context Protocol (MCP) Server for PostgreSQL with Spring Boot and Spring AI