felix-mcp 2.0.133 → 2.0.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Non-custodial trading tools for AI agents across Hyperliquid, Polymarket, and
8
8
  Derive. Live execution is the default; paper mode must be selected explicitly.
9
9
 
10
- Package version: `felix-mcp@2.0.133`. For prepublication review, use the local
10
+ Package version: `felix-mcp@2.0.134`. For prepublication review, use the local
11
11
  tarball below. Packaging checks do not certify live money workflows.
12
12
 
13
13
  ## Hosted (no install)
@@ -48,14 +48,14 @@ node --version
48
48
  npm ci
49
49
  candidate_dir="$(mktemp -d)"
50
50
  npm pack --pack-destination "$candidate_dir"
51
- npm install --global "$candidate_dir/felix-mcp-2.0.133.tgz"
51
+ npm install --global "$candidate_dir/felix-mcp-2.0.134.tgz"
52
52
  felix-keys --help
53
53
  ```
54
54
 
55
55
  After the operator publishes this version, the registry installation is:
56
56
 
57
57
  ```bash
58
- npm install --global felix-mcp@2.0.133
58
+ npm install --global felix-mcp@2.0.134
59
59
  ```
60
60
 
61
61
  ### 2. Set up keys locally
@@ -393,15 +393,36 @@ Safe; it does not retrieve venue balances.
393
393
  | Arc home Safe deposit from another chain (`arc_home_deposit`) | Not certified on this candidate; new accounts use `create_deposit` |
394
394
  | Fund Derive | Not certified; do not start a new operation |
395
395
  | Return Hyperliquid perps to the Arc home (`arc_home_hypercore_return`) | Available (the app's route) |
396
- | Return from other venues | Not available from the MCP in this release; use Wallet in the Felix app |
396
+ | Return from other venues to the Arc home | Not available from the MCP in this release; use Wallet in the Felix app |
397
397
  | Withdraw owner-wallet or Safe funds to an approved address | Available; does not pull funds from a venue |
398
398
  | Arc transfer between Gateway domains | Not certified; recover existing operations only |
399
- | Direct venue-to-venue movement | Not certified |
399
+ | Move free cash between Hyperliquid, Polymarket and Lighter (`transfer_between_venues`) | Available (the app's Transfer) |
400
400
 
401
401
  An unsupported action is not necessarily blocked by the current API. This
402
402
  table is a safety boundary for this candidate, not a claim that the server
403
403
  always refuses before movement.
404
404
 
405
+ ### Venue-to-venue transfers
406
+
407
+ `transfer_between_venues` moves free cash straight from one venue to another
408
+ (Hyperliquid, Polymarket, Lighter), the same Transfer the Felix app uses. Felix
409
+ signs it; only the owner's own venue accounts and Trading wallet are paid, and
410
+ open orders, positions and running agents keep their cash. Give `amount_usd`,
411
+ or `all_free_cash:true` to move everything that is free. One `idempotency_key`
412
+ is one transfer: a retry with the same key returns the same transfer.
413
+
414
+ ```text
415
+ preview_venue_transfer(from_venue="hyperliquid", to_venue="polymarket", amount_usd=20)
416
+ transfer_between_venues(from_venue="hyperliquid", to_venue="polymarket", amount_usd=20,
417
+ idempotency_key="hl-to-pm-1", wait_seconds=60)
418
+ get_venue_transfer(transfer_id="...")
419
+ ```
420
+
421
+ States are `sending`, `completed`, `partial`, `failed` and `needs_review`. Never
422
+ start another transfer from a venue while one is `sending` or `needs_review`;
423
+ `list_venue_transfers(open_only=true)` shows any still moving. In an account
424
+ session the start goes out on the local launcher key for the selected account.
425
+
405
426
  Use:
406
427
 
407
428
  - `preview_funding_route`: read-only Polygon-to-Hyperliquid Relay quote with
@@ -630,7 +651,8 @@ interrupted message with the same key.
630
651
  - Portfolio: `get_situation`, `get_positions`, `get_fills`,
631
652
  `get_account_statement`, `get_pnl`,
632
653
  `get_money_map`, `verify_custody`.
633
- - Money: funding, bring-home, fee-credit, withdrawal, and venue onboarding tools.
654
+ - Money: funding, venue-to-venue transfers, bring-home, withdrawal, and venue
655
+ onboarding tools.
634
656
  - Agents: strategy guide, backtest, walk-forward validation, deploy, status,
635
657
  logs, events, update, stop.
636
658
  - Account: keys, children, policy, webhooks, subscription, support, and archive.
@@ -18,7 +18,7 @@ then creates the identity and loads it into the session with no restart.
18
18
  Or let your AI agent run this single command:
19
19
 
20
20
  ~~~bash
21
- npx -y --package felix-mcp@2.0.133 felix-keys onboard --accept-terms --client claude
21
+ npx -y --package felix-mcp@2.0.134 felix-keys onboard --accept-terms --client claude
22
22
  ~~~
23
23
 
24
24
  After the user reviews the terms and explicitly authorizes acceptance, the agent
@@ -333,6 +333,10 @@ Web equivalents:
333
333
  use place_order with paper:true.
334
334
  7. get_situation, positions, and fills: reconcile before another action.
335
335
 
336
+ Cash already on one venue can move to another without going back through the
337
+ Arc home: preview_venue_transfer, then transfer_between_venues (Hyperliquid,
338
+ Polymarket, Lighter; open orders and positions keep their cash).
339
+
336
340
  For a timeout or unknown order result, reuse the same idempotency key and
337
341
  reconcile. Never create a replacement key until the original intent is known.
338
342
 
package/dist/index.js CHANGED
@@ -126,7 +126,7 @@ export function validatedApiBase(raw = process.env.FELIX_API_URL || `https://${O
126
126
  return parsed.origin;
127
127
  }
128
128
  const API = validatedApiBase();
129
- const MCP_VERSION = "2.0.133";
129
+ const MCP_VERSION = "2.0.134";
130
130
  const AES_GCM_IV_BYTES = 12;
131
131
  const AES_GCM_TAG_BYTES = 16;
132
132
  const MAX_MONEY_JOURNAL_BYTES = 16 * 1024 * 1024;
@@ -2840,7 +2840,13 @@ async function arcHomeOwnerKeyFor(accountId) {
2840
2840
  async function arcHomeCall(method, path, body, opts = {}) {
2841
2841
  // A child session's Arc home money calls go out on the launcher credential for that child (Astra mcploop r2:
2842
2842
  // the child's read/trade key got 403 'transfer' on an implicit arc_home_withdraw).
2843
- const accountId = opts.accountId || activeChildAccountId();
2843
+ // Opus QA r15: that launcher credential could act on ANY owned account, so an explicit account_id for a different
2844
+ // account than the session's is refused here exactly like call()'s child-management guard, never retargeted.
2845
+ const selected = activeChildAccountId();
2846
+ if (selected && opts.accountId && opts.accountId.toLowerCase() !== selected.toLowerCase()) {
2847
+ return clientError("account_mismatch", "This session is working on a different account than the account_id you passed. Nothing was sent.", "Omit account_id to act on the selected account, or call use_child_account with the other account first.", { selected_account_id: selected, money_moved: false });
2848
+ }
2849
+ const accountId = opts.accountId || selected;
2844
2850
  const targetPath = accountId && method === "GET" ? withTargetAccountQuery(path, accountId) : path;
2845
2851
  const targetBody = accountId && method === "POST" ? { ...(body || {}), account_id: accountId } : body;
2846
2852
  return call(method, targetPath, targetBody, {
@@ -3785,6 +3791,139 @@ export function withNewAccountNextStep(name, out, args = {}) {
3785
3791
  }
3786
3792
  return out;
3787
3793
  }
3794
+ // VENUE_TRANSFERS_2026_11_18: venue-to-venue transfers (engine services/agent_capital/venue_transfers.py).
3795
+ const VENUE_TRANSFER_VENUE_INPUTS = ["hyperliquid", "polymarket", "lighter", "prediction_market"];
3796
+ // Opus QA r16 F7: no "crypto" alias; Lighter is a crypto venue too. prediction_market is the engine's own alias.
3797
+ const VENUE_TRANSFER_ALIASES = {
3798
+ hyperliquid: "hyperliquid", polymarket: "polymarket", prediction_market: "polymarket", lighter: "lighter",
3799
+ };
3800
+ const VENUE_TRANSFER_NAMES = { hyperliquid: "Hyperliquid", polymarket: "Polymarket", lighter: "Lighter" };
3801
+ const VENUE_TRANSFER_FINAL = new Set(["completed", "partial", "failed", "needs_review"]);
3802
+ const VENUE_TRANSFER_STATES = new Set(["sending", ...VENUE_TRANSFER_FINAL]);
3803
+ const VENUE_TRANSFER_POLL_MS = 2_000;
3804
+ export function venueTransferVenue(value) {
3805
+ const key = typeof value === "string" ? value.trim().toLowerCase() : "";
3806
+ return Object.hasOwn(VENUE_TRANSFER_ALIASES, key) ? VENUE_TRANSFER_ALIASES[key] : undefined;
3807
+ }
3808
+ /** money_moved for a transfer record, from the engine's own state machine (venue_transfers.advance). */
3809
+ export function venueTransferMoneyMoved(state) {
3810
+ if (state === "completed" || state === "partial")
3811
+ return true;
3812
+ if (state === "failed")
3813
+ return false;
3814
+ return "unknown";
3815
+ }
3816
+ /** Adds the outcome fields an agent needs to a parsed transfer; never invents engine state. */
3817
+ export function describeVenueTransfer(transfer) {
3818
+ const state = String(transfer.state);
3819
+ const from = VENUE_TRANSFER_NAMES[String(transfer.from_venue)] ?? String(transfer.from_venue);
3820
+ const to = VENUE_TRANSFER_NAMES[String(transfer.to_venue)] ?? String(transfer.to_venue);
3821
+ const next = state === "sending"
3822
+ ? `Still moving. Poll get_venue_transfer with this transfer_id; do not start another transfer from ${from}.`
3823
+ : state === "completed"
3824
+ ? `Done: the cash is on ${to}.`
3825
+ : state === "partial"
3826
+ ? "Part of this transfer finished; message says where the cash is. It is safe in the owner's own accounts; "
3827
+ + "see get_money_map before moving it again."
3828
+ : state === "needs_review"
3829
+ ? "Felix is confirming a step. The money is safe and nothing will move twice. Do not retry; check "
3830
+ + "get_venue_transfer later."
3831
+ : "Nothing moved. A new transfer needs a new idempotency_key.";
3832
+ return { transfer, state, final: VENUE_TRANSFER_FINAL.has(state), money_moved: venueTransferMoneyMoved(state),
3833
+ next_action: next };
3834
+ }
3835
+ /** Validated venue-transfer arguments and the engine body, or the local refusal (nothing sent). */
3836
+ function venueTransferArgs(a) {
3837
+ const from = venueTransferVenue(a.from_venue);
3838
+ const to = venueTransferVenue(a.to_venue);
3839
+ const hasAmount = a.amount_usd !== undefined && a.amount_usd !== null;
3840
+ const amount = hasAmount ? arcHomeUnits(a.amount_usd, "amount_usd") : undefined;
3841
+ const bad = validateOptionalAccountId(a)
3842
+ || (!from ? clientError("invalid_argument", "from_venue must be hyperliquid, polymarket or lighter.") : undefined)
3843
+ || (!to ? clientError("invalid_argument", "to_venue must be hyperliquid, polymarket or lighter.") : undefined)
3844
+ || (from && from === to ? clientError("same_venue", "Pick two different venues.") : undefined)
3845
+ || (amount !== undefined && typeof amount !== "bigint" ? amount : undefined)
3846
+ || (typeof amount === "bigint" && amount <= 0n
3847
+ ? clientError("invalid_argument", "amount_usd must be greater than 0.") : undefined)
3848
+ || (a.all_free_cash !== undefined && typeof a.all_free_cash !== "boolean"
3849
+ ? clientError("invalid_argument", "all_free_cash must be true or false.") : undefined)
3850
+ || (hasAmount && a.all_free_cash === true
3851
+ ? clientError("invalid_argument", "Give amount_usd or all_free_cash:true, not both.") : undefined);
3852
+ if (bad || !from || !to)
3853
+ return { bad: { ...(bad ?? {}), money_moved: false } };
3854
+ return { from, to, hasAmount, requestBody: {
3855
+ ...(a.account_id ? { account_id: a.account_id } : {}),
3856
+ from_venue: from, to_venue: to,
3857
+ ...(hasAmount ? { amount_usd: Number(a.amount_usd) } : {}),
3858
+ } };
3859
+ }
3860
+ /** A transfer record shaped like the engine's public_transfer, or undefined (app parseVenueTransfer). */
3861
+ export function parseVenueTransferRecord(value) {
3862
+ if (!isRecord(value))
3863
+ return undefined;
3864
+ if (typeof value.transfer_id !== "string" || !UUID_RE.test(value.transfer_id))
3865
+ return undefined;
3866
+ if (!venueTransferVenue(value.from_venue) || !venueTransferVenue(value.to_venue))
3867
+ return undefined;
3868
+ if (typeof value.state !== "string" || !VENUE_TRANSFER_STATES.has(value.state))
3869
+ return undefined;
3870
+ return value;
3871
+ }
3872
+ const VENUE_TRANSFER_REFUSAL_HINTS = {
3873
+ insufficient_free_cash: "Pass a smaller amount_usd, or all_free_cash:true to move what is free. Open orders, "
3874
+ + "positions and running agents keep their cash.",
3875
+ below_transfer_minimum: "Transfers start at minimum_usd. Move at least that much, or add cash to the source venue first.",
3876
+ transfer_in_progress: "Another transfer from this venue is still moving. Wait for it: list_venue_transfers with open_only:true.",
3877
+ venue_cash_unreadable: "The venue balance is updating. Retry in a moment with the same idempotency_key.",
3878
+ polymarket_return_not_ready: "Polymarket cash cannot move out yet. Retry later with the same idempotency_key.",
3879
+ idempotency_conflict: "This idempotency_key already belongs to another transfer: read it first with "
3880
+ + "get_venue_transfer(existing_transfer_id); it may still be moving. Use a new idempotency_key only for a "
3881
+ + "genuinely different transfer.",
3882
+ agent_capital_not_enabled: "Transfers between venues are not available on this account yet. Fund a venue from the "
3883
+ + "Arc home with fund_hypercore_from_arc or fund_polymarket_from_arc instead.",
3884
+ unsupported_venue: "Transfers move between hyperliquid, polymarket and lighter.",
3885
+ same_venue: "Pick two different venues.",
3886
+ invalid_amount: "amount_usd must be a positive USDC amount.",
3887
+ };
3888
+ /** A refused preview/start (engine 400/409 TransferRefused): keep the engine's words, add the next step. */
3889
+ export function withVenueTransferRefusalHint(out) {
3890
+ if (out.ok !== false || !isRecord(out.error))
3891
+ return out;
3892
+ const error = out.error;
3893
+ const code = String(error.reason ?? error.code ?? "");
3894
+ const message = String(error.message ?? "");
3895
+ if (/lacks the '(?:transfer|read)' scope/.test(message)) {
3896
+ return { ...out, error: { ...error, hint: "This key cannot move money between venues. Use the owner's local "
3897
+ + "launcher session (use_child_account selects the account), or Transfer in the Felix app. This request moved no money." },
3898
+ money_moved: false };
3899
+ }
3900
+ const hint = VENUE_TRANSFER_REFUSAL_HINTS[code]
3901
+ ?? (/_order_in_flight$/.test(code)
3902
+ ? "An order on the source venue is still settling. Retry in a moment with the same idempotency_key." : undefined);
3903
+ if (!hint)
3904
+ return out;
3905
+ return { ...out, error: { ...error, hint: `${hint} This request moved no money.` }, money_moved: false };
3906
+ }
3907
+ /** Opus QA r16 F1/F3: a failed start that is not a definite engine refusal never claims nothing moved. */
3908
+ export function withVenueTransferFailureOutcome(out) {
3909
+ if (out.ok !== false || !isRecord(out.error))
3910
+ return out;
3911
+ const error = out.error;
3912
+ const code = String(error.reason ?? error.code ?? "");
3913
+ // Arc admission paused for a release: the engine refused before admission. Keep its own words and retry advice.
3914
+ if (code === "arc_admission_frozen")
3915
+ return { ...out, money_moved: false };
3916
+ const meta = isRecord(out._meta) ? out._meta : {};
3917
+ const status = finiteNumber(meta.http_status);
3918
+ const definite = status !== undefined && status >= 400 && status < 500 && status !== 408 && status !== 429
3919
+ && code !== "idempotency_in_progress";
3920
+ return {
3921
+ ...out,
3922
+ error: { ...error, hint: "Retry with the same idempotency_key: it never starts a second transfer. Check "
3923
+ + "list_venue_transfers before using a new key." },
3924
+ ...(definite ? {} : { money_moved: "unknown", outcome_unknown: true }),
3925
+ };
3926
+ }
3788
3927
  function isChildManagementRequest(method, path) {
3789
3928
  const pathname = path.split("?", 1)[0];
3790
3929
  if (method === "GET" || method === "DELETE") {
@@ -3805,6 +3944,9 @@ function isChildManagementRequest(method, path) {
3805
3944
  return pathname === "/v1/referrals"
3806
3945
  // Owner-signed venue bootstrap (routes_agent_capital.py: require("manage"), money_context(account_id)).
3807
3946
  || pathname.startsWith("/v1/agent-capital/venue-bootstrap/")
3947
+ // Venue-to-venue transfer start needs "transfer" (routes_agent_capital.py create_transfer, money_context), which
3948
+ // the account's read/trade key lacks. Preview and reads need only "read" and stay on the account's key.
3949
+ || pathname === "/v1/agent-capital/transfers"
3808
3950
  || pathname === "/v1/fund"
3809
3951
  || pathname === "/v1/bring-home"
3810
3952
  || pathname === "/v1/withdraw"
@@ -11750,6 +11892,7 @@ const TOOL_RISK_GROUPS = {
11750
11892
  read: [
11751
11893
  "get_capital_move_recovery", "preview_home_funding", "get_home_funding", "get_withdrawal_confirmation",
11752
11894
  "get_arc_home_operation", "get_agent_capital", "preview_capital_move", "get_capital_move",
11895
+ "preview_venue_transfer", "get_venue_transfer", "list_venue_transfers",
11753
11896
  "get_status", "get_health", "get_metrics", "get_custody_recovery_status", "get_strategy_guide",
11754
11897
  "get_market_streaming_guide",
11755
11898
  "search_markets", "list_markets", "search_tokens", "inspect_token_risk",
@@ -11793,7 +11936,7 @@ const TOOL_RISK_GROUPS = {
11793
11936
  ],
11794
11937
  money: [
11795
11938
  "start_home_funding", "prepare_capital_allocation", "submit_capital_allocation", "submit_venue_bootstrap",
11796
- "start_capital_move",
11939
+ "start_capital_move", "transfer_between_venues",
11797
11940
  "resolve_network_fee", "swap_native_usdc", "fund_market",
11798
11941
  "start_fund_market", "bring_home", "start_bring_home", "resume_money_operation",
11799
11942
  "start_arc_home_hl_return", "fund_hypercore_from_arc", "arc_home_hypercore_return", "invalidate_safe_nonce",
@@ -12066,7 +12209,7 @@ export async function executeSafeInvalidation(writer, operationId, expectedNonce
12066
12209
  }
12067
12210
  const LIVE_MONEY_TOOLS = new Set([
12068
12211
  "submit_capital_allocation", "submit_venue_bootstrap",
12069
- "start_capital_move",
12212
+ "start_capital_move", "transfer_between_venues",
12070
12213
  "place_order", "place_batch_orders", "close_position", "make_market",
12071
12214
  "place_manual_order", "close_manual_position", "modify_order_price",
12072
12215
  "swap_native_usdc", "fund_market", "start_fund_market",
@@ -12995,6 +13138,47 @@ const TOOLS = [
12995
13138
  account_id: stringProp("Optional owned child account UUID.", undefined, { pattern: UUID_RE.source }),
12996
13139
  }, ["move_id"]),
12997
13140
  },
13141
+ // VENUE_TRANSFERS_2026_11_18 (engine routes_agent_capital.py /v1/agent-capital/transfers, app lib/venueTransfers.ts).
13142
+ {
13143
+ name: "preview_venue_transfer",
13144
+ description: "Read-only preview of moving free cash straight from one venue to another (Hyperliquid, Polymarket, Lighter), like Transfer in the Felix app: free cash on the source, the minimum, the route (front: the destination is funded at once from the Trading wallet; chain: through the Trading wallet) and an ETA in seconds. Omit amount_usd to preview all free cash. Open orders, positions and running agents keep their cash. Creates, reserves and signs nothing.",
13145
+ inputSchema: schema({
13146
+ from_venue: stringProp("Venue the money leaves.", [...VENUE_TRANSFER_VENUE_INPUTS]),
13147
+ to_venue: stringProp("Venue the money arrives on.", [...VENUE_TRANSFER_VENUE_INPUTS]),
13148
+ amount_usd: numberProp("USDC amount, at most six decimal places. Omit to preview all free cash.", 0.000001),
13149
+ account_id: stringProp("Optional owned child account UUID. Omit for the active account.", undefined, { pattern: UUID_RE.source }),
13150
+ }, ["from_venue", "to_venue"]),
13151
+ },
13152
+ {
13153
+ name: "transfer_between_venues",
13154
+ description: "LIVE: move the account's free cash from one venue to another (Hyperliquid, Polymarket, Lighter), exactly like Transfer in the Felix app. Felix signs it; no owner signature. Only the owner's own venue accounts and Trading wallet are paid, and open orders, positions and running agents keep their cash. Give exactly one of amount_usd or all_free_cash:true. Reuse the same idempotency_key to retry: it always returns the same transfer, never a second one. Most transfers finish in seconds to a few minutes (Lighter withdrawals can take longer). Set wait_seconds to wait for the result, or poll get_venue_transfer. Never start another transfer while one is sending or needs review.",
13155
+ inputSchema: schema({
13156
+ from_venue: stringProp("Venue the money leaves.", [...VENUE_TRANSFER_VENUE_INPUTS]),
13157
+ to_venue: stringProp("Venue the money arrives on.", [...VENUE_TRANSFER_VENUE_INPUTS]),
13158
+ amount_usd: numberProp("USDC amount, at most six decimal places. Omit only with all_free_cash:true.", 0.000001),
13159
+ all_free_cash: booleanProp("true moves all free cash on from_venue. Use instead of amount_usd."),
13160
+ idempotency_key: stringProp("Required, 8 to 128 printable characters. One key per transfer; reuse it after any timeout."),
13161
+ wait_seconds: integerProp("Optional: wait up to this many seconds (0 to 120) for a final state. Default 0.", 0, 120),
13162
+ account_id: stringProp("Optional owned child account UUID. Omit for the active account.", undefined, { pattern: UUID_RE.source }),
13163
+ }, ["from_venue", "to_venue", "idempotency_key"]),
13164
+ },
13165
+ {
13166
+ name: "get_venue_transfer",
13167
+ description: "Read one venue-to-venue transfer: state (sending, completed, partial, failed, needs_review), phase, the plain-language message, amounts credited and received. Read-only; never starts or retries a transfer.",
13168
+ inputSchema: schema({
13169
+ transfer_id: stringProp("transfer_id from transfer_between_venues.", undefined, { pattern: UUID_RE.source }),
13170
+ account_id: stringProp("Optional owned child account UUID. Omit for the active account.", undefined, { pattern: UUID_RE.source }),
13171
+ }, ["transfer_id"]),
13172
+ },
13173
+ {
13174
+ name: "list_venue_transfers",
13175
+ description: "The account's latest venue-to-venue transfers, newest first (for example one still sending after a restart). Read-only.",
13176
+ inputSchema: schema({
13177
+ open_only: booleanProp("true lists only transfers still sending."),
13178
+ limit: integerProp("How many to return, 1 to 20. Default 10.", 1, 20),
13179
+ account_id: stringProp("Optional owned child account UUID. Omit for the active account.", undefined, { pattern: UUID_RE.source }),
13180
+ }),
13181
+ },
12998
13182
  {
12999
13183
  name: "get_network_fee_status",
13000
13184
  description: "Inspect an interrupted funding network-fee workflow. New funding pays and confirms the fee before any venue transfer; this tool exists only to reconcile a legacy or interrupted obligation without paying twice.",
@@ -16500,6 +16684,126 @@ export function makeServer() {
16500
16684
  || await call("GET", `/v1/agent-capital/moves/${encodeURIComponent(String(a.move_id))}${qs({ account_id: a.account_id })}`);
16501
16685
  break;
16502
16686
  }
16687
+ case "preview_venue_transfer": {
16688
+ const parsed = venueTransferArgs(a);
16689
+ if (!("requestBody" in parsed)) {
16690
+ out = parsed.bad;
16691
+ break;
16692
+ }
16693
+ const { from, to, hasAmount, requestBody } = parsed;
16694
+ const preview = await call("POST", "/v1/agent-capital/transfers/preview", requestBody, { retryOnError: false });
16695
+ if (preview.ok === false) {
16696
+ out = withVenueTransferRefusalHint(preview);
16697
+ break;
16698
+ }
16699
+ if (preview.from_venue !== from || preview.to_venue !== to) {
16700
+ out = clientError("transfer_preview_unreadable", "Felix returned a preview for different venues. Nothing moved.", "Retry preview_venue_transfer.", { money_moved: false });
16701
+ break;
16702
+ }
16703
+ out = { ...preview, money_moved: false, signed: false, operation_created: false,
16704
+ next_action: "To move it, call transfer_between_venues with the same venues and "
16705
+ + (hasAmount ? "amount_usd" : "all_free_cash:true") + " and a new idempotency_key." };
16706
+ break;
16707
+ }
16708
+ case "transfer_between_venues": {
16709
+ const parsed = venueTransferArgs(a);
16710
+ if (!("requestBody" in parsed)) {
16711
+ out = parsed.bad;
16712
+ break;
16713
+ }
16714
+ const { from, to, hasAmount, requestBody } = parsed;
16715
+ // An omitted amount moves ALL free cash on the engine; that must be an explicit choice here.
16716
+ if (!hasAmount && a.all_free_cash !== true) {
16717
+ out = clientError("missing_argument", "Give amount_usd, or all_free_cash:true to move all free cash.", "preview_venue_transfer shows how much is free. Nothing moved.", { money_moved: false });
16718
+ break;
16719
+ }
16720
+ const key = requiredWorkflowKey(a);
16721
+ if (!key || key.length < 8) {
16722
+ out = clientError("missing_argument", "idempotency_key is required (8 to 128 printable characters).", "Use one new key per transfer and reuse it after any timeout. Nothing moved.", { money_moved: false });
16723
+ break;
16724
+ }
16725
+ const waitMs = Math.min(120, Math.max(0, Math.floor(Number(a.wait_seconds) || 0))) * 1_000;
16726
+ const deadline = Date.now() + waitMs;
16727
+ const start = () => call("POST", "/v1/agent-capital/transfers", requestBody, { idempotent: true, idempotencyKey: key, timeoutMs: 60_000 });
16728
+ let started = await start();
16729
+ // Arc admission frozen (engine release): the request is queued with nothing moved; the same key replays it.
16730
+ while (started.ok !== false && started.queued === true && Date.now() + VENUE_TRANSFER_POLL_MS < deadline) {
16731
+ await sleep(VENUE_TRANSFER_POLL_MS);
16732
+ started = await start();
16733
+ }
16734
+ if (started.ok === false) {
16735
+ const refused = withVenueTransferRefusalHint(started);
16736
+ out = refused !== started ? refused : withVenueTransferFailureOutcome(started);
16737
+ break;
16738
+ }
16739
+ if (started.queued === true) {
16740
+ const executing = started.status === "executing";
16741
+ out = { ...started, money_moved: executing ? "unknown" : false, state: executing ? "executing" : "queued",
16742
+ next_action: "Felix accepted the transfer and starts it in a moment. Call transfer_between_venues again "
16743
+ + "with the same arguments and idempotency_key to get the transfer." };
16744
+ break;
16745
+ }
16746
+ let transfer = parseVenueTransferRecord(started.transfer);
16747
+ const receiptAmount = transfer ? finiteNumber(transfer.amount_usd) : undefined;
16748
+ const amountMismatch = hasAmount && receiptAmount !== undefined
16749
+ && Math.abs(receiptAmount - Number(a.amount_usd)) > 0.0000005;
16750
+ if (!transfer || transfer.from_venue !== from || transfer.to_venue !== to || amountMismatch) {
16751
+ out = clientError("transfer_receipt_mismatch", "The transfer receipt did not match this request, so its outcome is not confirmed.", "Do not use a new idempotency_key. Check list_venue_transfers, or retry with the same key.", { money_moved: "unknown", outcome_unknown: true });
16752
+ break;
16753
+ }
16754
+ while (!VENUE_TRANSFER_FINAL.has(String(transfer.state)) && Date.now() + VENUE_TRANSFER_POLL_MS < deadline) {
16755
+ await sleep(VENUE_TRANSFER_POLL_MS);
16756
+ const read = await call("GET", `/v1/agent-capital/transfers/${encodeURIComponent(String(transfer.transfer_id))}`
16757
+ + qs({ account_id: a.account_id }));
16758
+ const latest = read.ok === false ? undefined : parseVenueTransferRecord(read.transfer);
16759
+ if (latest && latest.transfer_id === transfer.transfer_id)
16760
+ transfer = latest;
16761
+ }
16762
+ out = { ok: true, ...describeVenueTransfer(transfer), idempotency_key: key,
16763
+ ...(waitMs > 0 ? { wait_completed: VENUE_TRANSFER_FINAL.has(String(transfer.state)) } : {}) };
16764
+ break;
16765
+ }
16766
+ case "get_venue_transfer": {
16767
+ const bad = validateOptionalAccountId(a) || validateUuid(a, "transfer_id");
16768
+ if (bad) {
16769
+ out = bad;
16770
+ break;
16771
+ }
16772
+ const read = await call("GET", `/v1/agent-capital/transfers/${encodeURIComponent(String(a.transfer_id))}`
16773
+ + qs({ account_id: a.account_id }));
16774
+ if (read.ok === false) {
16775
+ out = read;
16776
+ break;
16777
+ }
16778
+ const transfer = parseVenueTransferRecord(read.transfer);
16779
+ out = transfer && String(transfer.transfer_id).toLowerCase() === String(a.transfer_id).toLowerCase()
16780
+ ? { ok: true, ...describeVenueTransfer(transfer) }
16781
+ : clientError("transfer_unreadable", "Felix returned an unreadable transfer.", "Retry shortly.");
16782
+ break;
16783
+ }
16784
+ case "list_venue_transfers": {
16785
+ const bad = validateOptionalAccountId(a)
16786
+ || (a.open_only !== undefined && typeof a.open_only !== "boolean"
16787
+ ? clientError("invalid_argument", "open_only must be true or false.") : undefined)
16788
+ || (a.limit !== undefined && (!Number.isInteger(a.limit) || Number(a.limit) < 1 || Number(a.limit) > 20)
16789
+ ? clientError("invalid_argument", "limit must be a whole number from 1 to 20.") : undefined);
16790
+ if (bad) {
16791
+ out = bad;
16792
+ break;
16793
+ }
16794
+ const read = await call("GET", `/v1/agent-capital/transfers${qs({ account_id: a.account_id,
16795
+ open_only: a.open_only === true ? "true" : undefined, limit: a.limit })}`);
16796
+ if (read.ok === false) {
16797
+ out = read;
16798
+ break;
16799
+ }
16800
+ const rows = Array.isArray(read.transfers) ? read.transfers : [];
16801
+ const transfers = rows.map(parseVenueTransferRecord).filter((row) => row !== undefined)
16802
+ .map(describeVenueTransfer);
16803
+ out = { ok: true, transfers, count: transfers.length,
16804
+ any_sending: transfers.some((row) => row.state === "sending") };
16805
+ break;
16806
+ }
16503
16807
  case "get_network_fee_status":
16504
16808
  if (a.account_id !== undefined && validateUuid(a, "account_id")) {
16505
16809
  out = validateUuid(a, "account_id");
@@ -16702,10 +17006,19 @@ export function makeServer() {
16702
17006
  out = clientError("invalid_argument", "reconcile must be a boolean when provided.");
16703
17007
  break;
16704
17008
  }
16705
- const plainRead = a.reconcile === false;
16706
- const result = plainRead
17009
+ let plainRead = a.reconcile === false;
17010
+ let reconcileSkipped = false;
17011
+ let result = plainRead
16707
17012
  ? await call("GET", `/v1/settlement/operations/${enc(operationId)}`)
16708
17013
  : await call("POST", `/v1/settlement/transfers/${enc(operationId)}/reconcile`, undefined, { retryOnError: false, timeoutMs: 30_000 });
17014
+ // Opus QA r15: the reconcile step needs manage+transfer (engine routes_settlement.py reconcile_transfer) and
17015
+ // only advances the caller's own journey; an account's read/trade key gets 403. Fall back to the read-scope view.
17016
+ if (!plainRead && result.ok === false && isRecord(result.error)
17017
+ && /lacks the '(?:manage|transfer)' scope/.test(String(result.error.message ?? ""))) {
17018
+ plainRead = true;
17019
+ reconcileSkipped = true;
17020
+ result = await call("GET", `/v1/settlement/operations/${enc(operationId)}`);
17021
+ }
16709
17022
  if (result.ok === false) {
16710
17023
  out = result;
16711
17024
  break;
@@ -16723,6 +17036,8 @@ export function makeServer() {
16723
17036
  source_transaction_hash: operation.source_transaction_hash ?? null,
16724
17037
  destination_transaction_hash: operation.destination_transaction_hash ?? null,
16725
17038
  operation,
17039
+ ...(reconcileSkipped ? { reconciled: false,
17040
+ note: "This key cannot run the reconcile step, so this is the plain read. Felix advances the journey on its own." } : {}),
16726
17041
  };
16727
17042
  break;
16728
17043
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "felix-mcp",
3
- "version": "2.0.133",
3
+ "version": "2.0.134",
4
4
  "mcpName": "trade.felix/mcp",
5
5
  "description": "Non-custodial trading infrastructure for AI agents: one wallet, one risk policy, every market.",
6
6
  "homepage": "https://felix.trade/docs",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "trade.felix/mcp",
4
4
  "title": "Felix MCP",
5
5
  "description": "Non-custodial trading infrastructure for AI agents across prediction markets, crypto, and options.",
6
- "version": "2.0.133",
6
+ "version": "2.0.134",
7
7
  "websiteUrl": "https://felix.trade/docs",
8
8
  "icons": [
9
9
  {
@@ -25,7 +25,7 @@
25
25
  {
26
26
  "registryType": "npm",
27
27
  "identifier": "felix-mcp",
28
- "version": "2.0.133",
28
+ "version": "2.0.134",
29
29
  "transport": {
30
30
  "type": "stdio"
31
31
  }