> 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` 为构建者——人类或 AI 代理——贯穿整个 build-on-Rome 生命周期提供支持：基于事实的链信息、合适的模式、合约调用、资金入场通道、部署/发送、跨 VM 诊断，以及双通道工作验证。一个能力核心，两个一致的交互界面——CLI（`rome <command>`) 和一个 [MCP](https://modelcontextprotocol.io) 服务器（`rome mcp`）——因此代理和人类共享同一套心智模型。

## 安装

优先仓库方式（npm 发布待定）：

```bash
# 一次性使用，无需安装：
npx github:rome-protocol/rome-cli facts chain hadrian

# 持久安装——克隆 + 关联：
git clone 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 一次性方式或克隆 + 关联。需要可复现运行时，请固定标签（`github:rome-protocol/rome-cli#v0.8.0`）。

## 在一个核心之上的两层

**读取——基于事实的支撑 + 诊断。** 不含密钥；同时适用于 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_trace*`) |
| `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 …]`                                           | 具备 **路径感知的工作验证门禁**，每种进入方式各一条： `solidity` ——同一个合约在 EVM 通道上响应 *和* Solana 通道 · `solana-program` ——EVM 通道调用通过 CPI 驱动你的 Solana 程序 · `from-home` ——桥入 → 在 Rome 上操作 → 桥出，完成往返验证 |

## 将其接入 AI 代理（MCP）

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

```json
{ "mcpServers": { "rome": { "command": "npx", "args": ["-y", "github:rome-protocol/rome-cli", "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-ru-men/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
