加载中…
✦
✧
✦
✦
✧
✦

confluence-buddy

面向人和 AI agent 的只读 Confluence Data Center / Server CLI。它直接与 Confluence REST API 通信——不需要 MCP 网关或常驻服务。

命令集对标 atlassian-confluence-mcp-server 的五个只读工具,并补上上游缺少的附件下载能力:

cfb 命令对应的 MCP 工具
page <id|url>confluence_get_page_by_url
body <pageId>confluence_get_page_body_chunk
attachments <pageId>confluence_get_page_attachments
comments <pageId>confluence_get_page_comments
comment-attachments <id>confluence_get_comment_attachments
download <attachmentId>confluence_download_attachment(本地注入)
search <cql>confluence_search

安装

npm install
npm run build
npm link # 可选:把 cfb 放进 PATH

配置

一个 Confluence 实例,一份扁平配置。创建 cfb.config.json(参见 cfb.config.example.json):

{
"baseUrl": "http://confluence.example.com:8090",
"username": "your.name",
"passwordEnv": "CFB_PASSWORD",
"allowInsecureHttp": true,
"spaces": ["DEV", "DOCS"]
}

  • spaces 是白名单。省略则允许所有空间。白名单受限且命令无法判断内容所属空间时,直接失败退出(exit 3)。
  • base URL 是 http:// 时,allowInsecureHttp 必须为 true(凭据会明文传输)。
  • 认证:username + password / passwordEnv,或 pat / patEnv。Server/DC PAT 用 Bearer;Cloud API token(*.atlassian.net)用 Basic email:token。
  • 配置发现顺序:--config > $CFB_CONFIG > ./cfb.config.json > %APPDATA%\cfb\config.json / ~/.config/cfb/config.json。参数和环境变量是必需的——如果设置了 CFB_BASE_URL 和凭据,配置文件本身可省略。

环境变量覆盖:CFB_BASE_URL、CFB_USERNAME、CFB_PASSWORD、CFB_PAT、CFB_ALLOW_INSECURE_HTTP、CFB_IS_CLOUD、CFB_ALLOWED_SPACES(* 或逗号分隔)、CFB_TIMEOUT_MS、CFB_FORMAT、CFB_DOWNLOAD_DIR、CFB_MAX_ATTACHMENT_BYTES、CFB_AUDIT_LOG。

用法

cfb doctor

cfb page 123456
cfb page "http://confluence.example.com/display/DEV/Release+Notes" --body

cfb body 123456 --offset 0 --length 20000
cfb attachments 123456
cfb comments 123456
cfb comment-attachments 789012

cfb download att123456
cfb download att123456 --out ./downloads --force

cfb search 'type=page AND space=DEV' --limit 10
cfb search --text "deployment checklist" --space DEV

输出格式:auto|table|json|csv|tsv(auto = TTY 输出表格,管道输出 JSON)。body 在表格模式下打印原始文本块;需要偏移量/元信息时用 --format json。

退出码:0 成功,1 HTTP/网络错误,2 用法/配置错误,3 被空间白名单拦截,4 超时,130 中断。

注意事项

  • 只读:没有创建/更新/删除命令。
  • 密钥永不打印。
  • 页面 URL 支持数字 id、?pageId=ID、/spaces/SPACE/pages/ID/、/display/SPACE/Title 和 /x/ID 短链。
  • 列表命令最多返回 100 行。结果更多时会打印警告;缩小查询范围查看其余结果。
  • 下载受 download.maxBytes(默认 50 MB)限制,写入 download.dir(默认配置文件旁的 ./downloads)。