npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

workbuddy-postgres-connector

v1.0.0

Published

PostgreSQL connector MCP server for WorkBuddy: schema-aware natural language SQL queries with read-only protection

Readme

PostgreSQL 查询连接器(WorkBuddy 市场版)

连接用户的 PostgreSQL 数据库:自动感知表结构、主外键关系和注释,将自然语言转化为 SQL 并直接返回查询结果。默认只读防护,防止误删改数据。

目录结构

postgres-connector-market/
├── connector-meta.json   # 连接器元信息(auth_mode: token)
├── token-schema.json     # 授权表单(地址/端口/库名/账号/密码,密码为 password 类型)
├── mcp.json              # MCP Server 配置(npx 拉起,${VAR} 注入凭证,node 运行时托管)
├── icon.svg              # 市场图标
├── skills/
│   └── postgres-query-usage/
│       └── SKILL.md      # AI 使用说明(自然语言→SQL 工作流 + 安全规则)
└── server/               # MCP Server 源码(Node.js,需发布到 npm)
    ├── package.json      # 包名 workbuddy-postgres-connector
    └── index.js          # 4 个工具:test_connection / get_schema / describe_table / execute_sql

发布步骤

  1. 发布 npm 包(mcp.json 通过 npx 拉起):
    cd server
    npm login          # 需 npm 账号;如无请到 npmjs.com 注册
    npm publish        # 包名若被占用,改 package.json 和 mcp.json 中的名称
  2. 本地验证:
    PG_HOST=127.0.0.1 PG_PORT=5432 PG_DATABASE=test PG_USER=postgres PG_PASSWORD=xxx node index.js
    # 另一终端发送 MCP initialize 请求验证握手
  3. 提交开放平台:
    • 注册并认证 open.workbuddy.cn(个人认证即可发布连接器)
    • 后台创建「连接器」,上传本目录打包的 zip(connector-meta.json 需在 zip 根层)
    • 测试环境调试 → 提交审核 → 通过后上架市场

授权模式说明(auth_mode: token)

用户在市场点击「连接」时,WorkBuddy 自动弹出 token-schema.json 描述的表单,收集 PG_HOST / PG_PORT / PG_DATABASE / PG_USER / PG_PASSWORD。凭证:

  • 仅保存在用户本机 ~/.workbuddy 目录,不经过云端、不打开浏览器;
  • 连接时通过环境变量注入 MCP Server,${VAR} 占位符与表单 key 一一对应;
  • 密码字段使用 password 类型,满足审核安全红线(对话与日志中不出现明文密码)。

安全设计

  • execute_sql 默认只读:仅放行 SELECT / WITH / EXPLAIN / SHOW / VALUES / TABLE, 拦截多语句执行与注释绕过;写操作需显式 allow_write=true;
  • SKILL.md 要求 AI 在写操作前必须获得用户确认;
  • 单次查询默认最多返回 100 行(可调,上限 1000),statement_timeout 30 秒。

版本要求

  • auth_mode: token 需 WorkBuddy ≥ 4.23.0
  • mcp.json 的 runtime 字段需 ≥ 5.0.0
  • 因此 minWorkbuddyVersion 声明为 5.0.0