Skip to main content
Glama
prime-intellect-mcp

prime-intellect-mcp

by kvrancic

prime-intellect-mcp

让 Claude Code 自行租用、驱动和终止 Prime Intellect GPU 节点 — 并配有您可控的硬性支出上限。

PyPI Python License CI MCP


这是什么

这是一个 MCP 服务器,用于将 Claude Code(或任何 MCP 客户端)连接到您的 Prime Intellect 账户。通过它,代理可以:

  • 🔍 查找 符合您要求的最便宜 GPU 节点

  • 💸 报价 在投入资金之前获取价格

  • 🛒 配置 节点(仅在您确认 confirm=True 后)

  • 🖥️ SSH 进入节点(连接字符串会传递给代理自己的 Bash 工具)

  • 🛑 终止 节点(工作完成后)— 如果您忘记了,它还会发出强烈警告

专为一种工作流构建:告诉 Claude “租用最便宜的 H100,运行我的训练脚本,然后将其销毁”,而不必担心醒来时看到 400 美元的账单。


Related MCP server: claude-colab

60 秒内完成安装

您只需执行以下操作即可开始通过 Claude Code 租用 GPU:

1. 获取 Prime Intellect API 密钥

点击此处生成密钥 → 设置权限:

范围

级别

Instances (实例)

读写

Availability (可用性)

只读

Billing (账单)

只读

SSH Keys (SSH 密钥)

只读

复制密钥 — 它以 pit_… 开头。

2. 将服务器添加到 Claude Code

打开 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) 或您项目的 .mcp.json,并粘贴:

{
  "mcpServers": {
    "prime-intellect": {
      "command": "uvx",
      "args": ["prime-intellect-mcp"],
      "env": {
        "PRIME_API_KEY": "pit_PASTE_YOURS_HERE",
        "PRIME_MAX_HOURLY_USD": "5",
        "PRIME_MAX_TOTAL_USD": "40"
      }
    }
  }
}

就是这样。重启 Claude Code 并询问:“现在有哪些低于 $1/小时的 GPU 可用?”

没有 uvx?使用 curl -LsSf https://astral.sh/uv/install.sh | sh (或 brew install uv) 进行安装。这是一个用于 uv 包管理器的单行安装程序,您再也不用管理虚拟环境了。


✨ 添加 SSH(可选,+2 分钟)— Claude 在节点上运行代码所必需

上述服务器已经可以配置/检查/终止节点。但要让 Claude Code 通过 SSH 进入正在运行的节点并在其上执行命令,Prime Intellect 需要知道您机器的公钥。

3. 在您的机器上查找或生成 SSH 密钥

ls ~/.ssh/*.pub          # if you have id_ed25519.pub or similar, you're set
# otherwise:
ssh-keygen -t ed25519 -C "you@example.com"   # press Enter through the prompts

4. 向 Prime Intellect 注册公钥

cat ~/.ssh/id_ed25519.pub    # or whichever .pub file you have

复制输出内容(以 ssh-ed25519 … 开头的一行),然后将其粘贴到 app.primeintellect.ai/dashboard/ssh-keys 的 Add SSH key 表单中。

就是这样。未来的节点将在 authorized_keys 中包含您的公钥,Claude Code 的 Bash 工具可以直接通过 SSH 进入:

ssh ubuntu@<pod-ip-from-pod_status> "nvidia-smi"

v0.2 版本预告: 一个 register_ssh_key MCP 工具,可以在 Claude 内部完成第 4 步(无需访问浏览器)。请参阅 问题追踪器 以获取最新进展。


Claude 现在能做什么(9 个工具)

工具

用例

list_gpu_types

“Prime Intellect 提供哪些 GPU 类型?”

list_availability

“显示低于 $3/小时的 1×H100 节点。”

get_wallet_balance

“我还有多少余额?”

pod_quote

“为我报价一个 200GB 磁盘的 1×A100。”(不收费)

pod_create

“根据该报价配置节点。”(需要 confirm=True)

pod_list

“显示我正在运行的节点。”

pod_status

“节点 X 准备好了吗?等待直到它有 SSH 信息。”

pod_terminate

“销毁节点 X。”(需要 confirm=True)

pod_check_runaway

“我是否忘记终止任何节点了?”


安全性:没有任何配置是静默发生的

按顺序分为三层:

  1. 先报价。 pod_quote 返回价格 + 一个 60 秒的令牌。无副作用。金额现在已在代理的上下文中。

  2. 明确确认。 pod_create(和 pod_terminate)需要 confirm=True。如果没有它,您只会得到一个试运行预览。

  3. 硬性环境变量上限。 PRIME_MAX_HOURLY_USD 会阻止任何高于该费率的节点。PRIME_MAX_TOTAL_USD 会阻止任何(费率 × 最大运行小时数)超过预算的节点。钱包余额也会被强制执行。这些上限都不能通过工具参数覆盖 — 它们在每次调用时都会被读取。

默认值:PRIME_MAX_HOURLY_USD=5, PRIME_MAX_TOTAL_USD=40。在配置的 env 块中设置它们。

每个 pod_create / pod_terminate 操作都会以 JSON 格式追加到 ~/.prime-intellect-mcp/audit.log 中,因此您拥有代理如何使用您资金的完整历史记录。


示例提示词(粘贴到 Claude Code 中)

List the cheapest 1×H100 pods available right now. Show me the top 3 by hourly price.
Quote a 1×A100 80GB with 100GB disk, 8 vCPU, 64GB RAM. Don't provision yet —
just show me what it would cost.
I need to fine-tune a 7B model overnight. Find the cheapest 1×H100 with 200GB
disk, max $40 total budget, max 12 hours. Provision it, give me the SSH command,
and remind me to terminate when I'm done.
Check if I have any running pods I forgot about and show me their hourly cost.
Terminate pod abc123. Confirm before doing it.

故障排除

要么是您的 Claude Code 配置没有读取到 env 块,要么是您将 PRIME_API_KEY 输入成了其他变量名。请在启动 Claude Code 的同一个 shell 中使用以下命令验证:

$ env | grep PRIME

或者直接将密钥粘贴到 JSON env 块中(而不是使用 ${PRIME_API_KEY})。

代理选择了一个超过您硬性上限的节点。您可以:

  • 选择更便宜的 GPU(使用带有区域过滤器的 list_availability 通常会显示更便宜的社区定价行),或者

  • 在配置中提高 PRIME_MAX_HOURLY_USD 并重启 Claude Code。

报价有效期为 60 秒;代理在 pod_quote 和 pod_create 之间等待时间过长。只需再次调用 pod_quote 即可 — 它在成本上是无操作的。

配置尚未完全完成。节点已启动但仍在运行其安装脚本。调用 pod_status(pod_id, wait_for_ssh=True),它将阻塞(每 5 秒轮询一次)直到 SSH 可用。

您还没有将公钥告知 Prime Intellect(或者节点是在您注册公钥之前配置的)。解决方法:

  1. 验证您的公钥是否已在 app.primeintellect.ai/dashboard/ssh-keys 注册。

  2. 重新配置 — 节点的 authorized_keys 是在创建时设置的,因此现有节点不会获取您之后注册的密钥。

  3. 如果您的私钥有密码,请在 macOS 上运行一次 ssh-add --apple-use-keychain ~/.ssh/your_key,这样代理以后就可以静默解锁它。

在 app.primeintellect.ai/wallet 充值后再试。


为什么还要开发这个?

PyPI 上有一个 prime-mcp-server 0.1.2。那只是一个简单的概念验证;这不是一个分支。针对无人值守的夜间使用,其区别如下:

prime-intellect-mcp

prime-mcp-server 0.1.2

两步报价 → 确认

✅

❌

环境变量硬性支出上限

✅

❌

钱包预检查

✅

❌

失控节点检测

✅

❌

SSH 移交给代理

✅

❌

测试

32 个单元测试 + 可选实时测试

无


本地开发

git clone https://github.com/kvrancic/prime-intellect-mcp
cd prime-intellect-mcp
uv sync
uv run pytest -m "not live"        # 32 fast tests, no network, no spend
uv run ruff check .
uv run mypy src

实时冒烟测试(配置最便宜的可用 GPU,运行 nvidia-smi,然后终止;花费约 $0.05):

PRIME_API_KEY=pit_... PRIME_LIVE_TEST=1 PRIME_LIVE_MAX_HOURLY=0.60 \
PRIME_MAX_HOURLY_USD=0.60 PRIME_MAX_TOTAL_USD=2.00 \
uv run pytest tests/test_smoke_live.py -v -s

路线图

  • v0.2 — register_ssh_key MCP 工具(省去仪表板步骤),沙盒(prime-sandboxes SDK),环境中心

  • v0.3 — 可选的自动终止守护进程(服务器端强制执行 max_lifetime_hours);成本遥测

  • v1.0+ — 当 Prime Intellect 发布 OAuth 时进行托管/OAuth 部署;提交到 Anthropic 连接器目录


致谢

许可证

MIT — 见 LICENSE。

贡献

欢迎提交 Issue 和 PR。请在提交前运行 uv run pytest -m "not live" 和 uv run ruff check .。

Available Tools

9 tools
get_wallet_balanceA

Return the current Prime Intellect wallet balance and recent billings.

Use this to estimate how long a quoted pod can run, or to check why pod_create returned an insufficient-funds error.

Inputs: no named parameters. Returns: object

list_availabilityA

List currently-available GPU pods that match the filters.

Returns the SDK's GPUAvailability rows (cloud_id, gpu_type, gpu_count, prices, disk/vcpu/memory bounds, stock_status, ...). Use this to pick a target before pod_quote, or to show the user options.

Inputs: gpu_type, gpu_count, regions. Returns: object

list_gpu_typesA

List every GPU type Prime Intellect currently offers (e.g. "H100_80GB", "A100_80GB").

Use this when the user is vague about what they want. Pass the result into list_availability or pod_quote.

Inputs: no named parameters. Returns: result

pod_check_runawayA

Return locally-tracked pods that have run past max_lifetime_hours OR whose accumulated cost is approaching PRIME_MAX_TOTAL_USD.

Call this at the start of long-running sessions to catch forgotten pods.

Inputs: no named parameters. Returns: result

pod_createA

Provision a Prime Intellect GPU pod (or preview the provisioning).

With confirm=False: returns a dry-run preview describing what would happen. With confirm=True: validates spend caps + quote freshness, then provisions.

The server enforces:

  • quote_token must be fresh (TTL 60s)

  • hourly_usd ≤ PRIME_MAX_HOURLY_USD

  • hourly_usd × max_lifetime_hours ≤ PRIME_MAX_TOTAL_USD

  • estimated total ≤ wallet balance

On success, the pod is recorded in local state.json so pod_check_runaway can warn about overdue pods later.

Inputs: quote_token (required), name (required), max_lifetime_hours, confirm, +1 more. Returns: object

pod_listA

List every pod the API key can see (active + provisioning + stopped).

Inputs: no named parameters. Returns: result

pod_quoteA

Get a non-binding price quote + reserved provisioning payload.

Returns a quote_token (TTL=60s) that you pass to pod_create with confirm=True to actually provision. This tool has NO side effects.

The server picks the cheapest matching GPUAvailability row that satisfies the requested disk/vcpu/memory. If none matches, returns an error explaining what's available.

Inputs: gpu_type (required), gpu_count, disk_size_gb, vcpus, +2 more. Returns: object

pod_statusA

Get the current status (provisioning / active / failed) for a pod.

With wait_for_ssh=True, blocks (polls every 5s) until ssh_connection is available — that's when you can SSH in. Returns the SSH connection string in ssh_connection (e.g. "root@1.2.3.4 -p 22000"). Use it from your Bash tool: ssh -o StrictHostKeyChecking=no <ssh_connection> "<cmd>".

Inputs: pod_id (required), wait_for_ssh, timeout_s. Returns: object

pod_terminateA

Destroy (terminate) a pod. Idempotent on already-deleted pods.

Without confirm=True, returns a no-op preview so you can re-read your decision.

Inputs: pod_id (required), confirm. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool has a unique and clearly distinct purpose, from wallet balance and GPU availability listing to pod creation, quoting, and termination. There is no overlap that could cause an agent to select the wrong tool.

    Naming Consistency5/5

    Tool names follow a consistent pattern: utility functions use verb_noun (e.g., get_wallet_balance, list_availability) and pod operations all start with pod_ (e.g., pod_create, pod_terminate). The naming is predictable and easily understood.

    Tool Count5/5

    With 9 tools covering wallet, GPU types, availability, pod lifecycle (create, list, status, quote, terminate), and runaway monitoring, the count is well-scoped for the server's purpose. Each tool earns its place with no redundancy.

    Completeness5/5

    The tool surface covers the full lifecycle of GPU pod management: discovering availability, quoting, creating, monitoring status, listing, terminating, and checking for runaway pods. The inclusion of wallet balance and wait-for-SSH functionality addresses common operational needs.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers