Skip to main content
Glama
README.md
# AMD Radeon MCP

把 [AMD Radeon Cloud](https://developer.amd.com.cn/radeon/) 接入任意 MCP 客户端:在对话里部署和管理 GPU Notebook 实例、在实例内执行命令与训练任务,并免费调用平台托管的 Token Factory 模型(chat / OCR / TTS / 决策)。

Python 实现(MCP SDK 2.x + httpx + asyncssh),支持 stdio 与 streamable-http,可托管部署到 [ModelScope MCP 广场](https://modelscope.cn/mcp)。

## 安装

```bash
python3 -m venv .venv
.venv/bin/pip install -e .
```

## 配置

| 变量 | 用途 |
|---|---|
| `RADEON_API_KEY` | Token Factory 推理(`rc-` 开头,[控制台 Token Factory 页](https://developer.amd.com.cn/radeon/tokenfactory)复制) |
| `RCC_TOKEN` + `RCC_URL` | 实例管理(`rcc_` 令牌,**两者必须成对**;`RCC_URL=https://developer.amd.com.cn/radeon`) |
| `RADEON_SSH_IDENTITY` 或 `SSH_PRIVATE_KEY` | 实例内操作/训练的 SSH 私钥(路径或内容) |

也可以写入 `~/.config/radeon-cloud-mcp/auth.json`(chmod 600):

```json
{"api_key": "rc-...", "rcc_token": "rcc_...", "ssh_identity": "~/.ssh/id_ed25519"}
```

实例管理也可以不用 `RCC_TOKEN`:本地执行 `rcc auth login`(`rcc` 已随本包安装),CLI 登录态直接可用。首次用 SSH 前执行 `rcc instance add-key` 上传公钥——**公钥只对之后创建的实例生效**。

其他可选变量:`RADEON_BASE_URL`、`RADEON_OUTPUT_DIR`(音频/OCR 图片落盘目录)、`RADEON_SSH_KNOWN_HOSTS`、`RADEON_REQUEST_TIMEOUT`、`RADEON_MAX_CONCURRENCY`。

## 运行

```bash
.venv/bin/radeon-cloud-mcp                              # stdio,由 MCP 客户端拉起
.venv/bin/radeon-cloud-mcp --transport http --port 8000 # HTTP,端点 /mcp
```

## MCP 客户端配置

```json
{
  "mcpServers": {
    "radeon": {
      "command": "uvx",
      "args": ["radeon-cloud-mcp"],
      "env": {
        "RADEON_API_KEY": "rc-...",
        "RCC_TOKEN": "rcc_...",
        "RCC_URL": "https://developer.amd.com.cn/radeon",
        "SSH_PRIVATE_KEY": ""
      }
    }
  }
}
```

`RADEON_API_KEY` 必填(Token Factory 推理);`RCC_TOKEN`+`RCC_URL` 成对填写后启用实例管理;`SSH_PRIVATE_KEY` 填写后启用实例内操作/训练。本地运行也可把 `command` 换成本仓库 `.venv/bin/radeon-cloud-mcp` 的绝对路径。

## 工具(20 个)

**GPU 实例**:`credits_status` `catalog_list` `instance_create` `instance_status` `instance_logs` `instance_delete` `instance_connect` `instance_add_key` `cli_health` `instance_exec` `instance_job` `instance_transfer` `instance_gpu_status`

**Token Factory**:`list_models` `model_load` `chat` `usage` `ocr` `speech` `decide`

## 示例:部署并训练

```text
catalog_list
instance_create(env="Base", pod_type="one-click", resource_template="resource-16c55g1u", use_pvc=true)
instance_transfer("upload", "train.py", "/workspace/train.py")
instance_exec("python /workspace/train.py", background=true)   → {pid, log_file}
instance_job("logs", pid=..., log_file=...)                    → 训练进度
instance_transfer("download", "/workspace/model.pt", "./model.pt")
instance_delete(confirm=true)
```

实例按小时扣 credits(1 credit/GPU/小时),不用就销毁;`instance_delete` 需要 `confirm=true`。持久数据放 `/workspace`(`use_pvc=true`),临时目录随实例删除。

## ModelScope 托管部署

见 [docs/modelscope-deploy.md](docs/modelscope-deploy.md):推送 GitHub 后在魔搭「从Github仓库快速创建」,或发布 PyPI 后用 uvx 配置(示例 [modelscope/service-config.json](modelscope/service-config.json))。

## 开发

```bash
.venv/bin/pip install -e ".[dev]"
.venv/bin/python -m pytest tests/ -q
.venv/bin/python scripts/smoke_live.py       # 真实 API 冒烟(需 key)
.venv/bin/python scripts/smoke_stdio.py      # stdio 端到端
.venv/bin/python scripts/smoke_instance.py   # 实例链路只读检查(需 rcc 登录)
```

## 文档

- [Radeon Cloud 官方文档](https://amd-aim.github.io/radeon-cloud-docs/zh-cn/api/overview/)
- [DESIGN.md](DESIGN.md):平台调研、架构与实测记录
- [docs/community-blog-draft.md](docs/community-blog-draft.md):社区实践文章草稿

## 许可

Apache-2.0,见 [LICENSE](LICENSE)。

TDQS

A3.9/5.0

Scored across 20 tools

Disambiguation4/5

Most tools target a clearly distinct resource+action: instance lifecycle (create/status/logs/delete/connect/exec/job/transfer), model inference (chat/list_models/model_load/usage), and media (ocr/speech/decide). A few boundaries blur — instance_status already returns the JupyterLab URL and SSH info that instance_connect prints, and model_load vs list_models vs usage are three separate model-query tools an agent could mix up. Descriptions largely resolve these, so misselection risk is low but not zero.

Naming Consistency3/5

All names are snake_case and the instance_* prefix grouping is a strong, predictable cluster. However, verb placement is inconsistent across the set: model_load and catalog_list put the verb last while list_models and instance_create/instance_delete put it first, and several tools are bare nouns/verbs (chat, usage, ocr, speech, decide, cli_health). Readable, but not a single convention.

Tool Count4/5

20 tools is on the heavy side, but the server genuinely spans several sub-domains (GPU instance lifecycle, Token Factory inference, OCR/TTS, credits/catalog), so each tool carries a real function rather than being redundant. The ~11 instance_* tools are granular (add_key, gpu_status, logs, job) but each maps to a distinct operational need.

Completeness4/5

Instance coverage is near-complete: create, status, GPU metrics, logs, exec, background jobs, file transfer, key upload, connect, and destroy, plus credit/quota awareness. Minor gaps exist — no instance stop/start (only irreversible delete), no direct file read/list primitive short of exec or transfer, and no batch/multi-instance handling — but agents can work around these.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues