@stratabook/mcp 0.1.12 → 0.2.0

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.
@@ -10,6 +10,8 @@ export const STRATA_AGENT_HARNESS = {
10
10
  "capabilities": "https://api.stratabook.app/sonar/capabilities",
11
11
  "markets": "https://api.stratabook.app/sonar/markets",
12
12
  "platform_capabilities": "https://api.stratabook.app/v2/capabilities",
13
+ "platform_action_graph": "https://api.stratabook.app/v2/action-graph",
14
+ "platform_status": "https://api.stratabook.app/v2/status",
13
15
  "platform_markets": "https://api.stratabook.app/v2/markets",
14
16
  "action_graph": "https://api.stratabook.app/sonar/action-graph",
15
17
  "mcp": "https://api.stratabook.app/mcp",
@@ -19,11 +21,42 @@ export const STRATA_AGENT_HARNESS = {
19
21
  "mcp_tool_order": [
20
22
  "strata_capabilities",
21
23
  "strata_action_graph",
24
+ "strata_platform_graph",
25
+ "strata_status",
22
26
  "strata_markets",
27
+ "strata_marks",
28
+ "strata_candles",
29
+ "strata_twaps",
30
+ "strata_twap_challenge",
31
+ "strata_twap_cancel",
32
+ "strata_twap_prepare",
33
+ "strata_twap_submit",
34
+ "strata_portfolio",
35
+ "strata_portfolio_history",
36
+ "strata_market_making_status",
37
+ "strata_market_making_reputation",
38
+ "strata_vault_status",
39
+ "strata_vault_setup",
40
+ "strata_vault_deposit",
41
+ "strata_vault_withdraw",
42
+ "strata_vault_delegate",
43
+ "strata_vault_policy",
44
+ "strata_vault_pause",
45
+ "strata_vault_submit",
46
+ "strata_vault_submission",
47
+ "strata_rewards",
48
+ "strata_referrals",
49
+ "strata_referral_link",
50
+ "strata_referral_claim",
51
+ "strata_bugs",
52
+ "strata_bug_submit",
23
53
  "strata_quote",
54
+ "strata_exact_output_quote",
55
+ "strata_swap_quote",
24
56
  "strata_execution_challenge",
25
57
  "strata_execution_prepare",
26
58
  "strata_execution_submit",
59
+ "strata_execution_status",
27
60
  "strata_order_challenge",
28
61
  "strata_order_prepare",
29
62
  "strata_order_submit",
@@ -32,8 +65,37 @@ export const STRATA_AGENT_HARNESS = {
32
65
  "terminal": [
33
66
  "npx -y @stratabook/sdk capabilities --json",
34
67
  "npx -y @stratabook/sdk action-graph --json",
68
+ "npx -y @stratabook/sdk platform-graph --json",
69
+ "npx -y @stratabook/sdk platform-status --json",
70
+ "npx -y @stratabook/sdk mark --market-id MARKET_ID --json",
71
+ "npx -y @stratabook/sdk candles --market-id MARKET_ID --from-ms FROM_MS --to-ms TO_MS --resolution-seconds 300 --json",
72
+ "npx -y @stratabook/sdk execution-status --market-id MARKET_ID --execution-id EXECUTION_ID --json",
73
+ "npx -y @stratabook/sdk twaps --market-id MARKET_ID --wallet WALLET_PUBLIC_KEY --json",
74
+ "npx -y @stratabook/sdk twap-challenge --market-id MARKET_ID --owner-wallet OWNER_PUBLIC_KEY --session-public-key SESSION_PUBLIC_KEY --side buy --total-size-atoms TOTAL_ATOMS --slices 10 --tolerance-bps 100 --interval-slots 100 --limit-price-atoms PRICE_ATOMS --json",
75
+ "npx -y @stratabook/sdk twap-cancel --market-id MARKET_ID --owner-wallet OWNER_PUBLIC_KEY --session-public-key SESSION_PUBLIC_KEY --twap-id TWAP_ID --json",
76
+ "npx -y @stratabook/sdk twap-prepare --market-id MARKET_ID --owner-wallet OWNER_PUBLIC_KEY --session-public-key SESSION_PUBLIC_KEY --side buy --total-size-atoms TOTAL_ATOMS --slices 10 --tolerance-bps 100 --interval-slots 100 --limit-price-atoms PRICE_ATOMS --json",
77
+ "npx -y @stratabook/sdk twap-submit --market-id MARKET_ID --twap-control-id CONTROL_ID --signed-transaction-base64 TRANSACTION --idempotency-key KEY --json",
78
+ "npx -y @stratabook/sdk account --wallet WALLET_PUBLIC_KEY --json",
79
+ "npx -y @stratabook/sdk portfolio-history --wallet WALLET_PUBLIC_KEY --range 24h --json",
80
+ "npx -y @stratabook/sdk maker-status --market-id MARKET_ID --wallet WALLET_PUBLIC_KEY --json",
81
+ "npx -y @stratabook/sdk maker-reputation --market-id MARKET_ID --wallet WALLET_PUBLIC_KEY --json",
82
+ "npx -y @stratabook/sdk vault-status --wallet WALLET_PUBLIC_KEY --session-public-key SESSION_PUBLIC_KEY --json",
83
+ "npx -y @stratabook/sdk session-keygen --json",
84
+ "npx -y @stratabook/sdk vault-setup --wallet WALLET_PUBLIC_KEY --session-public-key SESSION_PUBLIC_KEY --json",
85
+ "npx -y @stratabook/sdk vault-deposit --wallet WALLET_PUBLIC_KEY --market-id MARKET_ID --asset-id ASSET_ID --amount-atoms AMOUNT --session-public-key SESSION_PUBLIC_KEY --json",
86
+ "npx -y @stratabook/sdk vault-withdraw --wallet WALLET_PUBLIC_KEY --market-id MARKET_ID --asset-id ASSET_ID --destination-wallet DESTINATION_WALLET --amount-atoms AMOUNT --json",
87
+ "npx -y @stratabook/sdk vault-delegate --wallet WALLET_PUBLIC_KEY --session-public-key SESSION_PUBLIC_KEY --action revoke --json",
88
+ "npx -y @stratabook/sdk vault-policy --wallet WALLET_PUBLIC_KEY --mode restricted --allowed-wallets DESTINATION_WALLET --json",
89
+ "npx -y @stratabook/sdk vault-pause --wallet WALLET_PUBLIC_KEY --paused true --json",
90
+ "npx -y @stratabook/sdk rewards --wallet WALLET_PUBLIC_KEY --json",
91
+ "npx -y @stratabook/sdk referrals --wallet WALLET_PUBLIC_KEY --json",
92
+ "npx -y @stratabook/sdk referral-link --wallet WALLET_PUBLIC_KEY --code REFERRAL_CODE --json",
93
+ "npx -y @stratabook/sdk referral-claim --wallet WALLET_PUBLIC_KEY --json",
94
+ "npx -y @stratabook/sdk bugs --wallet WALLET_PUBLIC_KEY --json",
95
+ "npx -y @stratabook/sdk bug-payload --message REPORT_TEXT --json",
35
96
  "npx -y @stratabook/sdk markets --json",
36
97
  "npx -y @stratabook/sdk quote --market SOL/USDC --side sell --amount-atoms 10000000 --json",
98
+ "npx -y @stratabook/sdk swap-quote --input-asset-id INPUT_ASSET_ID --output-asset-id OUTPUT_ASSET_ID --amount-atoms 10000000 --json",
37
99
  "npx -y @stratabook/sdk order-slo --market-id MARKET_ID --owner-wallet OWNER_PUBLIC_KEY --json"
38
100
  ]
39
101
  },
@@ -44,15 +106,15 @@ export const STRATA_AGENT_HARNESS = {
44
106
  },
45
107
  {
46
108
  "id": "establish_mode",
47
- "instruction": "Read the action graph and identify which prepare and submit nodes are live. The external agent owner configures its permissions and signer authority; static documentation never enables a Strata operation."
109
+ "instruction": "Read the compact action graph and the complete platform graph, then identify which operation and workflow nodes are live. The external agent owner configures its permissions and signer authority; static documentation never enables a Strata operation."
48
110
  },
49
111
  {
50
112
  "id": "understand_objective",
51
- "instruction": "Resolve the user's market, side, amount, and tolerance. Ask before proceeding when any economically meaningful input is ambiguous."
113
+ "instruction": "Resolve the user's market or input/output assets, side when applicable, amount, and tolerance. Ask before proceeding when any economically meaningful input is ambiguous."
52
114
  },
53
115
  {
54
116
  "id": "discover_market",
55
- "instruction": "List markets, select one marked ready, and use its discovered base and quote decimals. Do not guess market identifiers or token decimals."
117
+ "instruction": "List catalog assets and markets, select currently available product identities, and use discovered decimals. Do not guess identifiers or token decimals."
56
118
  },
57
119
  {
58
120
  "id": "read_market_data",
@@ -60,19 +122,67 @@ export const STRATA_AGENT_HARNESS = {
60
122
  },
61
123
  {
62
124
  "id": "read_account",
63
- "instruction": "When account.read is live, use the owner-configured signer to authorize the exact wallet, market, request time, and fill limit. Read or stream only the sanitized orders and fills returned by the official SDK, and recover stream gaps from a fresh signed snapshot."
125
+ "instruction": "Read the whole account with one public call by wallet address (portfolio.read / strata_portfolio / `account.read(wallet)`): balances, positions, open orders, and recent fills across every live market — no signature, no session key, no market selection. Per-market signed account reads and streams (account.read / account.stream) exist only for owners who want a signed, per-market view; never make them a prerequisite for trading."
126
+ },
127
+ {
128
+ "id": "read_portfolio",
129
+ "instruction": "Before sizing any action, read the account once (portfolio.read): exact per-asset total, available, and locked atoms, per-market positions, open orders, recent fills, and USD totals with the observed slot. Treat null USD totals as an incomplete valuation, never as zero; markets listed in unavailable_market_ids did not report orders and fills for that snapshot; use the typed stored-history operation for past equity."
130
+ },
131
+ {
132
+ "id": "read_vault",
133
+ "instruction": "Before session-owned execution, read the official Vault status for the owner and external session key. Continue only when the product is active, the session is active, and market_execution_ready is true; treat opaque asset limits and withdrawal access as authoritative."
134
+ },
135
+ {
136
+ "id": "protect_vault",
137
+ "instruction": "When an owner requests a Vault pause or resume and vault.pause is live, prepare the exact transaction with the official SDK, verify that the wallet and requested state are unchanged, then have the owner-configured signer sign and broadcast it externally. Preparation alone does not change state."
138
+ },
139
+ {
140
+ "id": "onboard_vault",
141
+ "instruction": "Onboarding is one owner signature, once: register the external session key with vault.setup (only the wallet and the session key are required; one session then trades every market) or simply name the session key on the first vault.deposit, which registers it in the same transaction. Policy fields — expiry, cadence, tolerance, per-asset limits — are optional. Verify every echoed field and the prepared transaction before external owner signing and broadcast; retain the session key only in the owner's signer."
142
+ },
143
+ {
144
+ "id": "fund_vault",
145
+ "instruction": "When vault.deposit is live, select an asset from the discovered market and use an exact positive atomic amount. Verify the echoed owner, market, asset, and amount plus the prepared transaction before external owner signing and broadcast."
146
+ },
147
+ {
148
+ "id": "withdraw_vault",
149
+ "instruction": "When vault.withdraw is live, choose an exact market asset, destination-owner wallet, and positive atomic amount. Verify every echoed binding and the prepared transaction before external owner signing and broadcast; the on-chain withdrawal policy remains authoritative."
150
+ },
151
+ {
152
+ "id": "revoke_vault_session",
153
+ "instruction": "When an owner requests session revocation and vault.delegate.manage is live, bind the exact owner wallet and external session public key. Verify both identities and the destructive revoke action before external owner signing and broadcast; preparation alone does not revoke access."
154
+ },
155
+ {
156
+ "id": "control_vault_withdrawals",
157
+ "instruction": "When vault.policy.manage is live, use blocked mode with no allowed wallets to freeze withdrawals or restricted mode with one to eight exact destination-owner wallets. Verify the echoed mode and complete wallet list before external owner signing and broadcast."
158
+ },
159
+ {
160
+ "id": "reconcile_maker_status",
161
+ "instruction": "When mm.status.read is live, read the maker's products by wallet address (public, no signature) before and after any maker action: resting firm orders, the intent budget, live signed quotes, each Strand and Current with its remaining exposure and expiry, oracle health, and armed dead-man guards. Reconcile against what the agent believes it posted; treat missing, expired, or disabled products as not quoting."
162
+ },
163
+ {
164
+ "id": "stream_maker_fills",
165
+ "instruction": "When mm.fills.stream is live, keep one maker stream open per market through the official SDK by wallet address (public, no signature): start from the maker snapshot, apply only contiguous maker_fill and maker_status events, and recover any gap or reconnect from a fresh snapshot. Reconcile every fill and exposure change against the maker's own state before quoting further."
166
+ },
167
+ {
168
+ "id": "inspect_maker_reputation",
169
+ "instruction": "When mm.reputation.read is live, read the maker's record by wallet address (public, no signature). Use the tier, reliability counters, tier-progress gates, signed-quote eligibility, and minimum cadence before choosing the maker transport; do not infer hidden counterparties or execution paths."
64
170
  },
65
171
  {
66
172
  "id": "preserve_atoms",
67
173
  "instruction": "Represent token amounts as unsigned base-10 atomic strings. Never pass settlement amounts through floating-point arithmetic."
68
174
  },
175
+ {
176
+ "id": "authorize_community_actions",
177
+ "instruction": "For referral link or claim actions, generate the exact official SDK authorization payload, have the affected owner wallet sign it externally, and submit only the detached signature with the same referral code or payout wallet binding."
178
+ },
69
179
  {
70
180
  "id": "request_quote",
71
- "instruction": "Request a fresh Sonar quote with an explicit side, exact input atoms, and execution tolerance supplied by the external agent."
181
+ "instruction": "Request a fresh Sonar quote using either a selected market and explicit side or selected input/output asset IDs, plus exact input atoms and the execution tolerance supplied by the external agent."
72
182
  },
73
183
  {
74
184
  "id": "validate_quote",
75
- "instruction": "Verify the quote binds to the selected market, side, and input. Check labelled fees, minimum output, price impact, server time, and expiry."
185
+ "instruction": "Verify the quote binds to the selected market and side or the selected input/output assets, plus the exact input and tolerance. Check labelled fees, minimum output, price impact, server time, and expiry."
76
186
  },
77
187
  {
78
188
  "id": "report_result",
@@ -80,7 +190,7 @@ export const STRATA_AGENT_HARNESS = {
80
190
  },
81
191
  {
82
192
  "id": "authorize_writes",
83
- "instruction": "When prepare and submit are exposed, keep signing external to Strata: request canonical authorization bytes, sign them with the owner-configured signer, verify the prepared transaction preserves the quote or exact opaque order set, then submit the externally signed transaction with idempotency. Resting-order control supports place, cancel, bounded cancel-all, atomic replace, and atomic heterogeneous batches of up to six operations. Every incoming resting order selects an explicit self-trade prevention policy; no policy permits a self-fill."
193
+ "instruction": "When prepare and submit are exposed, keep signing external to Strata and use one signature per action: send the operation itself to prepare (orders, TWAP, quote-bound execution), verify the returned transaction, sign only that transaction with the session key, then submit with idempotency. The SDK's built-in verifier decodes the transaction and requires it to be exactly the requested operation for that market with the session co-signing only delegated instructions and never paying; a stricter owner verifier may replace it. The two-step challenge path (authorization bytes signed first) remains available. Resting-order control supports place, cancel, bounded cancel-all, atomic replace, and atomic heterogeneous batches of up to six operations. Every incoming resting order selects an explicit self-trade prevention policy; no policy permits a self-fill."
84
194
  },
85
195
  {
86
196
  "id": "stream_order_commands",
@@ -94,6 +204,14 @@ export const STRATA_AGENT_HARNESS = {
94
204
  "id": "certify_order_command_slo",
95
205
  "instruction": "Use the official non-trading order-command certification harness before release and on the production schedule. Retain its machine-readable connection count, load, latency percentiles, sequence/error rate, thresholds, and pass/fail result; package support alone is not a latency claim."
96
206
  },
207
+ {
208
+ "id": "stream_execution_state",
209
+ "instruction": "When execution.stream is live, watch every execution handle you prepared through the official SDK's sequenced execution stream instead of polling status: start from its snapshot, apply only contiguous execution_update, execution_expired, and execution_unknown events, recover any gap from a fresh snapshot, and treat an expired or unknown handle as not executed unless a confirmed receipt says otherwise."
210
+ },
211
+ {
212
+ "id": "stream_twap_progress",
213
+ "instruction": "When algos.twap.stream is live, keep the official SDK's TWAP stream open for the owner wallet across the markets with active schedules: start from the snapshot, apply only contiguous twap_update events, and recover any gap from a fresh snapshot. Report executed size, achieved value, fees, and the terminal receipt from the streamed rows rather than polling."
214
+ },
97
215
  {
98
216
  "id": "monitor_outcome",
99
217
  "instruction": "After an authorized submission, report the RPC-broadcast receipt and then the durable terminal status or explicit failure. If the request times out or either process restarts, recover it with the same control ID and idempotency key. Never claim chain completion from preparation, signing, or the immediate broadcast receipt."
@@ -111,7 +229,7 @@ export const STRATA_AGENT_HARNESS = {
111
229
  "safety_rules": [
112
230
  "Never request or accept wallet secrets, private keys, seed phrases, session keys, or production credentials in a prompt.",
113
231
  "Never call undocumented endpoints or reconstruct private Sonar behavior.",
114
- "Never silently widen slippage, refresh changed economics, substitute a market, or retry a non-retryable failure.",
232
+ "Never silently widen the tolerance, refresh changed economics, substitute a market, or retry a non-retryable failure.",
115
233
  "Never select a self-trade policy implicitly, suppress an order-command sequence gap, or disarm a dead-man ticket merely because the client is shutting down.",
116
234
  "Treat capability removal, revocation, expiry, and emergency disable as immediate stop signals.",
117
235
  "Capability and action-graph availability are authoritative for Strata operations; permission and signer policy remain controlled by the external agent owner."
@@ -668,4 +786,4 @@ export const STRATA_ACTION_GRAPH = {
668
786
  ]
669
787
  };
670
788
  export const STRATA_ACTION_GRAPH_URI = "strata://action-graph/v1";
671
- export const STRATA_AGENT_HARNESS_INSTRUCTIONS = "Strata Agent Harness 1.0. Start every objective with strata_capabilities, then strata_action_graph, then strata_markets. Read strata://agent-harness/v1 and strata://action-graph/v1. The external agent owner controls permission and signer authority. Strata accepts public keys, detached signatures, and signed transactions, never private keys or seed phrases. Resolve the market, side, exact input atoms, and tolerance before strata_quote. Treat amounts as unsigned base-10 token atoms; check quote bindings, labelled fees, minimum output, and expiry. To execute or control a resting order: request a challenge, verify its quote or exact opaque order bindings, sign canonical authorization bytes externally, prepare, verify and sign the returned transaction externally, then submit with idempotency. When websocket order transport is live, prefer the official SDK persistent command stream, choose explicit self-trade prevention, keep its durable dead-man guard armed for resting exposure, and distinguish immediate RPC broadcast from pushed terminal chain status. If submission is ambiguous, recover durable status with the same control ID and idempotency key. Order control supports place, cancel, bounded cancel-all, atomic replace, and atomic heterogeneous batches of up to six operations. Stop on ambiguity, sequence gaps, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
789
+ export const STRATA_AGENT_HARNESS_INSTRUCTIONS = "Strata Agent Harness 1.0. Start every objective with strata_capabilities, then strata_action_graph, then strata_platform_graph, then strata_status, then strata_markets. Read strata://agent-harness/v1, strata://action-graph/v1, and strata://platform-graph/v2. The external agent owner controls permission and signer authority. Strata accepts public keys, detached signatures, and signed transactions, never private keys or seed phrases. Resolve a market and side or catalog input/output asset IDs, plus exact input atoms and tolerance, before strata_quote or strata_swap_quote. When portfolio.read is live, read the owner's live Vault portfolio before sizing any action and treat null USD totals as an incomplete valuation, never as zero. When mm.status.read is live, reconcile the owner's own maker products, exposure, and dead-man guards through the authorized status read before and after every maker action, and when mm.fills.stream is live keep the official SDK's authenticated maker stream open to apply contiguous maker fills and exposure changes. When algos.twap.stream is live, follow TWAP progress through the official SDK's sequenced TWAP stream instead of polling, and when execution.stream is live watch prepared execution handles through the sequenced execution stream. Before selecting a maker transport, read the externally authorized owner-scoped maker reputation record and follow its signed-quote eligibility, cadence, and tier-progress fields. Treat amounts as unsigned base-10 token atoms; check quote bindings, labelled fees, minimum output, and expiry. To execute or control a resting order: request a challenge, verify its quote or exact opaque order bindings, sign canonical authorization bytes externally, prepare, verify and sign the returned transaction externally, then submit with idempotency. When websocket order transport is live, prefer the official SDK persistent command stream, choose explicit self-trade prevention, keep its durable dead-man guard armed for resting exposure, and distinguish immediate RPC broadcast from pushed terminal chain status. If submission is ambiguous, recover durable status with the same control ID and idempotency key. Order control supports place, cancel, bounded cancel-all, atomic replace, and atomic heterogeneous batches of up to six operations. Stop on ambiguity, sequence gaps, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
@@ -1,10 +1,17 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { StrataClient, StrataPlatformClient, type CapabilityCatalog } from "@stratabook/sdk";
3
+ import { type SessionAutonomy } from "./autonomy.js";
3
4
  export interface StrataMcpOptions {
4
5
  apiBase?: string;
5
6
  timeoutMs?: number;
6
7
  client?: StrataClient;
7
8
  platformClient?: StrataPlatformClient;
9
+ /**
10
+ * When set, the MCP may finish trades itself with this Vault session key,
11
+ * bounded by the user-owned autonomy slider. Absent = the calm default:
12
+ * every trade is prepared for a human to sign. Built from env in the CLI.
13
+ */
14
+ sessionAutonomy?: SessionAutonomy;
8
15
  }
9
16
  export interface StrataMcpRuntime {
10
17
  server: McpServer;
@@ -18,6 +25,7 @@ export interface StrataMcpReadiness {
18
25
  contract_version: string;
19
26
  harness_version: string;
20
27
  }
28
+ export declare const STRATA_PLATFORM_GRAPH_URI = "strata://platform-graph/v2";
21
29
  export declare function capabilityAvailable(catalog: CapabilityCatalog, id: string): boolean;
22
30
  export declare function probeStrataMcpReadiness(options?: StrataMcpOptions): Promise<StrataMcpReadiness>;
23
31
  export declare function createStrataMcpServer(options?: StrataMcpOptions): Promise<StrataMcpRuntime>;