MCP-Server-postgres logo

MCP-Server-postgres

by CodeNexus-ai

The MCP PostgreSQL Server provides an API to interact with a PostgreSQL database. It offers functionalities to list tables, retrieve table information, execute queries, and manage database connections.

View on GitHub

Last updated: N/A

What is MCP-Server-postgres?

The MCP PostgreSQL Server is a tool that exposes database functionalities through an API. It allows users to interact with a PostgreSQL database by listing tables, retrieving table information, executing custom queries, and managing database connections.

How to use MCP-Server-postgres?

To use the server, you can leverage the exposed API endpoints. Each endpoint requires specific arguments, such as the table name for retrieving table information or a SQL query for execution. The server provides tools for listing tables, getting table info, querying tables, and executing custom queries.

Key features of MCP-Server-postgres

  • Database connection management

  • Table listing

  • Table information retrieval

  • Data querying

  • Custom SQL execution

Use cases of MCP-Server-postgres

  • Database administration

  • Data exploration

  • Automated data retrieval

  • SQL query execution

  • Integration with MCP tools

FAQ from MCP-Server-postgres

How do I connect to the database?

The DatabaseConnection class manages the connection. It uses default values for host, database, user, and password, but these can be customized during instantiation.

How do I list all tables in the database?

Use the list_tables_tool API endpoint. It returns a formatted string with the names of all tables.

How do I get detailed information about a specific table?

Use the get_table_info_tool API endpoint, providing the table name as an argument. It returns column details, primary keys, and row count.

How do I query data from a table?

Use the query_table_tool API endpoint, providing the table name as an argument. You can optionally specify a limit for the number of rows returned.

How do I execute a custom SQL query?

Use the execute_query_tool API endpoint, providing the SQL query as an argument. You can also provide optional parameters for the query.