PostgreSQL MCP Server
PostgreSQL MCP 서버
PostgreSQL을 위한 범용 모델 컨텍스트 프로토콜(MCP) 서버로, AI 에이전트가 PostgreSQL 데이터베이스를 안전하게 검사하고 쿼리할 수 있게 합니다.
기능
list_tables:public스키마의 모든 테이블을 나열합니다.get_schema: 특정 테이블의 스키마(열, 유형, null 허용 여부)를 가져옵니다.run_query: 읽기 전용 SQL 쿼리(SELECT/WITH만 허용)를 실행하며, 대규모 응답을 방지하기 위해 최대 100행으로 제한합니다.
Related MCP server: PostgreSQL MCP Server
사전 요구 사항
Python 3.13+
PostgreSQL 데이터베이스
설치
저장소를 복제한 경우 uvx 또는 uv run을 사용하여 직접 실행할 수 있습니다.
사용법
이 서버는 DATABASE_URL 환경 변수가 설정되어 있어야 합니다.
연결 문자열 예시:
postgres://user:password@localhost:5432/mydatabase
직접 실행
DATABASE_URL="postgresql://postgres:poggerpogger@localhost:5432/boxboxWeb" uv run main.pyClaude Desktop / MCP 클라이언트와 함께 사용
MCP 클라이언트 구성(예: Claude Desktop의 claude_desktop_config.json)에 다음을 추가하세요:
{
"mcpServers": {
"postgres": {
"command": "uv",
"args": [
"run",
"/path/to/2025postgresqlmcp/main.py"
],
"env": {
"DATABASE_URL": "postgres://user:password@localhost:5432/mydatabase"
}
}
}
}Available Tools
3 toolsget_schemaA
Get the schema (columns, types) of a specific table
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes | Name of the table |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must convey behavioral traits. It describes a read operation ('Get') but lacks details such as whether any side effects occur, authentication requirements, or rate limits. The description is adequate for a simple metadata retrieval but could be more explicit.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence that directly states the purpose. It is concise and efficient, though it could briefly mention the output to improve completeness without adding much length.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the low complexity (one parameter, no output schema), the description covers the core functionality. It does not explain the return format, but the tool name and description imply a schema structure. For simple tools, this level of detail is sufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides 100% coverage with a clear description for table_name ('Name of the table'). The tool description does not add additional meaning beyond what the schema already conveys, so baseline score applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Get') and the resource ('schema of a specific table'), making the purpose instantly understandable. It distinguishes itself from sibling tools: list_tables lists tables, run_query executes queries.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage when needing column names and types for a known table, but it does not provide explicit guidance on when to use this tool versus alternatives (e.g., run_query for more complex queries).
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesB
List all tables in the current database schema
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It states the basic action but fails to disclose important behaviors such as whether system tables are included, required permissions, or response format. The minimal description limits transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence that conveys the core action efficiently. It is front-loaded with the verb and resource, containing no unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (no parameters, no output schema), the description is adequate to understand what it does. However, it lacks information about the output format or any constraints, making it partially complete for effective agent use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and schema description coverage is 100%. The description adds minimal context ('current database schema'), which provides scope but does not significantly enhance parameter meaning. Baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action (List) and the resource (tables) with a specific scope ('current database schema'). It differentiates well from siblings: get_schema likely retrieves schema structure, run_query executes queries, while list_tables is focused solely on listing table names.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like get_schema or run_query. The description does not mention context, prerequisites, or exclusions, leaving the agent to infer usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
run_queryA
Run a read-only SQL query against the database. ONLY SELECT queries are allowed for safety.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The read-only SQL query to execute |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description discloses the key read-only behavior. However, it lacks details on error handling, result format, or performance impacts, making it adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two concise sentences, front-loaded with the core action, with no redundant information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simplicity of the tool (single parameter, no output schema), the description is minimally complete. It could mention that it returns query results, but the lack is not critical.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and the description reinforces the parameter's safety (read-only, SELECT-only). No additional meaning beyond the schema is provided, so baseline score applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool runs a read-only SQL query, specifying 'SELECT queries only' which distinguishes it from sibling tools like get_schema and list_tables.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It explicitly restricts usage to SELECT queries for safety, providing a clear when-to-use guideline. It could mention alternatives for non-SELECT queries, but the constraint is sufficient.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.0- First observed
get_schema - First observed
list_tables - First observed
run_query
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: listing tables, retrieving table schema, and running arbitrary SQL queries. No overlap or ambiguity exists.
All tool names follow a consistent verb_noun pattern (list_tables, get_schema, run_query), making them predictable and easy to understand.
Three tools is on the lower end of the ideal range, but they cover the essential operations for a read-only database server. Slightly more tools (e.g., listing views) would improve scope without bloat.
The tool set provides core capabilities for exploring and querying a database, but lacks support for listing views, functions, or other database objects. This is acceptable for a focused MCP server.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to safely interact with PostgreSQL databases through read-only operations, providing schema discovery, table inspection, and query execution capabilities with structured context awareness.MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.8 npm1-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to safely interact with PostgreSQL databases, perform queries, inspect schemas, and analyze query performance.2-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query and explore PostgreSQL databases with tools for executing SQL queries, listing tables, and describing table structures.MIT