[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"pack-detail-postgres-for-agents-zh":3,"seo:pack:postgres-for-agents:zh":59},{"code":4,"message":5,"data":6},200,"操作成功",{"pack":7},{"slug":8,"icon":9,"tone":10,"status":11,"status_label":12,"title":13,"description":14,"items":15,"install_cmd":58},"postgres-for-agents","🐘","#3730A3","stable","稳定","Postgres for Agent","PostgreSQL MCP（两个口味）\u002F DBHub 通用数据库 MCP \u002F Neon serverless Postgres \u002F Supabase MCP — agent 要的 SQL 接口全这了。",[16,28,35,43,50],{"id":17,"uuid":18,"slug":19,"title":20,"description":21,"author_name":22,"view_count":23,"vote_count":24,"lang_type":25,"type":26,"type_label":27},154,"1ca69a22-de42-4722-af49-3d0869362e2d","postgresql-mcp-server-database-queries-ai-1ca69a22","PostgreSQL MCP Server — Database Queries for AI","MCP server for PostgreSQL database access. Run read-only SQL queries, inspect schemas, list tables, and analyze data directly from Claude Code or Cursor.","MCP Hub",290,0,"en","mcp","MCP",{"id":29,"uuid":30,"slug":31,"title":32,"description":33,"author_name":22,"view_count":34,"vote_count":24,"lang_type":25,"type":26,"type_label":27},660,"faa28c56-1377-4109-9e8f-a9b2be119d16","postgresql-mcp-sql-database-server-ai-agents-faa28c56","PostgreSQL MCP — SQL Database Server for AI Agents","MCP server that gives AI agents direct access to PostgreSQL databases. Run queries, explore schemas, manage tables, and analyze data through natural language. 3,000+ stars.",308,{"id":36,"uuid":37,"slug":38,"title":39,"description":40,"author_name":41,"view_count":42,"vote_count":24,"lang_type":25,"type":26,"type_label":27},522,"943f4349-7127-400b-9cd3-bbb8f67982a3","dbhub-universal-database-mcp-server-zero-dependencies-943f4349","DBHub — Universal Database MCP Server, Zero Dependencies","Token-efficient database MCP server supporting Postgres, MySQL, MariaDB, SQL Server, and SQLite. Just two MCP tools, zero dependencies, read-only safe.","TokRepo精选",316,{"id":44,"uuid":45,"slug":46,"title":47,"description":48,"author_name":22,"view_count":49,"vote_count":24,"lang_type":25,"type":26,"type_label":27},685,"a561d526-fcb0-474b-a566-82b45e889f68","neon-serverless-postgres-database-branching-a561d526","Neon — Serverless Postgres with Database Branching","Serverless PostgreSQL with instant database branching, autoscaling, and a generous free tier. Branch your database like git branches — test schema changes without touching production. 16,000+ stars.",341,{"id":51,"uuid":52,"slug":53,"title":54,"description":55,"author_name":56,"view_count":57,"vote_count":24,"lang_type":25,"type":26,"type_label":27},641,"b141b1a9-a134-4be5-9708-93d48ccc7ff4","supabase-mcp-postgres-auth-server-ai-agents-b141b1a9","Supabase MCP — Postgres + Auth Server for AI Agents","MCP server for Supabase that gives AI agents access to PostgreSQL databases, authentication, storage, and edge functions. Query data, manage users, and build full-stack features. 4,000+ stars.","Supabase",313,"tokrepo install pack\u002Fpostgres-for-agents",{"pageType":60,"pageKey":8,"locale":61,"title":62,"metaDescription":63,"h1":13,"tldr":64,"bodyMarkdown":65,"faq":66,"schema":82,"internalLinks":92,"citations":105,"wordCount":118,"generatedAt":119},"pack","zh","Postgres for Agent：5 个 MCP 服务器 + 云原生 Postgres","PostgreSQL MCP（两个口味）\u002F DBHub 通用数据库 MCP \u002F Neon serverless \u002F Supabase MCP — Claude 或 Cursor agent 需要的 SQL 接口全这了，TokRepo CLI 一条命令装齐。","把 SQL 数据库接给 agent 的五种实战方案 —— 两个 stdio MCP 服务器、一个多 DB 通用路由、两个云端托管 Postgres。TokRepo 一条命令装齐。","## 这个 pack 装了什么\n\n这个包收齐了 **agent 真要读写 Postgres 的五种 SQL 接口**。两个 stdio MCP 服务器，指向自己的 DSN。一个通用 MCP，能同时管 Postgres \u002F MySQL \u002F SQLite \u002F DuckDB。最后两个是云端托管 Postgres，自带 agent 集成。\n\n| # | 资产 | 类型 | 适合场景 |\n|---|---|---|---|\n| 1 | PostgreSQL MCP（官方参考） | stdio MCP | 本地\u002F自建 Postgres |\n| 2 | PostgreSQL MCP（社区版） | stdio MCP | 多了 explain \u002F 索引建议 |\n| 3 | DBHub | 通用 MCP | 一个服务多种 DB |\n| 4 | Neon serverless | 云端 + MCP | 给 agent 任务做分支 |\n| 5 | Supabase MCP | 云端 + MCP | 全套 BaaS（auth\u002F存储\u002FRLS） |\n\n参考版 PostgreSQL MCP 在官方 `modelcontextprotocol\u002Fservers` 仓库里，最简单的 stdio 绑定：`query` \u002F `list_tables` \u002F `describe_table`。社区版加了 `explain` \u002F `index_advice` 和带参写入。DBHub 把连接层抽象掉，一个 MCP 装好可以同时打 Postgres \u002F MySQL \u002F SQLite \u002F DuckDB。Neon 和 Supabase 各自带 MCP，超越纯 SQL —— Neon 把分支创建做成工具（一个 agent 任务一个数据库），Supabase 把 auth \u002F 存储 \u002F 行级权限全暴露。\n\n## 为什么 agent 配 Postgres 这么重要\n\n大多数「agent + 数据库」演示都在作弊：临时 SQLite、手写 fixture、零并发。真实应用跑在 Postgres 上，几百张表 + RLS 策略 + JSON 列 + 已有连接池。把 LLM 直接接进去就是 DELETE 不带 WHERE 的事故现场。\n\n这五个服务器把现实层面都处理了：\n- **默认只读**，五个都带 read-only 开关或能力作用域\n- **schema 内省**，agent 可以问 describe_table，不用猜列名\n- **连接池**，每个服务器都重用 pool，避免每查询重连\n- **分支\u002F沙箱**，Neon 分支工具让每个 agent 任务获得自己的临时库（200ms 出生）\n\n## 一条命令装齐\n\n```bash\n# 装整个 pack，把 MCP 配置写进对应工具的 config\ntokrepo install pack\u002Fpostgres-for-agents\n\n# 或单独装\ntokrepo install postgres-mcp\ntokrepo install dbhub\ntokrepo install neon-mcp\ntokrepo install supabase-mcp\n```\n\nTokRepo CLI 会把配置写到每个工具该去的位置 —— Claude Code 写 `claude_desktop_config.json`，Cursor 写 `mcp.json`，Codex CLI 写 AGENTS.md。连接串放环境变量，配置只带服务器名。\n\n## 几个常见坑\n\n- **第一天别开写权限**，先 `--read-only`，看 agent 安全跑几百次读再放写\n- **用专用 role，不要用 postgres 超级用户**，建个 `mcp_agent` role，只给真要暴露的 schema 上 SELECT；RLS 也要对它生效\n- **schema dump 成本要看着**，500 张表 list_tables 一发把 agent context 撑爆 — 限定单 schema 或允许列表\n- **分支要真用才起作用**，Neon 分支很便宜 —— 每个 agent 任务起一个，把 MCP 指向分支 DSN，用完丢\n- **Supabase RLS 不是可选项**，service role key 会绕过 RLS。涉及用户数据的任务用 anon + JWT\n\n## 与其他 pack 的关系\n\n这个 pack 是**结构化数据**层。语义 \u002F 非结构化检索（相似度搜、文档 RAG）用 [向量数据库横评](\u002Fzh\u002Fpacks\u002Fvector-db-showdown) pack —— Chroma \u002F Qdrant \u002F Weaviate \u002F Pinecone。更广义的 MCP 工具（文件系统 \u002F 浏览器 \u002F GitHub）见 [MCP 服务器全家桶](\u002Fzh\u002Fpacks\u002Fmcp-server-stack)。线上 agent 通常每个 pack 各取一个：Postgres 装事务态，向量库装 embedding，MCP 栈装工具面。",[67,70,73,76,79],{"q":68,"a":69},"官方 PostgreSQL MCP 服务器是免费的吗？","是的 —— MIT 开源，放在官方 modelcontextprotocol\u002Fservers 仓库里，除了你自己数据库的额度没有任何限制。你只为数据库本身付钱（Neon 和 Supabase 免费额度都很慷慨；自建 Postgres 完全免费）。MCP 层零成本零遥测。",{"q":71,"a":72},"DBHub 跟开多个 PostgreSQL MCP 实例比怎么样？","DBHub 是一个 MCP 进程前置多个 DSN —— Postgres \u002F MySQL \u002F SQLite \u002F DuckDB。如果 agent 要打三个库，DBHub 一个 slot 三个命名连接搞定。开多个 PostgreSQL MCP 也行，但每个吃一个 MCP 槽，schema 缓存也不共享。多 DB 工作流用 DBHub，单 DB 精细控制用原生 PostgreSQL MCP。",{"q":74,"a":75},"Claude Code 或 Cursor 都能用吗？","两个都能，再加 Codex CLI \u002F Gemini CLI \u002F Cline \u002F Roo Code \u002F Windsurf \u002F Copilot。MCP 是标准，TokRepo CLI 只是把对应配置写进每个工具该去的位置。Neon 和 Supabase MCP 用法一样；Neon 还出了 Cursor 扩展自动做 branch-per-task。",{"q":77,"a":78},"这个 pack 跟向量数据库横评的区别？","Postgres 装结构化行 —— 订单 \u002F 用户 \u002F 用 SELECT WHERE 查的那种数据。向量库装 embedding 相似度 —— 「找出语义近似 X 的文档」。两者互补。真实 RAG 应用两个都跑：Postgres 装事实，Qdrant 或 Chroma 装语义召回，靠 metadata 里的外键串起来。",{"q":80,"a":81},"Supabase service role key 的坑是什么？","service role key 会绕过行级权限。如果你把 MCP 接到这个 key，agent 能读到所有用户数据 —— 不止当前用户的。涉及用户数据的任务永远用 anon key + 每会话 JWT，service role 留给后台管理任务，前面再放一道人工审批关。",{"@context":83,"@type":84,"name":85,"description":86,"numberOfItems":87,"publisher":88},"https:\u002F\u002Fschema.org","CollectionPage","Postgres for AI Agents","PostgreSQL MCP servers, DBHub, Neon and Supabase — every SQL surface an agent needs.",5,{"@type":89,"name":90,"url":91},"Organization","TokRepo","https:\u002F\u002Ftokrepo.com",[93,97,101],{"url":94,"anchor":95,"reason":96},"\u002Fzh\u002Fpacks\u002Fmcp-server-stack","MCP 服务器全家桶","这些服务器所属的更大 MCP 工具盒",{"url":98,"anchor":99,"reason":100},"\u002Fzh\u002Fpacks\u002Fvector-db-showdown","向量数据库横评","SQL 数据的 embedding 侧伙伴",{"url":102,"anchor":103,"reason":104},"\u002Fzh\u002Fpacks\u002Fheadless-cms-for-ai","AI 友好 Headless CMS","默认开 REST + GraphQL 的内容后端",[106,110,114],{"claim":107,"source_name":108,"source_url":109},"Official PostgreSQL MCP Server reference","modelcontextprotocol\u002Fservers","https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fservers\u002Ftree\u002Fmain\u002Fsrc\u002Fpostgres",{"claim":111,"source_name":112,"source_url":113},"Supabase MCP server documentation","supabase\u002Fmcp-server-supabase","https:\u002F\u002Fgithub.com\u002Fsupabase-community\u002Fsupabase-mcp",{"claim":115,"source_name":116,"source_url":117},"Neon serverless Postgres branching","Neon docs","https:\u002F\u002Fneon.tech\u002Fdocs\u002Fintroduction\u002Fbranching",467,"2026-05-02T15:00:00Z"]