前言¶
在 DSH 里让智能体访问 GitHub,常见做法是先在本地准备 Git 或 gh CLI,再让模型调用这些命令行工具;另一类做法是通过 DSH 的 MCP bridge 连接 GitHub MCP server。后一种链路少了本地命令行中间层,但已有 bridge 会丢掉文件内容。
dsh-github-mcp 针对这个链路做桥接:把 GitHub 官方 MCP server 暴露为 DSH 原生工具,并提供 github_file_read 工具读取文件内容。
这是什么¶
dsh-github-mcp 是 GitRuozhi 维护的 DSH 插件,许可证为 MIT,package.json 中版本为 1.1.0。
它把 GitHub 官方 MCP server 注册为 DSH 原生工具,安装后主要通过两个入口访问 GitHub:
mcp__github__*工具族;github_file_read工具。
插件使用 GitHub hosted endpoint:
https://api.githubcopilot.com/mcp/
事实说明中写明,它无需本地 Git 或 gh CLI 中间层。package.json 声明了两个 peer dependencies:
"@deepseek-ai/dsh-mcp-client": ">=0.1.0-rc.6",
"@deepseek-ai/dsh-tools": ">=0.1.0-rc.6"
核心功能¶
暴露 GitHub 官方 MCP 工具¶
安装后,DSH 可以调用 mcp__github__* 工具族。资料写明这些工具来自 GitHub 官方 MCP server,共 44 tools。
本文可核实的示例包括:
search_repositories
get_file_contents
list_issues
create_pull_request
merge_pull_request
模型侧看到的名字都带 mcp__github__ 前缀。
读取文件内容或目录¶
github_file_read 用于读取文件内容,或列出目录。
已核实说明写明:文件内容会 decoded to UTF-8 text。私有仓库支持需要 GITHUB_TOKEN。
使用 GitHub hosted MCP endpoint¶
插件使用:
https://api.githubcopilot.com/mcp/
因此接入方式不依赖本地 Git 仓库,也不依赖本地 gh CLI 作为中间层。
安装与启用¶
先执行插件安装命令:
dsh plugin --profile web add github:GitRuozhi/dsh-github-mcp
这一步会把 dsh-github-mcp 添加到 web profile 下。
如果需要使用私有仓库,设置 GITHUB_TOKEN 后重启 dsh web:
Set GITHUB_TOKEN and restart dsh web
如果本机 gh 已经登录,文档给出的说法是:可以直接让 DSH 帮你配置。
典型用法¶
下面给出几个从已核实资料中可核对的使用路径。
使用 mcp__github__* 工具¶
安装后,可以在 DSH 中直接使用 mcp__github__* 工具族。示例工具名包括:
search_repositories
get_file_contents
list_issues
create_pull_request
merge_pull_request
这些工具名对应 GitHub 官方 MCP server 的工具,模型侧统一带 mcp__github__ 前缀。
使用 github_file_read 读取文件或目录¶
github_file_read 可用于读取文件内容,也可以用于列出目录。
适合的场景是:你希望 DSH 直接拿到某个仓库里的文件文本,而不是只拿到路径、元数据或被 bridge 丢弃后的空内容。
使用私有仓库¶
私有仓库需要设置 GITHUB_TOKEN,然后重启 dsh web。
最小 preset 与工具过滤¶
dsh-github-mcp 会把工具注册到全局,因此所有 preset 都会继承 GitHub tools,包括 minimal presets。
如果你想在某个 preset 中排除这些工具,建议在 system-prompt/assemble 阶段过滤,而不是在 apply 阶段一次性快照 ctx.tools.schemas()。原因是插件注册工具是异步的,包含 MCP discovery 和 ctx.effect registration;在 apply 时做一次性快照可能拿到空结果,导致过滤逻辑没有生效。assembly-time filtering 不依赖具体注册时机,请求组装时再过滤即可。
已核实的建议是:DSH 内置的 minimal preset 不能 mask global plugins;需要创建自定义 minimal preset 来实现隔离。
下面给出 README 中的过滤示例。
这个 JS 文件用于在 system prompt 组装时移除 mcp__github__* 和 github_file_read:
// restrict-github.js
const name = 'restrict-github';
const inject = ['tools'];
function apply(ctx) {
ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
const assembled = await next();
try {
const tools = assembled && Array.isArray(assembled.tools) ? assembled.tools : [];
const filtered = tools.filter((tool) => {
const toolName = tool && typeof tool.name === 'string' ? tool.name : '';
return !(toolName.startsWith('mcp__github__') || toolName === 'github_file_read');
});
if (filtered.length === tools.length) return assembled;
return { ...assembled, tools: filtered };
} catch (error) {
// A filter bug must never brick a session: keep every tool.
return assembled;
}
});
}
export { apply, inject, name };
在对应 preset 的 agent.cordis.yml 中挂载该 filter:
# in that preset's agent.cordis.yml
- id: restrict-github
name: ./restrict-github.js
适用场景与注意¶
适合这类使用者:
- 希望 DSH 直接调用 GitHub 官方 MCP server 的
mcp__github__*工具; - 需要读取 GitHub 仓库中的文件内容,而不是只依赖本地 Git 或
ghCLI; - 需要在私有仓库场景下通过
GITHUB_TOKEN访问 GitHub; - 需要控制某个 preset 是否继承全局 GitHub 工具。
使用前需要确认:
- 插件许可证为 MIT;
package.json要求@deepseek-ai/dsh-mcp-client >=0.1.0-rc.6和@deepseek-ai/dsh-tools >=0.1.0-rc.6;- 私有仓库需要
GITHUB_TOKEN; - 插件工具默认全局注册,所有 preset 都会继承;
- 插件以当前
dsh进程权限运行,安装前建议检查源码、依赖和许可证。
小结¶
dsh-github-mcp 的核心价值,是把 GitHub 官方 MCP server 暴露为 DSH 原生工具,并用 github_file_read 补齐文件内容读取这一环节。安装后可以直接使用 mcp__github__* 工具族和 github_file_read,私有仓库通过 GITHUB_TOKEN 启用。
仓库地址:
https://github.com/GitRuozhi/dsh-github-mcp
目录页(来自插件线索,未在本次抓取资料中进一步核验):
https://www.skillhub.cn/plugins/GitRuozhi/dsh-github-mcp