mcpField
M
modelrun

modelrun

本地服务
github.com/CloudCorpRecordsAI 与智能体02 周前更新

关于 modelrun

modelrun 是用于浏览 Replicate 模型与集合、管理预测任务的命令行工作台和 MCP 服务。它需要 Replicate API 令牌,并通过模型和集合列表发现内容,而不提供搜索功能。

主要功能

  1. 01列出并查看模型与集合
  2. 02浏览模型版本及其模式
  3. 03创建并监控预测任务
  4. 04取消预测并列出账户任务
  5. 05查询令牌所属账户

适用场景

  1. 01检查模型版本的输入模式
  2. 02使用模型或版本运行预测
  3. 03查看预测状态和输出
  4. 04浏览精选模型集合

MCP 相关

提供 MCP 工具,用于浏览 Replicate 模型、集合和版本,创建、查看、列出及取消预测,并获取账户信息。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"cloudcorprecords-modelrun": {
"command": "npx",
"args": [
"-y",
"@reneturcios/modelrun"
]
}
}
}
启动命令npx -y @reneturcios/modelrun

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@reneturcios/modelrun0.1.0
ocighcr.io/cloudcorprecords/modelrun:0.1.0

工具

11

收录的工具列表 · 更新于 1 周前

参数类型必填说明
cursorstring否用于获取下一页模型的分页游标(可选,取自之前的响应)。

详细介绍

modelrun

modelrun 是一个面向 Replicate 的小型工作台。它遵循该服务的结构:模型归属于某个所有者,并以名称标识;每个模型都有各自输入架构的版本;精选集汇集了值得浏览的模型;预测则是对某个版本或官方模型的一次运行,并接受自由格式的输入对象。基于这种结构,modelrun 可以列出和读取模型、浏览精选集和版本历史、启动预测、查看预测状态、取消预测,并报告令牌所属的账户。一个二进制文件同时提供命令行界面和 stdio MCP 服务。

此工具需要 Replicate API 令牌。请将其放入 REPLICATE_API_TOKEN 环境变量;该令牌会通过 Authorization: Bearer 标头发送到 API,且绝不会出现在输出中。如果缺少此变量,每次调用都会在发出任何请求之前失败,并显示包含该变量名称的错误。

Replicate 没有提供搜索端点,因此 modelrun 也不提供搜索功能:发现模型可使用 list_models 和 list_collections,再通过 get_model 读取你感兴趣的模型以缩小范围。

安装

npx @reneturcios/modelrun models

也可以运行容器镜像:

docker run -i -e REPLICATE_API_TOKEN ghcr.io/cloudcorprecords/modelrun

容器默认启动 MCP 服务(见下文)。传入 CLI 参数即可将其用作 CLI。

CLI

export REPLICATE_API_TOKEN=<redacted>

modelrun models
modelrun model meta meta-llama-3-70b-instruct
modelrun collections
modelrun collection text-to-image
modelrun versions stability-ai sdxl
modelrun version stability-ai sdxl db21e45d3f7023abc2a46ee38c23973f6dce16bb082a930b0c49861f96d1e5bf
modelrun predict --model meta/meta-llama-3-70b-instruct '{"prompt":"Explain tides in one sentence."}'
modelrun predict --version db21e45d3f7023abc2a46ee38c23973f6dce16bb082a930b0c49861f96d1e5bf '{"prompt":"a lighthouse at dawn"}'
modelrun prediction zt3k9examplepredictionid
modelrun predictions
modelrun cancel zt3k9examplepredictionid
modelrun account

modelrun --version

每条命令都会输出上游 JSON 负载。退出代码:成功时为 0,调用失败时为 1(包括缺少 REPLICATE_API_TOKEN 或 API 错误),用法错误时为 2。

MCP 服务

一个二进制文件同时提供两种接口。mcp 子命令会启动 stdio MCP 服务:

npx -y @reneturcios/modelrun mcp

MCP 客户端配置:

{
  "mcpServers": {
    "modelrun": {
      "command": "npx",
      "args": ["-y", "@reneturcios/modelrun", "mcp"],
      "env": { "REPLICATE_API_TOKEN": "r8_..." }
    }
  }
}
工具
工具输入返回内容
list_modelscursor(可选)一页模型。
get_modelowner、name(必填)模型及其描述和最新版本摘要。
list_collections(无)精选集。
get_collectionslug(必填)精选集及其中包含的模型。
list_model_versionsowner、name(必填)模型的各个版本。
get_model_versionowner、name、versionId(必填)版本及其输入/输出架构。
create_predictioninput(必填)、version/model 中恰好一个、webhook(可选)创建的预测。
get_predictionpredictionId(必填)预测及其状态和输出。
list_predictionscursor(可选)账户预测的一页。
cancel_predictionpredictionId(必填)已取消的预测。
get_account(无)令牌所属的账户。

所有调用都使用 https://api.replicate.com/v1 下的 Replicate API。create_prediction 会原样传递 input 对象;对于社区模型,请传入 version ID;对于官方模型,请将 model 设为 owner/name——两者必须且只能指定一个,工具会在发出任何请求之前进行校验。

开发

npm install
npm run build   # tsc -> dist/
npm test        # node test runner over test/*.test.ts, no network (fake fetch fixtures)
npm run dev     # run the CLI from source via tsx

许可证

MIT — 参见 LICENSE。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。