> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/zh/chan-pin/rome-cli.md).

# Rome CLI + MCP

Rome 开发者 CLI 和 MCP 服务器——基于链上事实、正确的构建模式，以及面向人类或 AI 代理的 Rome 特有操作（资金、部署、验证）。

`rome` 贯穿整个 Rome 构建生命周期，帮助构建者——人类或 AI 代理——完成：有据可依的链上事实、合适的模式、合约调用、资金接入通道、部署/发送、跨 VM 诊断，以及双通道验收关卡。一个能力核心，两种一致的接口——CLI（`rome <command>`) 和一个 [MCP](https://modelcontextprotocol.io) 服务端（`rome mcp`）——让代理和人类共享同一个心智模型。

## 安装

优先使用仓库方式（npm 发布尚未完成）：

```bash
# 一次性运行，无需安装：
npx github:rome-protocol/rome-cli#v0.12.0 facts chain hadrian

# 持久安装——克隆 + 链接：
git clone --branch v0.12.0 https://github.com/rome-protocol/rome-cli
cd rome-cli && npm install && npm install -g .
```

直接的 `npm install -g github:rome-protocol/rome-cli` 并不会 **不** 在今天生效——npm 会准备该包的 git 依赖，但不会为它们各自创建 node\_modules（[rome-cli#25](https://github.com/rome-protocol/rome-cli/issues/25)）。请使用 npx 一次性运行或克隆 + 链接，并像上面一样固定 tag：npx 会保留其首次获取的副本，因此未固定的 `npx github:rome-protocol/rome-cli` 可能会一直运行旧版本，而固定的 tag 始终会拉取该版本。

## 一个核心，两层接口

**读取——校准 + 诊断。** 无密钥；CLI 和 MCP 服务端均如此。

| 命令                                                       | 返回内容                                                                     |
| -------------------------------------------------------- | ------------------------------------------------------------------------ |
| `rome facts chain·tokens·contracts·gas·balance·programs` | 来自注册表 + RPC 的实时链上事实——没有幻觉生成的 ID、地址或选择器                                   |
| `rome cookbook patterns·cpi-recipe·errors`               | 哪个示例适合你的目标 · 代理常出错的 CPI 账户规则 · 解码 Rome 失败 → 原因 + 修复                      |
| `rome call <chain> <addr> <sig> [args]`                  | 读取合约（`eth_call`）——多值参数在一个参数中用逗号分隔： `"0xOwner…,0xSpender…"`               |
| `rome doctor <chain>`                                    | 预检——链是否在线？RPC 是否可达？程序是否已配置？钱包是否已注资？                                      |
| `rome tx <chain> <hash>`                                 | 诊断一笔交易——EVM 收据 + Solana 结算交易 + Via 链接（Rome 不提供 `debug_traceTransaction`) |
| `rome preset foundry\|hardhat <chain>`                   | 适用于你的工具链的现成 Rome 网络配置 + 相关特殊之处                                           |

**操作——在链上签名。** 仅限 CLI，密钥来自环境变量， **绝不** 在 MCP 上。

| 命令                                                                         | 功能                                                                                                                                                                  |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `rome deploy <chain> <artifact>`                                           | 部署已编译合约，并处理 Rome 的 gas 特殊性                                                                                                                                          |
| `rome send <chain> <addr> <sig>`                                           | 通过正确的 Rome 写入路径向合约写入                                                                                                                                                |
| `rome fund <chain> --from <src> --amount <usdc>`                           | 通过桥接 USDC → Rome gas（CCTP）——“从原链出发”的入金通道                                                                                                                            |
| `rome bridge <chain> --from <src> --amount <usdc> [--intent gas\|wrapper]` | 桥接 USDC **在** 作为 gas 或 wUSDC                                                                                                                                        |
| `rome bridge <chain> --to <dest> --amount <usdc>`                          | 桥出 wUSDC **出去** ——在 Rome 上销毁；你在目标链领取（Rome 资助入站，不资助出站领取）                                                                                                             |
| `rome activate <chain>`                                                    | 可选的 PDA 注资；桥出不需要，因为桥合约（RomeBridgeWithdraw v12 及后续版本）会支付消息租金，并将其计入 gas                                                                                               |
| `rome verify <chain> [--path …]`                                           | 这个 **感知路径的验收关卡**，每种进入方式各一个： `solidity` ——同一个合约在 EVM 通道上响应 *和* Solana 通道 · `solana-program` ——EVM 通道调用通过 CPI 驱动你的 Solana 程序 · `从主链出发的` ——桥入 → 在 Rome 上执行 → 桥出，完成往返验证 |

## 接入 AI 代理（MCP）

你无需运行或托管任何东西——你的 MCP 客户端会按需启动 `rome mcp` （一个 stdio 服务端）。只需注册一次：

```json
{ "mcpServers": { "rome": { "command": "npx", "args": ["-y", "github:rome-protocol/rome-cli#v0.12.0", "mcp"] } } }
```

（使用克隆 + 链接安装时， `{ "command": "rome", "args": ["mcp"] }` 也能正常工作——npx 形式只是无需预先安装。）

然后代理会调用诸如以下工具： `facts_chain`, `cookbook_cpi_recipe`, `doctor`, `tx`，以及 `preset` ——基于实时注册表 + RPC，因此它不再猜测地址和选择器。MCP 接口是 **只读且不持有密钥** ——可安全接入任何代理；它绝不会签名或转移资金。签名操作保留在 CLI 上，密钥通过环境变量提供。

## 代理校准循环

1. `rome cookbook patterns <我在构建的内容>` → 对应哪个示例仓库 + 架构
2. `rome facts chain <chain>` → RPC、program id、gas 代币（不硬编码）
3. …基于这些准确值编写代码…
4. `rome verify <chain> --path <你的进入路径>` → 证明它可用，无论你走的是哪条路径

## 了解更多

* 仓库 + 完整指南： [`rome-protocol/rome-cli`](https://github.com/rome-protocol/rome-cli)
* [生态系统与仓库](https://docs.rome.builders/zh/kuai-su-ru-men/ecosystem.md) · [构建双通道应用](https://docs.rome.builders/zh/kai-fa-zhe-zhi-nan/dual-lane-app.md) · [从原链出发：从另一条链接入 Rome](https://docs.rome.builders/zh/kai-fa-zhe-zhi-nan/from-home.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rome.builders/zh/chan-pin/rome-cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
