PostgreSQL
PostgreSQL
提供对 PostgreSQL 数据库的只读访问的模型上下文协议 (MLM) 服务器。该服务器使 LLM 能够检查数据库架构并执行只读查询。
成分
工具
询问
对连接的数据库执行只读 SQL 查询
输入:
sql(字符串):要执行的 SQL 查询所有查询都在只读事务中执行
资源
服务器为数据库中的每个表提供架构信息:
表模式(
postgres://<host>/<table>/schema)每个表的 JSON 架构信息
包括列名和数据类型
从数据库元数据中自动发现
Related MCP server: PostgreSQL Multi-Schema MCP Server
配置
与 Claude Desktop 一起使用
要将此服务器与 Claude Desktop 应用程序一起使用,请将以下配置添加到claude_desktop_config.json的“mcpServers”部分:
Docker
在 macos 上运行 docker 时,如果服务器在主机网络上运行(例如 localhost),请使用 host.docker.internal
可以将用户名/密码添加到 postgresql url,格式为
postgresql://user:password@host:port/db-name
{
"mcpServers": {
"postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"postgresql://host.docker.internal:5432/mydb"]
}
}
}NPX
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
}
}将/mydb替换为您的数据库名称。
与 VS Code 一起使用
为了快速安装,请使用下面的一键安装按钮之一...
如需手动安装,请将以下 JSON 块添加到 VS Code 中的“用户设置 (JSON)”文件中。您可以按下Ctrl + Shift + P并输入Preferences: Open User Settings (JSON)来执行此操作。
或者,您可以将其添加到工作区中名为.vscode/mcp.json的文件中。这样您就可以与其他人共享该配置。
请注意
.vscode/mcp.json文件中不需要mcp键。
Docker
注意:当使用 Docker 并连接到主机上的 PostgreSQL 服务器时,请在连接 URL 中使用host.docker.internal而不是localhost 。
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "pg_url",
"description": "PostgreSQL URL (e.g. postgresql://user:pass@host.docker.internal:5432/mydb)"
}
],
"servers": {
"postgres": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"mcp/postgres",
"${input:pg_url}"
]
}
}
}
}NPX
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "pg_url",
"description": "PostgreSQL URL (e.g. postgresql://user:pass@localhost:5432/mydb)"
}
],
"servers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"${input:pg_url}"
]
}
}
}
}建筑
Docker:
docker build -t mcp/postgres -f src/postgres/Dockerfile . 执照
此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.Last updated126,03627MIT
- Alicense-qualityDmaintenanceA Model Context Protocol server that provides read-only access to PostgreSQL databases with enhanced multi-schema support, allowing LLMs to inspect database schemas across multiple namespaces and execute read-only queries while maintaining schema isolation.Last updated1233MIT
- Alicense-qualityFmaintenanceA Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.Last updated41711MIT
- Alicense-qualityDmaintenanceA Model Context Protocol server that provides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only queries.Last updated126,036MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
MCP server for managing Prisma Postgres.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/modelcontextprotocol/postgresql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server