DeepSeek Harness 插件:通過 TokenRhythm 生成圖片並落盤

在 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 協議暴露了兩個工具:

  1. mcp__tokenrhythm_image__generate_image
    • 生成最多 4 張圖片。
    • 支持模型:qwen-image-2.0 或 wan2.7-image。
    • 將圖片寫入本地目錄,返回本地路徑和遠程 URL。
  2. mcp__tokenrhythm_image__list_image_models
    • 列出當前可用的 TokenRhythm 圖片模型。

安裝與啓用

Desktop 端

  1. 打開 DeepSeek Harness Desktop。
  2. 在側邊欄點擊 Plugins。
  3. 選擇 Add plugin。
  4. 在對話框中輸入插件地址:
    https://github.com/bauerelizabeth07139/opencode-tokenrhythm-image-mcp
  1. 啓用新出現的 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

注意事項

  1. 付費 API:生成圖片需要 TokenRhythm 的付費 API Key。未配置 Key 時,工具會報錯提示變量未設置。
  2. 輸出目錄:默認輸出目錄爲 ~/Pictures/opencode-tokenrhythm(在當前平臺下),位於 workspace 外部。建議顯式設置 outputDir 以便管理文件。
  3. 超時設置:TokenRhythm 單次請求的服務端預算爲 300 秒。插件默認將超時設置爲 360 秒,以避免請求被中斷。

生態鏈接

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜