Logo di PostgreSQL 全访问 MCP 服务器

PostgreSQL 全访问 MCP 服务器

Community
syahiidkamil

Full access postgres mcp server

Autoresyahiidkamil
Repositorymcp-postgres-full-access
LinguaTypeScript
Fork
20
Stelle
25
Strumenti disponibili
0
Tipo di trasportostdio
Categorie
Link
  • Collega gli strumenti ai flussi di lavoro IA

    PostgreSQL 全访问 MCP 服务器 mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    25 stelle e 20 fork nel repository collegato.

PostgreSQL Full Access MCP Server

Model Context Protocol MIT License

A powerful Model Context Protocol server providing full read-write access to PostgreSQL databases. Unlike the read-only official MCP PostgreSQL server, this enhanced implementation allows Large Language Models (LLMs) to both query and modify database content with proper transaction management and safety controls.

Table of Contents

🌟 Features

Full Read-Write Access

  • Safely execute DML operations (INSERT, UPDATE, DELETE)
  • Create, alter, and manage database objects with DDL
  • Transaction management with explicit commit
  • Safety timeouts and automatic rollback protection

Rich Schema Information

  • Detailed column metadata (data types, descriptions, max length, nullability)
  • Primary key identification
  • Foreign key relationships
  • Index information with type and uniqueness flags
  • Table row count estimates
  • Table and column descriptions (when available)

Advanced Safety Controls

  • SQL query classification (DQL, DML, DDL, DCL, TCL)
  • Enforced read-only execution for safe queries
  • All operations run in isolated transactions
  • Automatic transaction timeout monitoring
  • Configurable safety limits
  • Two-step transaction commit process with explicit user confirmation

🔧 Tools

  • execute_query

    • Execute read-only SQL queries (SELECT statements)
    • Input: sql (string): The SQL query to execute
    • All queries are executed within a READ ONLY transaction
    • Results include execution time metrics and field information
  • execute_dml_ddl_dcl_tcl

    • Execute data modification operations (INSERT, UPDATE, DELETE) or schema changes (CREATE, ALTER, DROP)
    • Input: sql (string): The SQL statement to execute
    • Automatically wrapped in a transaction with configurable timeout
    • Returns a transaction ID for explicit commit
    • Important safety feature: The conversation will end after execution, allowing the user to review the results before deciding to commit or rollback
  • execute_maintenance

    • Execute maintenance commands like VACUUM, ANALYZE, or CREATE DATABASE outside of transactions
    • Input: sql (string): The SQL statement to execute - must be VACUUM, ANALYZE, or CREATE DATABASE
    • Returns a result object with execution time metrics
  • execute_commit

    • Explicitly commit a transaction by its ID
    • Input: transaction_id (string): ID of the transaction to commit
    • Safely handles cleanup after commit or rollback
    • Permanently applies changes to the database
  • execute_rollback

    • Explicitly rollback a transaction by its ID
    • Input: transaction_id (string): ID of the transaction to rollback
    • Safely discards all changes and cleans up resources
    • Useful when reviewing changes and deciding not to apply them
  • list_tables

    • Get a comprehensive list of all tables in the database
    • Includes column count and table descriptions
    • No input parameters required
  • describe_table

    • Get detailed information about a specific table structure
    • Input: table_name (string): Name of the table to describe
    • Returns complete schema information including primary keys, foreign keys, indexes, and column details

📊 Resources

The server provides enhanced schema information for database tables:

  • Table Schemas (postgres://<host>/<table>/schema)
    • Detailed JSON schema information for each table
    • Includes complete column metadata, primary keys, and constraints
    • Automatically discovered from database metadata

🚀 Using with Claude Desktop

Claude Desktop Integration

To use this server with Claude Desktop, follow these steps:

  1. First, ensure you have Node.js installed on your system

  2. Install the package using npx or add it to your project

  3. Configure Claude Desktop by editing claude_desktop_config.json (typically found at ~/Library/Application Support/Claude/ on macOS):

json
{
  "mcpServers": {
    "postgres-full": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-full-access",
        "postgresql://username:password@localhost:5432/database"
      ],
      "env": {
        "TRANSACTION_TIMEOUT_MS": "60000",
        "MAX_CONCURRENT_TRANSACTIONS": "5",
        "PG_STATEMENT_TIMEOUT_MS": "30000"
      }
    }
  }
}
  1. Replace the database connection string with your actual PostgreSQL connection details
  2. Restart Claude Desktop completely

Important: Using "Allow Once" for Safety

When Claude attempts to commit changes to your database, Claude Desktop will prompt you for approval:

Allow Once Dialog

Always review the SQL changes carefully before approving them!

Best practices for safety:

  • Always click "Allow once" (not "Always allow") for commit operations
  • Review the transaction SQL carefully before approving
  • Consider using a database user with limited permissions
  • Use a testing database if possible when first trying this server

This "Allow once" approach gives you full control to prevent unwanted changes to your database while still enabling Claude to help with data management tasks when needed.

⚙️ Environment Variables

You can customize the server behavior with environment variables in your Claude Desktop config:

json
"env": {
  "TRANSACTION_TIMEOUT_MS": "60000",
  "MAX_CONCURRENT_TRANSACTIONS": "5"
}

Key environment variables:

  • TRANSACTION_TIMEOUT_MS: Transaction timeout in milliseconds (default: 15000)

    • Increase this if your transactions need more time
    • Transactions exceeding this time will be automatically rolled back for safety
  • MAX_CONCURRENT_TRANSACTIONS: Maximum concurrent transactions (default: 10)

    • Lower this number for more conservative operation
    • Higher values allow more simultaneous write operations
  • ENABLE_TRANSACTION_MONITOR: Enable/disable transaction monitor ("true" or "false", default: "true")

    • Monitors and automatically rolls back abandoned transactions
    • Rarely needs to be disabled
  • PG_STATEMENT_TIMEOUT_MS: SQL query execution timeout in ms (default: 30000)

    • Limits how long any single SQL statement can run
    • Important safety feature to prevent runaway queries
  • PG_MAX_CONNECTIONS: Maximum PostgreSQL connections (default: 20)

    • Important to stay within your database's connection limits
  • MONITOR_INTERVAL_MS: How often to check for stuck transactions (default: 5000)

    • Usually doesn't need adjustment

🔄 Using Full Database Access with Claude

This server enables Claude to both read from and write to your PostgreSQL database with your approval. Here are some example conversation flows:

Example: Creating a New Table and Adding Data

You: "I need a new products table with columns for id, name, price, and inventory"

Claude: Analyzes your database and creates a query

sql
CREATE TABLE products (
    id SERIAL PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    price DECIMAL(10,2) NOT NULL,
    inventory INTEGER DEFAULT 0
);

Claude Desktop will prompt you to approve this operation

You: Review and click "Allow once"

Claude: "I've created the products table. Would you like me to add some sample data?"

You: "Yes, please add 5 sample products"

Claude: Creates INSERT statements and prompts for approval You review and approve with "Allow once"

Example: Data Analysis with Safe Queries

You: "What are my top 3 products by price?"

Claude: Executes a read-only query automatically Shows you the results

Safety Workflow

The key safety feature is the two-step approach for any operation that modifies your database:

  1. Claude analyzes your request and prepares SQL
  2. For read-only operations (SELECT), Claude executes automatically
  3. For write operations (INSERT, UPDATE, DELETE, CREATE, etc.):
    • Claude executes the SQL in a transaction and ends the conversation
    • You review the results
    • In a new conversation, you respond with "Yes" to commit or "No" to rollback
    • Claude Desktop shows you exactly what will be changed and asks for permission
    • You click "Allow once" to permit the specific operation
    • Claude executes the operation and returns results

This gives you multiple opportunities to verify changes before they're permanently applied to the database.

⚠️ Security Considerations

When connecting Claude to your database with write access:

Database User Permissions

IMPORTANT: Create a dedicated database user with appropriate permissions:

sql
-- Example of creating a restricted user (adjust as needed)
CREATE USER claude_user WITH PASSWORD 'secure_password';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO claude_user;
GRANT INSERT, UPDATE, DELETE ON TABLE table1, table2 TO claude_user;
-- Only grant specific permissions as needed

Best Practices for Safe Usage

  1. Always use "Allow once" to review each write operation

    • Never select "Always allow" for database modifications
    • Take time to review the SQL carefully
  2. Connect to a testing database when first exploring this tool

    • Consider using a database copy/backup for initial testing
  3. Limit database user permissions to only what's necessary

    • Avoid using a superuser or admin account
    • Grant table-specific permissions when possible
  4. Implement database backups before extensive use

  5. Never share sensitive data that shouldn't be exposed to LLMs

  6. Verify all SQL operations before approving them

    • Check table names
    • Verify column names and data
    • Confirm WHERE clauses are appropriate
    • Look for proper transaction handling

Docker

The server can be easily run in a Docker container:

bash
# Build the Docker image
docker build -t mcp-postgres-full-access .

# Run the container
docker run -i --rm mcp-postgres-full-access "postgresql://username:password@host:5432/database"

For Docker on macOS, use host.docker.internal to connect to the host network:

bash
docker run -i --rm mcp-postgres-full-access "postgresql://username:password@host.docker.internal:5432/database"

📄 License

This MCP server is licensed under the MIT License.

💡 Comparison with Official PostgreSQL MCP Server

FeatureThis ServerOfficial MCP PostgreSQL Server
Read Access✅✅
Write Access✅❌
Schema DetailsEnhancedBasic
Transaction SupportExplicit with timeoutsRead-only
Index Information✅❌
Foreign Key Details✅❌
Row Count Estimates✅❌
Table Descriptions✅❌

Author

Created by Syahiid Nur Kamil (@syahiidkamil)


Copyright © 2024 Syahiid Nur Kamil. All rights reserved.

Installazione

TypingMind
{
  "mcpServers": {
    "mcp-postgres-full-access": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-full-access",
        "{{config.POSTGRES_CONNECTION_STRING}}"
      ],
      "env": {
        "POSTGRES_CONNECTION_STRING": "<POSTGRES_CONNECTION_STRING>"
      }
    }
  }
}

Usa MCP PostgreSQL 全访问 MCP 服务器 con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso PostgreSQL 全访问 MCP 服务器, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi PostgreSQL 全访问 MCP 服务器 come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di PostgreSQL 全访问 MCP 服务器.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "mcp-postgres-full-access": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-full-access"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di PostgreSQL 全访问 MCP 服务器, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di PostgreSQL 全访问 MCP 服务器.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare PostgreSQL 全访问 MCP 服务器 per aiutarmi con questa attività?
PostgreSQL 全访问 MCP 服务器
Certo. Ho letto.
Ecco cosa ho trovato con PostgreSQL 全访问 MCP 服务器.

Domande frequenti

A cosa serve il server MCP PostgreSQL 全访问 MCP 服务器?

PostgreSQL 全访问 MCP 服务器 è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare PostgreSQL 全访问 MCP 服务器 MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare PostgreSQL 全访问 MCP 服务器 con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP PostgreSQL 全访问 MCP 服务器 con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando PostgreSQL 全访问 MCP 服务器, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego PostgreSQL 全访问 MCP 服务器 MCP a TypingMind?

PostgreSQL 全访问 MCP 服务器 funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre PostgreSQL 全访问 MCP 服务器 MCP in TypingMind?

PostgreSQL 全访问 MCP 服务器 mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare PostgreSQL 全访问 MCP 服务器 MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se PostgreSQL 全访问 MCP 服务器 richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇