> 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` 贯穿构建者——无论是人类还是 AI 代理——完成整个在 Rome 上构建的生命周期：有据可依的链上事实、正确的模式、合约调用、资金入门通道、部署/发送、跨 VM 诊断，以及双通道 works-gate。一个能力核心，两种对齐的界面——一个 CLI（`rome <command>`）以及一个 [MCP](https://modelcontextprotocol.io) 服务器（`rome mcp`）——因此代理与人类共享同一个心智模型。

## 安装

以仓库为先（npm 发布待定）：

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

# 持久安装——克隆 + 链接：
git clone --branch v0.11.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 一次性运行或克隆 + 链接，并按上文固定一个标签：npx 会保留它最先获取的副本，因此未固定版本的 `npx github:rome-protocol/rome-cli` 可能会一直运行旧版本，而固定标签则始终拉取该版本。

## 一个核心，两层

**读取——落地与诊断。** 不需要密钥；在 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 资助： **首次桥出** （入向无摩擦——无需任何操作）                                                                                                                               |
| `rome verify <chain> [--path …]`                                           | 这个 **支持路径感知的 works-gate**，每种入口方式各一个： `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.11.0", "mcp"] } } }
```

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

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

## 代理落地闭环

1. `rome cookbook patterns <what I'm building>` → 对应哪个示例仓库 + 架构
2. `rome facts chain <chain>` → RPC、程序 ID、gas 代币（无需硬编码）
3. …基于这些精确值编写代码…
4. `rome verify <chain> --path <your way in>` → 证明它可行，无论你从哪条路径进入

## 了解更多

* 仓库 + 完整指南： [`rome-protocol/rome-cli`](https://github.com/rome-protocol/rome-cli)
* [生态系统与仓库](/zh/kuai-su-kai-shi/ecosystem.md) · [构建双通道应用](/zh/kai-fa-zhe-zhi-nan/dual-lane-app.md) · [从主链出发：从另一条链抵达 Rome](/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.
