CLI 参考
Almirant CLI 可让你向一个或多个实例进行身份验证、将仓库关联到项目,并在不把令牌写入项目文件的情况下向你的智能体公开 MCP 服务器。
安装
npm i -g almirant
验证安装:
almirant version
主要命令
| 命令 | 说明 |
|---|---|
almirant login | 通过浏览器进行身份验证,并将账户保存到 ~/.almirant/config.json |
almirant accounts list | 列出已配置的账户,不显示密钥 |
almirant accounts rename <ref> <label> | 为账户指定便于人读的标签 |
almirant use [ref] | 选择活动账户;不带参数时打开交互式选择器 |
almirant current | 显示活动账户,不泄露 API key |
almirant link | 使用已存储的凭据将当前仓库关联到项目 |
almirant init | 为当前项目配置 Almirant MCP(完整流程) |
almirant mcp proxy --project-id <id> [--account <ref>] | MCP 智能体使用的 stdio 代理;从本地配置读取令牌 |
账户
almirant login 可以执行多次。每个账户都会保存以下信息:
- 稳定的
id,供生成的配置使用; - 本地
label,供人使用(local-m1pro、prod-saas、kroko-dev); - 电子邮件、API URL 和 API key。
almirant accounts list
almirant accounts rename 2 local-m1pro
almirant use local-m1pro
almirant current
接受账户的命令使用 <ref>:标签、稳定 ID、唯一电子邮件或列表索引。
生成的文件
CLI 会创建并使用以下文件:
| 文件 | 位置 | 说明 |
|---|---|---|
config.json | ~/.almirant/config.json | 本地账户和 API key;权限为 600 |
.mcp.json | 仓库根目录 | 执行 almirant mcp proxy 的无密钥 MCP 配置 |
.claude/skills/ | 仓库根目录 | Claude Code 的 Skills |
.agents/skills/ | 仓库根目录 | 其他智能体的 Skills |
信息
文件 ~/.almirant/config.json 是本地唯一保存 API key 的位置,且权限为 600。请勿共享或提交到仓库。
无密钥 MCP
almirant init 和 almirant link 会生成类似下面的 stdio 条目:
{
"mcpServers": {
"almirant": {
"type": "stdio",
"command": "almirant",
"args": ["mcp", "proxy", "--project-id", "<project-id>", "--account", "<account-id>"]
}
}
}
仓库通过 --account <account-id> 固定到特定账户,但不包含 bearer token。代理会在运行时读取 ~/.almirant/config.json,并在内存中附加令牌。
如果你使用 Codex 并偏好 .codex/config.toml,请使用相同模式:
[mcp_servers.almirant]
command = "almirant"
args = ["mcp", "proxy", "--project-id", "<project-id>", "--account", "<account-id-or-label>"]
若要让项目始终跟随通过 almirant use 选择的活动账户,请省略 --account ... 参数。这种方式更灵活,但对旧仓库而言安全性较低,因为它们可能会指向错误的实例。
迁移带令牌的旧配置
旧配置包含 type: "http"、url 和 Authorization: Bearer ... 请求头。重新执行以下命令以替换它们:
almirant link
或者手动将条目改为上面展示的 stdio 代理。如果真实令牌曾被提交到仓库,请在 Almirant 中或通过以下命令轮换它:
almirant config rotate api-key --account <ref>