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.
Potencialize seu agente
Instalação do publicador. Não é um endpoint do PlugMCP.
Host a copy with our keys and logs.
Ainda não há uma versão empacotada no registro. Siga o README do repositório.
URL remota ou um comando na sua máquina? Como as duas instalações diferem
Rodar no 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.
AbrirDo publicador
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
Ferramentas
Ainda não há lista de ferramentas. Servidores remotos recebem uma após a primeira verificação de saúde.
Perguntas frequentes
Copie nesta página a configuração stdio para Cursor, Claude Desktop, Claude Code ou VS Code. Ela usa a instalação do publicador, não um proxy do PlugMCP.
Este registro não lista nenhuma variável de ambiente obrigatória.
MCP Server Postgres roda localmente via stdio.
Última verificação: 2026-10-28. Model Context Protocol (MCP) Server for PostgreSQL with Spring Boot and Spring AI