Skip to main content
Glama

CNB Remote MCP

中文 · English · MIT

在 ChatGPT 网页中,通过自己的 MCP 插件操作 CNB.cool。

一个非官方、自托管的 CNB 远程 MCP 服务器:查询仓库、阅读代码、管理 Issue / PR、检查构建日志、提交文件,以及调度 CNB NPC。支持 Streamable HTTP 和 STDIO;工具受你的 CNB 令牌权限约束。

选择源码镜像

地区

仓库

中国大陆,优先 CNB

cnb.cool/htazq/cnb-remote-mcp

其他地区,优先 GitHub

github.com/htazq/cnb-remote-mcp

两处发布相同版本的源代码,提交历史按平台独立维护。这里的“镜像”指源码仓库;教程从源码构建 Docker 镜像,不依赖未发布的预构建镜像。网络可达性取决于你的环境;源码镜像选择不会改变 ChatGPT 的账号或地区可用性。

Related MCP server: forgejo-mcp

从部署到 ChatGPT

ChatGPT 网页 / 自定义 MCP 插件
        │ HTTPS + OAuth
Cloudflare Tunnel
        │ 私有网络中的 HTTP
CNB Remote MCP(Northflank / 自有 Docker / 其他容器平台)
        │ 你的 CNB PAT
CNB OpenAPI / Git

完整部署教程(中文) · Step-by-step guide (English)

教程按顺序覆盖:创建 CNB 令牌 → 选择源码 → 新建 Northflank 容器服务(或使用自有平台)→ 配置 Cloudflare Tunnel → 连接 ChatGPT → 验证读写。Northflank 只是示例,不是必需依赖;不需要为本项目申请 OpenAI API key。

本地快速体验

需要 Docker Engine / Docker Desktop 和 Compose v2。在终端执行,任选一个源码地址:

git clone https://cnb.cool/htazq/cnb-remote-mcp.git
# 或:git clone https://github.com/htazq/cnb-remote-mcp.git
cd cnb-remote-mcp
cp .env.example .env

编辑 .env,填写 CNB_TOKEN,并将 openssl rand -hex 32 生成的独立密钥填入 MCP_ACCESS_TOKENS。保留默认只读模式。PowerShell 可以使用 Copy-Item .env.example .env。

docker compose up -d --build
curl http://127.0.0.1:3000/healthz

返回 status: ok 后,本地支持自定义 Header 的 MCP 客户端可连接:

{
  "mcpServers": {
    "cnb": {
      "url": "http://127.0.0.1:3000/mcp",
      "headers": { "Authorization": "Bearer REPLACE_WITH_YOUR_MCP_ACCESS_KEY" }
    }
  }
}

ChatGPT 网页使用教程中的 HTTPS + OAuth 流程;不要把本地 Header 配置直接照搬到 ChatGPT。

能力与权限

分组

能力

账号与仓库

当前账号、仓库搜索与创建、分支、标签、文件、提交、差异

Issue / PR

查询、创建、更新、评论、评审、合并

构建

历史、实时状态、阶段日志、触发与取消

NPC

角色搜索、任务调度、状态与动作记录

代码

在隔离 Git 工作区内提交与推送文件

默认只暴露读工具;设置 MCP_WRITE_MODE=write 后启用写工具。合并 PR、删除分支、推送默认分支还需工具调用中的 confirm: true。构建/NPC 触发返回“已受理”后,需继续查询状态才能确认完成。实际工具列表来自 tools/list,完整范围见 能力矩阵。

配置与边界

配置

用途

CNB_TOKEN

服务端调用 CNB 的 PAT,仅放在服务器

MCP_ACCESS_TOKENS

客户端 Bearer 密钥;OAuth 授权页用它验证服务器所有者

MCP_PUBLIC_BASE_URL

公网 HTTPS 源站地址,例如 https://mcp.example.com

MCP_OAUTH_CLIENT_ID / MCP_OAUTH_CLIENT_SECRET

ChatGPT 预配置 OAuth 客户端;留空则关闭 OAuth

MCP_OAUTH_REDIRECT_URIS

ChatGPT 管理页显示的精确 HTTPS 回调地址,多个用逗号分隔

MCP_WRITE_MODE

默认 read-only;写操作需显式设为 write

所有变量见 .env.example。compose.yaml 用于本地部署;compose.cloudflare.yaml 添加 Cloudflare Tunnel。

这是单个 CNB 账号的自托管网关,所有授权客户端共享该账号权限,不是多用户 CNB 登录服务。OAuth 授权信息仅保存在内存中,使用一个副本;重启后需在 ChatGPT 重新连接。无需数据库或持久卷;审计记录会写 stdout 和本地轮转文件,需长期保留时使用平台日志系统。日志可能包含仓库路径、文件路径与提交内容等操作数据,分享前请检查。

开发与贡献

Node.js >= 22.12:

npm ci
npm run typecheck
npm run lint
npm test
npm run build

本项目以 MIT 发布,与 CNB、OpenAI、Northflank、Cloudflare 无隶属或背书关系。各平台名称和商标归其所有者所有。

Available Tools

29 tools
build_listList build historyC
Read-onlyIdempotent

List CI build history of a repository with filters.

Inputs: repo (required), sha, page, event, +6 more.

build_stage_logsGet build stage logsA
Read-onlyIdempotent

Get the log of one pipeline stage. Find pipelineId/stageId via build_status first. Log output is truncated to keep responses small.

Inputs: sn (required), repo (required), stage_id (required), pipeline_id (required), +1 more.

build_statusGet build statusA
Read-onlyIdempotent

Get the overall status and per-pipeline status of one build (by SN, e.g. cnb-xxx). SN values come from build_list / build_trigger / npc_dispatch.

Inputs: sn (required), repo (required).

issue_comment_listList issue commentsC
Read-onlyIdempotent

List comments of an issue.

Inputs: repo (required), number (required), page, page_size.

issue_getGet an issueC
Read-onlyIdempotent

Get one issue by number.

Inputs: repo (required), number (required).

issue_listList issuesC
Read-onlyIdempotent

List issues of a repository with optional filters.

Inputs: repo (required), page, state, author, +3 more.

npc_actionsList NPC activityB
Read-onlyIdempotent

List recorded NPC actions (calls, pushes, PRs) in a repository.

Inputs: repo (required), page, event, npc_name, +2 more.

npc_statusGet NPC task statusA
Read-onlyIdempotent

Get the real status of a dispatched NPC task (build). Returns overall status, per-pipeline status and the NPC that triggered it. Use build_stage_logs for detailed logs.

Inputs: sn (required), repo (required).

pr_checksGet PR CI check statusesB
Read-onlyIdempotent

Get CI check statuses attached to a pull request.

Inputs: repo (required), number (required).

pr_comment_listList PR commentsC
Read-onlyIdempotent

List comments on a pull request.

Inputs: repo (required), number (required), page, page_size.

pr_commitsList PR commitsC
Read-onlyIdempotent

List commits contained in a pull request.

Inputs: repo (required), number (required).

pr_filesList PR changed filesB
Read-onlyIdempotent

List files changed by a pull request with patch diffs.

Inputs: repo (required), number (required), page, page_size.

pr_getGet a pull requestB
Read-onlyIdempotent

Get one pull request including mergeable_state (conflict/merge status) and CI statuses.

Inputs: repo (required), number (required).

pr_listList pull requestsB
Read-onlyIdempotent

List pull requests with optional filters.

Inputs: repo (required), page, state, author, +2 more.

pr_review_listList PR reviewsA
Read-onlyIdempotent

List reviews of a pull request (approve / request changes / comment).

Inputs: repo (required), number (required).

repo_branch_getGet a branchB
Read-onlyIdempotent

Get one branch with its head commit.

Inputs: repo (required), branch (required).

repo_branch_listList branchesC
Read-onlyIdempotent

List branches of a repository.

Inputs: repo (required), page, page_size.

repo_commit_getGet a commitB
Read-onlyIdempotent

Get one commit with its changed files (patch).

Inputs: sha (required), repo (required).

repo_commits_listList commitsB
Read-onlyIdempotent

List commit history, optionally starting from a commit-ish.

Inputs: repo (required), sha, page, since, +3 more.

repo_commit_statusesGet commit check statusesB
Read-onlyIdempotent

Get CI check statuses (pipeline results) attached to a commit.

Inputs: repo (required), commitish (required).

repo_diff_compareCompare two refsC
Read-onlyIdempotent

Get the diff between two refs (base and head), e.g. base=main head=feature-x.

Inputs: base (required), head (required), repo (required).

repo_file_readRead a fileA
Read-onlyIdempotent

Read the raw text content of a file at a given ref (branch/tag/commit).

Inputs: ref (required), path (required), repo (required).

repo_getGet repository detailsB
Read-onlyIdempotent

Get metadata of a CNB repository (description, visibility, default branch, stats).

Inputs: repo (required).

repo_listList my repositoriesB
Read-onlyIdempotent

List repositories owned by the authenticated CNB user.

Inputs: page, search, page_size.

repo_tag_listList tagsC
Read-onlyIdempotent

List tags of a repository.

Inputs: repo (required), page, page_size.

repo_tree_listList directory contentsB
Read-onlyIdempotent

List files and directories at a path. Omit path to list the repository root.

Inputs: ref (required), repo (required), path.

whoamiGet current CNB userA
Read-onlyIdempotent

Return the CNB user that the upstream token belongs to. Use this first to verify authentication works.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 29 tools

    Disambiguation4/5

    Tools are grouped by resource prefix (repo_*, issue_*, pr_*, build_*, npc_*) and most have a single distinct action, so an agent can pick correctly in the common case. A few pairs are close: repo_commit_statuses vs pr_checks, build_status vs npc_status, and pr_commits vs pr_files all surface overlapping CI/commit data, though the descriptions do enough to separate them.

    Naming Consistency4/5

    Nearly all tools follow a resource_action snake_case convention (repo_list, issue_get, pr_review_list, build_stage_logs), which is highly predictable. Minor deviations exist: whoami and pr_commits (verb/plural noun without action) and a couple of prefix irregularities like repo_file_read vs repo_tree_list.

    Tool Count2/5

    At 29 tools this is above the comfortable range for what is essentially a read-only repository browsing surface, and several list/get pairs feel granular enough to be merged. The npc_* group in particular adds scope that inflates the set without adding much distinct capability.

    Completeness3/5

    Read coverage is thorough: repos, files, commits, diffs, branches, tags, issues, PRs, reviews, builds, and logs are all reachable. However, there is no write/lifecycle operation anywhere — no create issue, open PR, comment, merge, or branch creation — so workflows dead-end at read-only inspection.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with a Forgejo instance as an authenticated user, supporting issues, pull requests, repositories, and notifications.
      26 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI agents to read repositories, manage issues, inspect CI/CD workflow runs, create branches, commit files, and open pull requests on a self-hosted Gitea instance.
      7
      MIT