在 DeepSeek Harness (DSH) 的开发场景中,调用外部 API 生成图片是常见需求。通常这需要单独配置服务或处理复杂的文件路径返回逻辑。下面介绍 opencode-tokenrhythm-image-mcp,这是一个 DeepSeek Harness 插件,它将 TokenRhythm(支持 qwen-image-2.0 和 wan2.7-image 模型)的图片生成能力打包,直接将生成的图片保存到本地目录,并将路径返回给模型。
插件介绍¶
这是一个基于 OpenCode MCP 服务器构建的 DSH 插件。插件本身是一个纯 stdio MCP 服务器,无第三方依赖。它通过 TokenRhythm 接口生成图片,并将文件保存到磁盘,随后返回本地路径供模型使用。
插件维护者:bauerelizabeth07139。开源协议:MIT。
核心功能¶
插件通过 MCP 协议暴露了两个工具:
mcp__tokenrhythm_image__generate_image- 生成最多 4 张图片。
- 支持模型:
qwen-image-2.0或wan2.7-image。 - 将图片写入本地目录,返回本地路径和远程 URL。
mcp__tokenrhythm_image__list_image_models- 列出当前可用的 TokenRhythm 图片模型。
安装与启用¶
Desktop 端¶
- 打开 DeepSeek Harness Desktop。
- 在侧边栏点击 Plugins。
- 选择 Add plugin。
- 在对话框中输入插件地址:
https://github.com/bauerelizabeth07139/opencode-tokenrhythm-image-mcp
- 启用新出现的 dsh-tokenrhythm-image bundle。
CLI 端¶
安装到当前启动的 profile(例如 web):
dsh plugin --profile web add bauerelizabeth07139/opencode-tokenrhythm-image-mcp
如果机器上没有 git,可以使用 tarball 地址:
dsh plugin --profile web add https://codeload.github.com/bauerelizabeth07139/opencode-tokenrhythm-image-mcp/tar.gz/main
卸载¶
dsh plugin --profile web remove dsh-tokenrhythm-image
配置项¶
插件依赖 Python 环境和 TokenRhythm API 密钥。
环境要求¶
- Python >= 3.8,需在系统 PATH 中。
- TokenRhythm API Key(通过环境变量或插件配置传入)。
- 网络可访问
https://tokenrhythm.studio/v1。
配置说明¶
插件支持以下配置项,通常在 cordis.patch.yml 中配置:
| 配置项 | 环境变量 | 默认值 | 说明 |
|---|---|---|---|
apiKey |
TOKENRHYTHM_API_KEY |
空 | TokenRhythm 认证密钥 |
outputDir |
TOKENRHYTHM_OUTPUT_DIR |
~/Pictures/opencode-tokenrhythm |
图片保存目录(默认在 workspace 外) |
toolCallTimeoutMs |
— | 360000 |
单次工具调用的超时时间 |
配置示例¶
在 cordis.patch.yml 中添加:
- id: dsh-tokenrhythm-image
name: 'dsh-tokenrhythm-image'
config:
apiKey: 'sk-...'
outputDir: 'D:/images/generated'
toolCallTimeoutMs: 360000
注意事项¶
- 付费 API:生成图片需要 TokenRhythm 的付费 API Key。未配置 Key 时,工具会报错提示变量未设置。
- 输出目录:默认输出目录为
~/Pictures/opencode-tokenrhythm(在当前平台下),位于 workspace 外部。建议显式设置outputDir以便管理文件。 - 超时设置:TokenRhythm 单次请求的服务端预算为 300 秒。插件默认将超时设置为 360 秒,以避免请求被中断。