@stratabook/mcp 0.1.7 → 0.1.8
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 +2 -1
- package/dist/src/generated-harness.d.ts +3 -3
- package/dist/src/generated-harness.js +3 -3
- package/dist/src/server.js +78 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -76,7 +76,8 @@ manifest at `/.well-known/strata-agent.json` and the graph at
|
|
|
76
76
|
|
|
77
77
|
The external agent owner decides what its agent may do and configures its
|
|
78
78
|
signer. MCP can request authorization bytes, prepare quote-bound trades or
|
|
79
|
-
|
|
79
|
+
atomic place, cancel, cancel-all, replace, or bounded batch order controls, and
|
|
80
|
+
submit the externally signed result. It accepts
|
|
80
81
|
public keys, detached signatures, and signed transactions, never private keys,
|
|
81
82
|
seed phrases, or wallet secrets. Amounts are token atoms encoded as base-10
|
|
82
83
|
strings.
|
|
@@ -50,7 +50,7 @@ export declare const STRATA_AGENT_HARNESS: {
|
|
|
50
50
|
readonly instruction: "Report consumed input, expected output, minimum output, fees by asset side, price impact, and remaining validity.";
|
|
51
51
|
}, {
|
|
52
52
|
readonly id: "authorize_writes";
|
|
53
|
-
readonly 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
|
|
53
|
+
readonly 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.";
|
|
54
54
|
}, {
|
|
55
55
|
readonly id: "monitor_outcome";
|
|
56
56
|
readonly instruction: "After an authorized submission, report the durable receipt or explicit failure. If the request times out or either process restarts, recover it with the same control ID and idempotency key. Never claim completion from preparation, signing, or an unconfirmed request.";
|
|
@@ -273,7 +273,7 @@ export declare const STRATA_ACTION_GRAPH: {
|
|
|
273
273
|
}, {
|
|
274
274
|
readonly id: "request_order_challenge";
|
|
275
275
|
readonly kind: "prepare";
|
|
276
|
-
readonly summary: "Bind a product-level place, cancel,
|
|
276
|
+
readonly summary: "Bind a product-level place, cancel, bounded cancel-all, atomic replace, or atomic batch operation to canonical authorization bytes.";
|
|
277
277
|
readonly required_capabilities: readonly ["orders.prepare"];
|
|
278
278
|
readonly available: false;
|
|
279
279
|
readonly operation: {
|
|
@@ -448,4 +448,4 @@ export declare const STRATA_ACTION_GRAPH: {
|
|
|
448
448
|
}];
|
|
449
449
|
};
|
|
450
450
|
export declare const STRATA_ACTION_GRAPH_URI = "strata://action-graph/v1";
|
|
451
|
-
export declare 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. If order submission is ambiguous, recover durable status with the same control ID and idempotency key.
|
|
451
|
+
export declare 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. If order 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, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
|
|
@@ -79,7 +79,7 @@ export const STRATA_AGENT_HARNESS = {
|
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"id": "authorize_writes",
|
|
82
|
-
"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
|
|
82
|
+
"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."
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"id": "monitor_outcome",
|
|
@@ -368,7 +368,7 @@ export const STRATA_ACTION_GRAPH = {
|
|
|
368
368
|
{
|
|
369
369
|
"id": "request_order_challenge",
|
|
370
370
|
"kind": "prepare",
|
|
371
|
-
"summary": "Bind a product-level place, cancel,
|
|
371
|
+
"summary": "Bind a product-level place, cancel, bounded cancel-all, atomic replace, or atomic batch operation to canonical authorization bytes.",
|
|
372
372
|
"required_capabilities": [
|
|
373
373
|
"orders.prepare"
|
|
374
374
|
],
|
|
@@ -587,4 +587,4 @@ export const STRATA_ACTION_GRAPH = {
|
|
|
587
587
|
]
|
|
588
588
|
};
|
|
589
589
|
export const STRATA_ACTION_GRAPH_URI = "strata://action-graph/v1";
|
|
590
|
-
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. If order submission is ambiguous, recover durable status with the same control ID and idempotency key.
|
|
590
|
+
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. If order 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, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
|
package/dist/src/server.js
CHANGED
|
@@ -182,7 +182,7 @@ export async function createStrataMcpServer(options = {}) {
|
|
|
182
182
|
};
|
|
183
183
|
const response = await client.quote(request);
|
|
184
184
|
return toolResult(response, `Sonar ${response.side} quote: ${response.amount_in_consumed_atoms} input atoms `
|
|
185
|
-
+ `for ${response.amount_out_atoms} output atoms; minimum `
|
|
185
|
+
+ `for ${response.amount_out_atoms} user-net output atoms; user-net minimum `
|
|
186
186
|
+ `${response.minimum_output_atoms}; expires at ${response.expires_at_ms}.`);
|
|
187
187
|
}));
|
|
188
188
|
const executionChallenge = server.registerTool("strata_execution_challenge", {
|
|
@@ -291,10 +291,10 @@ export async function createStrataMcpServer(options = {}) {
|
|
|
291
291
|
}));
|
|
292
292
|
const orderChallenge = server.registerTool("strata_order_challenge", {
|
|
293
293
|
title: "Strata order challenge",
|
|
294
|
-
description: "Bind
|
|
294
|
+
description: "Bind an atomic place, cancel, cancel-all, replace, or bounded batch request to canonical bytes for the agent owner's external signer.",
|
|
295
295
|
inputSchema: {
|
|
296
296
|
marketId: z.string().regex(/^market_[0-9a-f]{32}$/),
|
|
297
|
-
action: z.enum(["place", "cancel", "cancel_all"]),
|
|
297
|
+
action: z.enum(["place", "cancel", "cancel_all", "replace", "batch"]),
|
|
298
298
|
ownerWallet: z.string().min(32).max(44),
|
|
299
299
|
sessionPublicKey: z.string().min(32).max(44),
|
|
300
300
|
accountSequence: z.string().regex(/^[0-9]+$/).max(20).optional(),
|
|
@@ -304,6 +304,16 @@ export async function createStrataMcpServer(options = {}) {
|
|
|
304
304
|
limitPriceAtoms: z.string().regex(/^[1-9][0-9]*$/).max(20).optional(),
|
|
305
305
|
sizeAtoms: z.string().regex(/^[1-9][0-9]*$/).max(20).optional(),
|
|
306
306
|
orderId: z.string().regex(/^order_[0-9a-f]{32}$/).optional(),
|
|
307
|
+
operations: z.array(z.object({
|
|
308
|
+
action: z.enum(["place", "cancel", "replace"]),
|
|
309
|
+
accountSequence: z.string().regex(/^[0-9]+$/).max(20).optional(),
|
|
310
|
+
clientOrderId: z.string().min(1).max(64).regex(/^[A-Za-z0-9._-]+$/).optional(),
|
|
311
|
+
side: z.enum(["buy", "sell"]).optional(),
|
|
312
|
+
orderType: z.enum(["good_until_cancelled", "post_only"]).optional(),
|
|
313
|
+
limitPriceAtoms: z.string().regex(/^[1-9][0-9]*$/).max(20).optional(),
|
|
314
|
+
sizeAtoms: z.string().regex(/^[1-9][0-9]*$/).max(20).optional(),
|
|
315
|
+
orderId: z.string().regex(/^order_[0-9a-f]{32}$/).optional(),
|
|
316
|
+
}).strict()).min(1).max(6).optional(),
|
|
307
317
|
},
|
|
308
318
|
annotations: {
|
|
309
319
|
readOnlyHint: false,
|
|
@@ -345,13 +355,77 @@ export async function createStrataMcpServer(options = {}) {
|
|
|
345
355
|
orderId: args.orderId,
|
|
346
356
|
};
|
|
347
357
|
}
|
|
348
|
-
else {
|
|
358
|
+
else if (args.action === "cancel_all") {
|
|
349
359
|
request = {
|
|
350
360
|
action: "cancel_all",
|
|
351
361
|
ownerWallet: args.ownerWallet,
|
|
352
362
|
sessionPublicKey: args.sessionPublicKey,
|
|
353
363
|
};
|
|
354
364
|
}
|
|
365
|
+
else if (args.action === "replace") {
|
|
366
|
+
if (args.orderId === undefined
|
|
367
|
+
|| args.accountSequence === undefined
|
|
368
|
+
|| args.clientOrderId === undefined
|
|
369
|
+
|| args.side === undefined
|
|
370
|
+
|| args.orderType === undefined
|
|
371
|
+
|| args.limitPriceAtoms === undefined
|
|
372
|
+
|| args.sizeAtoms === undefined) {
|
|
373
|
+
return toolError("invalid_request", "Replace requires orderId, accountSequence, clientOrderId, side, orderType, limitPriceAtoms, and sizeAtoms.", false);
|
|
374
|
+
}
|
|
375
|
+
request = {
|
|
376
|
+
action: "replace",
|
|
377
|
+
ownerWallet: args.ownerWallet,
|
|
378
|
+
sessionPublicKey: args.sessionPublicKey,
|
|
379
|
+
orderId: args.orderId,
|
|
380
|
+
accountSequence: args.accountSequence,
|
|
381
|
+
clientOrderId: args.clientOrderId,
|
|
382
|
+
side: args.side,
|
|
383
|
+
orderType: args.orderType,
|
|
384
|
+
limitPriceAtoms: args.limitPriceAtoms,
|
|
385
|
+
sizeAtoms: args.sizeAtoms,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
if (args.operations === undefined) {
|
|
390
|
+
return toolError("invalid_request", "Batch requires operations.", false);
|
|
391
|
+
}
|
|
392
|
+
const operations = [];
|
|
393
|
+
for (const operation of args.operations) {
|
|
394
|
+
if (operation.action === "cancel") {
|
|
395
|
+
if (operation.orderId === undefined) {
|
|
396
|
+
return toolError("invalid_request", "Batch cancel requires orderId.", false);
|
|
397
|
+
}
|
|
398
|
+
operations.push({ action: "cancel", orderId: operation.orderId });
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if (operation.accountSequence === undefined
|
|
402
|
+
|| operation.clientOrderId === undefined
|
|
403
|
+
|| operation.side === undefined
|
|
404
|
+
|| operation.orderType === undefined
|
|
405
|
+
|| operation.limitPriceAtoms === undefined
|
|
406
|
+
|| operation.sizeAtoms === undefined
|
|
407
|
+
|| (operation.action === "replace" && operation.orderId === undefined)) {
|
|
408
|
+
return toolError("invalid_request", `Batch ${operation.action} has incomplete fields.`, false);
|
|
409
|
+
}
|
|
410
|
+
const place = {
|
|
411
|
+
accountSequence: operation.accountSequence,
|
|
412
|
+
clientOrderId: operation.clientOrderId,
|
|
413
|
+
side: operation.side,
|
|
414
|
+
orderType: operation.orderType,
|
|
415
|
+
limitPriceAtoms: operation.limitPriceAtoms,
|
|
416
|
+
sizeAtoms: operation.sizeAtoms,
|
|
417
|
+
};
|
|
418
|
+
operations.push(operation.action === "replace"
|
|
419
|
+
? { action: "replace", orderId: operation.orderId, ...place }
|
|
420
|
+
: { action: "place", ...place });
|
|
421
|
+
}
|
|
422
|
+
request = {
|
|
423
|
+
action: "batch",
|
|
424
|
+
ownerWallet: args.ownerWallet,
|
|
425
|
+
sessionPublicKey: args.sessionPublicKey,
|
|
426
|
+
operations,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
355
429
|
const response = await platformClient.orders.challenge(args.marketId, request);
|
|
356
430
|
return toolResult(response, `Order challenge ${response.challenge_id} binds ${response.order_ids.length} opaque order ID(s); expires at ${response.expires_at_ms}.`);
|
|
357
431
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratabook/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Connect AI agents to Strata markets and Sonar quotes with MCP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
47
|
-
"@stratabook/sdk": "0.1.
|
|
47
|
+
"@stratabook/sdk": "0.1.7",
|
|
48
48
|
"zod": "^3.25.76"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|