Rail

io.github.tstockham96由 GitHub 帳號 tstockham96 發布v0.1.1更新於 Oct 27, 2026

Budgets, propose-then-approve, and receipts for agents that buy for a human. Dry-run by default.

概覽

AI 產生的概覽

本機 MCP 伺服器,為代替使用者購物的代理提供預算、先提案後核准的關卡與收據帳本,預設以試跑模式運作。

可以做什麼
  • 設定並讀取本機預算上限,查看已花費、剩餘額度與待處理提案數量
  • 記錄待處理的購買提案,並依待處理、已核准、已拒絕或全部列出
  • 核准或拒絕提案,核准時產生試跑收據並扣減剩餘預算
  • 依時間倒序讀取收據,並可撤銷試跑結算以回復預算
  • 將所有帳本狀態存放在可設定的資料目錄下的本機 JSON 檔案
適用情境
適合讓代理代替使用者購物、同時需要支出上限、明確的人工核准步驟與可稽核收據紀錄的情境。它不是市集、店面或陌生開發工具,也不發行卡片。
執行需求
需要 Node.js 20 以上版本,透過 npx 以 stdio 在本機執行。選用環境變數 RAIL_DATA_DIR 指定帳本目錄,預設為使用者家目錄下的 .rail 資料夾。即時模式另需 RAIL_MODE、STRIPE_SECRET_KEY、RAIL_LIVE、RAIL_ALLOW_LIVE_CHARGE 與 LINK_ACCESS_TOKEN,並需連線至 Link 的網路。
安裝前請注意
預設試跑模式不連網也不動用金錢,但一旦同時設定 RAIL_MODE、STRIPE_SECRET_KEY、RAIL_LIVE、RAIL_ALLOW_LIVE_CHARGE 與 LINK_ACCESS_TOKEN,即時模式會向 Link 送出真實的消費請求。請勿把這些密鑰寫進共用設定片段。核准提案與退款會變更帳本,應由人工確認;README 說明即時 Link 請求內容目前僅為雛形。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Rail,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Rail MCP

Rail is a budget, approval and receipt layer that agents call when they buy something on a human's behalf, dry-run by default, wrapping Stripe Link for settlement rather than issuing cards.

It is not a marketplace, storefront, or outreach tool. Rail owns the budget, the approval gate, and the receipt ledger.

Quickstart

Requires Node.js 20+. Run the published package with npx -y rail-mcp. Default mode is dry-run: no network and no charges.

Claude Desktop and any other host that takes an mcpServers block:

json
{  "mcpServers": {    "rail": {      "command": "npx",      "args": ["-y", "rail-mcp"]    }  }}

Cursor: one-click install (install links). The config value is the base64 of {"command":"npx","args":["-y","rail-mcp"]}.

Install Rail in Cursor

cursor://anysphere.cursor-deeplink/mcp/install?name=rail&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsInJhaWwtbWNwIl19

Grok Bot: add a custom MCP with npx -y rail-mcp.

Do not put Stripe or Link secrets (STRIPE_SECRET_KEY, LINK_ACCESS_TOKEN, or live-spend flags) in this shared snippet. Real charges stay off unless those gates are set on purpose, outside the shared config. See Stripe Link seam.

Ledger files (budget.json, proposals.json, receipts.json) are written to ~/.rail in the user home directory, or to RAIL_DATA_DIR when that is set. They are local state, not part of the npm package. The default does not follow the process working directory, so a host that starts the server from / still writes under the home directory.

Example

Set a budget, propose a purchase, have a human approve it, then read the receipt. Dry-run moves no money off the machine.

  1. set_budget → { "amount_usd": 50, "note": "week1" }
  2. propose_purchase → { "merchant": "Acme", "amount_usd": 12, "rationale": "need widgets" }
  3. get_budget still shows remaining 50.00 and open_proposals: 1. The proposal is pending until a human decides.
  4. decide_proposal → { "proposal_id": "prop_…", "decision": "approve" }
  5. get_receipts returns one settled_dry_run receipt with a settlement_ref. Remaining budget is 38.00.

Rejecting spends nothing. refund_receipt reverses a dry-run settlement and restores the budget.

Tools

ToolPurpose
set_budgetOverwrite the local budget limit. Moves no money
get_budgetRead budget, spent, remaining, open proposals count
propose_purchaseRecord a pending intent only. Moves no money. Needs a later human approval
list_proposalsRead proposals by pending (default) / approved / rejected / all
decide_proposalHuman confirmation step. approve settles (dry-run receipt + settlement_ref, remaining decremented). reject spends nothing. No double-decide
get_receiptsRead receipts, newest first
refund_receiptHuman confirmation step. Reverse a dry-run settlement and restore budget

Permission model

Proposing a purchase is cheap. Settling one is not. An agent may record intent without moving money. The human should confirm the call that settles a purchase or reverses a receipt.

Hosts should read title, description, and annotations from tools/list. Every hint is set explicitly. The spec defaults (readOnlyHint false, destructiveHint true, openWorldHint true) would otherwise treat every tool as a destructive open-world write. Rail's ledger is local. Default mode is dry-run: no network and no charge.

ToolreadOnlyHintdestructiveHintidempotentHintopenWorldHintHost should
set_budgetfalsefalsetruefalseAllow. Overwrites the local limit only. The same arguments do not stack or spend
get_budgettruefalsetruefalseAllow. Read-only
propose_purchasefalsefalsefalsefalseAllow. Adds one pending intent and spends nothing. Each call creates a new proposal
list_proposalstruefalsetruefalseAllow. Read-only
decide_proposalfalsetruetruefalseConfirm with the human. approve settles and decrements remaining budget. A repeat does not settle again
get_receiptstruefalsetruefalseAllow. Read-only
refund_receiptfalsetruetruefalseConfirm with the human. Reverses a dry-run settlement and restores budget. A repeat does not refund again

destructiveHint is the confirmation signal, and it is true only for decide_proposal and refund_receipt. openWorldHint is false on every tool: dry-run never leaves the ledger, and live Link stays behind separate environment gates. Annotations are hints for the host. They do not themselves move money.

Mode defaults to RAIL_MODE=dry_run. Money is stored as integer cents; tools display USD with 2 decimals. IDs: prop_…, rcpt_…, dry-run Link refs lsrq_dry_… on settlement_ref.

Local checkout

tsx is a dev dependency for dogfood in this repo. npm run smoke runs the TypeScript sources directly and does not need a build. npm start compiles first, then runs dist/index.js (the same file the rail-mcp bin points at).

bash
npm installnpm start          # tsc → dist/, then stdio MCP servernpm run dev        # tsx watch src/index.tsnpm run smoke      # dry-run ledger smoke test; throwaway dirs only (never ./data, ~/.rail, or RAIL_DATA_DIR)

npm run smoke forces RAIL_MODE=dry_run, never enables live charge gates, and writes the ledger only under temporary directories it creates and deletes. ./data, ~/.rail, and RAIL_DATA_DIR are left untouched even when RAIL_DATA_DIR is set in the environment. One check starts the server with its working directory at / and HOME pointed at a temp directory, then calls a tool. That call succeeds, and the ledger for that check is created under the temp home rather than /data or the real ~/.rail. An explicit RAIL_DATA_DIR still overrides the default in that launch.

Stripe Link seam

Rail asks Link for a one-time credential. Rail still decides budget and policy and writes the receipt. This seam does not issue cards and does not render UI.

  • RAIL_MODE=dry_run (default, including when unset): createSpendRequest returns a fake Link spend-request id and status dry_run_pending_human. No Stripe or Link HTTP. Approve stores that id as settlement_ref on a settled_dry_run receipt and decrements remaining budget.
  • RAIL_MODE=live without gates: throws live mode not enabled — set keys and get explicit human approval unless both STRIPE_SECRET_KEY and RAIL_LIVE=1 are set. The proposal stays pending and no receipt is written.
  • Live with those two gates: the POST https://api.link.com/spend_requests body is scaffolded only (see src/stripeLink.ts). Nothing is sent unless RAIL_ALLOW_LIVE_CHARGE=1.
  • RAIL_ALLOW_LIVE_CHARGE=1: the only branch allowed to call Link, and only if LINK_ACCESS_TOKEN is also set. STRIPE_SECRET_KEY is a presence gate and is never sent. There is no Stripe Issuing card create. Docs: Link CLI, link-cli, Issuing for agents.
  • Live spend stays off until those env vars are set on purpose. A posted Link request is stored as link_pending_human and does not decrement the dry-run budget. CI and npm run smoke stay on dry-run and do not charge.
EnvRole
RAIL_MODEdry_run (default) or live
RAIL_DATA_DIRLedger directory. Default is ~/.rail in the user home directory. An explicit value overrides the default
STRIPE_SECRET_KEYRequired for live. Not used to issue cards or as a Link bearer token
RAIL_LIVE=1Explicit live approval alongside the secret key
RAIL_ALLOW_LIVE_CHARGE=1Additional gate before any Link HTTP
LINK_ACCESS_TOKENLink OAuth token. Required before the scaffolded POST actually runs

Explicit non-goals

  • No marketplace UI
  • No outreach / messaging
  • No card issuing
  • No real charges in dry-run, CI, or smoke

License

MIT. Copyright 2026 Thomas Stockham.

來源:README.md,提交 7190385

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.1最新Sep 29, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分