← Back to Pull requests

Let an AI agent propose transfers as a proposer, through an MCP server #18

Closed
unknown closed this pull request without merging on Oct 22, 2026 09:03 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 08:45 UTC
Author

<!-- claude-projects-attribution: {"github_login":"b3hr4d"} -->
_Requested by Behrad · project thread_

Before: a wallet had owners, approvers and viewers. An AI could only reach it by holding an owner's key, which can move funds, or a viewer's, which can ask for nothing.

After: an AI agent joins the wallet as a proposer. It reads the accounts, balances, open actions and audit log, and it proposes transfers. Its approval never counts, so every transfer it proposes waits for an owner or an approver on the Approvals page. That holds even under the daily limit, where an owner's own transfer goes through at once. mcp/ is an MCP server that runs on your Mac. Claude Code or Claude Desktop starts it, and it calls one wallet with the agent's own key, which it makes on first run. scripts/try-local.sh prints the claude mcp add command for the wallet it installs. You chose this as "Propose only" in the thread; it is recorded as [decision 0007](docs/decisions/0007-agent-proposer.md).

How:

  • Wallet. Role gains Proposer. propose takes owners and proposers. A proposer may propose only a Transfer, its proposal starts with no approvals, and it may have at most 8 actions open, so it cannot crowd the owners out of the 64. approve, execute, reject and add_account keep their guards.

  • Joining. request_join takes a trailing opt Role, which may be Viewer or Proposer. A call with one argument still asks to be a viewer, and a test still makes such calls.

  • Pages. The Approvals page says which role a join request asks for. It names who proposed an action by label and role, such as "“Claude”, a proposer", reading members for that. A proposer can use the Send page, which says the transfer waits for approval.

  • MCP server. mcp/ has seven tools: wallet_whoami, wallet_join (returns the 8-digit code), wallet_accounts, wallet_balance, wallet_activity (the audit log), wallet_pending and wallet_propose_transfer (a decimal amount in the token's units). None approves, runs or rejects. Reads are certified replicated calls, as on the pages.

  • - The key is a PKCS #8 Ed25519 PEM at ~/.config/b3wallet-mcp/agent.pem, mode 0600, and the server refuses a key file others can read. icp-cli imports the same file and shows the same principal.
    - The protocol (JSON-RPC over stdio, tools only) is written in mcp/src/protocol.ts rather than taken from the SDK. That way the process holding the key runs only this code and the IC libraries the pages already use.
    - CI gets an mcp job.

    Worth your review

  • The interface changes for other clients. A client built before this PR that reads members or whoami cannot decode a Proposer role, which it does not know. The pages ship with the wallet, so they are fine. Your own scripts are affected only once a proposer has joined.

  • Behaviour change: a viewer or an approver calling propose used to be refused with "only an owner can do this" and now gets "only an owner or a proposer can do this".

  • history is in candid/wallet.did but not in the wallet yet. The first version of the server offered it, and Claude's local run below hit "Canister has no update method 'history'". The server reads audit_log instead. A test now reads the wallet's exported methods from canisters/wallet/src/lib.rs and fails if a tool calls any other. The fake replica answers whatever the interface file names, which is how the first version slipped through.

  • A stolen agent key can read the wallet and propose up to 8 transfers you can reject. It cannot move funds. The design's security table has a row for it.
  • Tests.

  • Two new PocketIC tests, and one updated:

  • - A proposer's transfer under the daily limit waits for an owner. Its other actions are refused, and its 9th open proposal is refused.
    - A join request asks only to be a viewer or a proposer.
    - The role test now covers a proposer.
  • Each test fails with its check taken out. Five faults were checked: a proposer's approval counting, a proposer proposing any action, no cap, any role in a join request, and a viewer passing the proposer guard.

  • 14 MCP tests run the tools against ic-reactor's fake replica. Six faults were checked there: joining as a viewer, an amount in base units, an extra argument accepted, a key file readable by others or made 0644, and an approve tool added. One UI test covers the role in a join request.
  • Real Claude, local network. I ran Claude Code (claude -p) with only this server against a wallet try-local.sh installed:
    1. Claude called wallet_whoami, then wallet_join. It told me the code 2052 5840, which matches the SHA-256 code of its principal.
    2. As the owner, I approved and ran the join.
    3. Asked to send 1.5 ICP and "approve and send it yourself", Claude read the balance (10 ICP) and proposed action 2. It said it could not approve, since its approval never counts.
    4. The owner's execute before approving got QuorumNotMet { approvals: 0, quorum: 1 }.
    5. With the agent's key in icp-cli, approve, execute, reject and add_account were refused by their guards. Proposing ChangeRole to make itself an owner got Forbidden: a proposer proposes only transfers.
    6. The owner approved and ran it, and the account then held 8.4999 ICP.
    7. Asked whether it went through, Claude read wallet_activity and saw the owner's approval and execution.

    The whole CI battery passes locally:

  • the ui and mcp jobs' steps

  • the unit tests and the interface check

  • the PocketIC tests, with the upgrade from main's wallet
  • ---
    _Generated by Claude Code_

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: b3hr4d Review duration: 17m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #18"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%