@stratabook/mcp 0.1.6 → 0.1.7
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 +1 -0
- package/dist/src/generated-harness.d.ts +22 -3
- package/dist/src/generated-harness.js +28 -3
- package/dist/src/server.js +20 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ The tools currently available are:
|
|
|
35
35
|
- `strata_order_challenge`, when `orders.prepare` is enabled for MCP
|
|
36
36
|
- `strata_order_prepare`, when `orders.prepare` is enabled for MCP
|
|
37
37
|
- `strata_order_submit`, when `orders.submit` is enabled for MCP
|
|
38
|
+
- `strata_order_status`, when `orders.submit` is enabled for MCP
|
|
38
39
|
|
|
39
40
|
Every initialization response carries the compact Strata Agent Harness. The
|
|
40
41
|
server also publishes the complete harness as the
|
|
@@ -15,7 +15,7 @@ export declare const STRATA_AGENT_HARNESS: {
|
|
|
15
15
|
readonly manifest: "https://api.stratabook.app/.well-known/strata-agent.json";
|
|
16
16
|
};
|
|
17
17
|
readonly interfaces: {
|
|
18
|
-
readonly mcp_tool_order: readonly ["strata_capabilities", "strata_action_graph", "strata_markets", "strata_quote", "strata_execution_challenge", "strata_execution_prepare", "strata_execution_submit", "strata_order_challenge", "strata_order_prepare", "strata_order_submit"];
|
|
18
|
+
readonly mcp_tool_order: readonly ["strata_capabilities", "strata_action_graph", "strata_markets", "strata_quote", "strata_execution_challenge", "strata_execution_prepare", "strata_execution_submit", "strata_order_challenge", "strata_order_prepare", "strata_order_submit", "strata_order_status"];
|
|
19
19
|
readonly terminal: readonly ["npx -y @stratabook/sdk capabilities --json", "npx -y @stratabook/sdk action-graph --json", "npx -y @stratabook/sdk markets --json", "npx -y @stratabook/sdk quote --market SOL/USDC --side sell --amount-atoms 10000000 --json"];
|
|
20
20
|
};
|
|
21
21
|
readonly workflow: readonly [{
|
|
@@ -53,7 +53,7 @@ export declare const STRATA_AGENT_HARNESS: {
|
|
|
53
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 uses place, cancel, or cancel-all and cancel-all is atomically bounded to six orders per call.";
|
|
54
54
|
}, {
|
|
55
55
|
readonly id: "monitor_outcome";
|
|
56
|
-
readonly instruction: "After an authorized submission, report the durable receipt or explicit failure. Never claim completion from preparation, signing, or an unconfirmed request.";
|
|
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.";
|
|
57
57
|
}];
|
|
58
58
|
readonly stop_conditions: readonly ["The required live capability is disabled or absent.", "The market is paused, unavailable, or has no reviewed operation path.", "Market, side, amount, decimals, tolerance, or signer authority is unavailable or ambiguous.", "The contract version is unsupported or a response contains unknown fields.", "A quote is expired or its market, side, amount, fee, minimum-output, or time binding is inconsistent.", "A requested operation exceeds the exposed tool, account, or policy scope.", "A user asks the agent to receive or expose wallet secrets, private keys, seed phrases, session keys, or production credentials."];
|
|
59
59
|
readonly safety_rules: readonly ["Never request or accept wallet secrets, private keys, seed phrases, session keys, or production credentials in a prompt.", "Never call undocumented endpoints or reconstruct private Sonar behavior.", "Never silently widen slippage, refresh changed economics, substitute a market, or retry a non-retryable failure.", "Treat capability removal, revocation, expiry, and emergency disable as immediate stop signals.", "Capability and action-graph availability are authoritative for Strata operations; permission and signer policy remain controlled by the external agent owner."];
|
|
@@ -321,6 +321,17 @@ export declare const STRATA_ACTION_GRAPH: {
|
|
|
321
321
|
readonly summary: "Receive the opaque order IDs, transaction signature, and submitted status.";
|
|
322
322
|
readonly required_capabilities: readonly [];
|
|
323
323
|
readonly available: true;
|
|
324
|
+
}, {
|
|
325
|
+
readonly id: "recover_order_status";
|
|
326
|
+
readonly kind: "read";
|
|
327
|
+
readonly summary: "Recover durable submitting, submitted, or failed status after a timeout or restart.";
|
|
328
|
+
readonly required_capabilities: readonly ["orders.submit"];
|
|
329
|
+
readonly available: false;
|
|
330
|
+
readonly operation: {
|
|
331
|
+
readonly method: "POST";
|
|
332
|
+
readonly path: "/v2/markets/{market_id}/orders/status";
|
|
333
|
+
readonly mcp_tool: "strata_order_status";
|
|
334
|
+
};
|
|
324
335
|
}];
|
|
325
336
|
readonly edges: readonly [{
|
|
326
337
|
readonly from: "discover_capabilities";
|
|
@@ -426,7 +437,15 @@ export declare const STRATA_ACTION_GRAPH: {
|
|
|
426
437
|
readonly from: "submit_order_control";
|
|
427
438
|
readonly to: "receive_order_receipt";
|
|
428
439
|
readonly condition: "the control ID and idempotency key match";
|
|
440
|
+
}, {
|
|
441
|
+
readonly from: "submit_order_control";
|
|
442
|
+
readonly to: "recover_order_status";
|
|
443
|
+
readonly condition: "the submission result is ambiguous or either process restarted";
|
|
444
|
+
}, {
|
|
445
|
+
readonly from: "recover_order_status";
|
|
446
|
+
readonly to: "receive_order_receipt";
|
|
447
|
+
readonly condition: "durable status is submitted";
|
|
429
448
|
}];
|
|
430
449
|
};
|
|
431
450
|
export declare const STRATA_ACTION_GRAPH_URI = "strata://action-graph/v1";
|
|
432
|
-
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. Cancel-all is atomically bounded to six orders per call. Stop on ambiguity, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
|
|
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. Cancel-all is atomically bounded to six orders per call. Stop on ambiguity, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
|
|
@@ -26,7 +26,8 @@ export const STRATA_AGENT_HARNESS = {
|
|
|
26
26
|
"strata_execution_submit",
|
|
27
27
|
"strata_order_challenge",
|
|
28
28
|
"strata_order_prepare",
|
|
29
|
-
"strata_order_submit"
|
|
29
|
+
"strata_order_submit",
|
|
30
|
+
"strata_order_status"
|
|
30
31
|
],
|
|
31
32
|
"terminal": [
|
|
32
33
|
"npx -y @stratabook/sdk capabilities --json",
|
|
@@ -82,7 +83,7 @@ export const STRATA_AGENT_HARNESS = {
|
|
|
82
83
|
},
|
|
83
84
|
{
|
|
84
85
|
"id": "monitor_outcome",
|
|
85
|
-
"instruction": "After an authorized submission, report the durable receipt or explicit failure. Never claim completion from preparation, signing, or an unconfirmed request."
|
|
86
|
+
"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."
|
|
86
87
|
}
|
|
87
88
|
],
|
|
88
89
|
"stop_conditions": [
|
|
@@ -426,6 +427,20 @@ export const STRATA_ACTION_GRAPH = {
|
|
|
426
427
|
"summary": "Receive the opaque order IDs, transaction signature, and submitted status.",
|
|
427
428
|
"required_capabilities": [],
|
|
428
429
|
"available": true
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"id": "recover_order_status",
|
|
433
|
+
"kind": "read",
|
|
434
|
+
"summary": "Recover durable submitting, submitted, or failed status after a timeout or restart.",
|
|
435
|
+
"required_capabilities": [
|
|
436
|
+
"orders.submit"
|
|
437
|
+
],
|
|
438
|
+
"available": false,
|
|
439
|
+
"operation": {
|
|
440
|
+
"method": "POST",
|
|
441
|
+
"path": "/v2/markets/{market_id}/orders/status",
|
|
442
|
+
"mcp_tool": "strata_order_status"
|
|
443
|
+
}
|
|
429
444
|
}
|
|
430
445
|
],
|
|
431
446
|
"edges": [
|
|
@@ -558,8 +573,18 @@ export const STRATA_ACTION_GRAPH = {
|
|
|
558
573
|
"from": "submit_order_control",
|
|
559
574
|
"to": "receive_order_receipt",
|
|
560
575
|
"condition": "the control ID and idempotency key match"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"from": "submit_order_control",
|
|
579
|
+
"to": "recover_order_status",
|
|
580
|
+
"condition": "the submission result is ambiguous or either process restarted"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
"from": "recover_order_status",
|
|
584
|
+
"to": "receive_order_receipt",
|
|
585
|
+
"condition": "durable status is submitted"
|
|
561
586
|
}
|
|
562
587
|
]
|
|
563
588
|
};
|
|
564
589
|
export const STRATA_ACTION_GRAPH_URI = "strata://action-graph/v1";
|
|
565
|
-
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. Cancel-all is atomically bounded to six orders per call. Stop on ambiguity, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
|
|
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. Cancel-all is atomically bounded to six orders per call. Stop on ambiguity, unavailable capabilities, paused markets, unsupported contracts, inconsistent bindings, expiry, or missing signer authority.";
|
package/dist/src/server.js
CHANGED
|
@@ -407,6 +407,24 @@ export async function createStrataMcpServer(options = {}) {
|
|
|
407
407
|
});
|
|
408
408
|
return toolResult(response, `Submitted ${response.action} control ${response.order_control_id} as ${response.signature}.`);
|
|
409
409
|
}));
|
|
410
|
+
const orderStatus = server.registerTool("strata_order_status", {
|
|
411
|
+
title: "Read Strata order-control status",
|
|
412
|
+
description: "Recover the durable result for an externally signed order submission after a timeout or restart.",
|
|
413
|
+
inputSchema: {
|
|
414
|
+
marketId: z.string().regex(/^market_[0-9a-f]{32}$/),
|
|
415
|
+
orderControlId: z.string().regex(/^or_[0-9a-f]{32}$/),
|
|
416
|
+
idempotencyKey: z.string().min(1).max(64).regex(/^[A-Za-z0-9._-]+$/),
|
|
417
|
+
},
|
|
418
|
+
annotations: {
|
|
419
|
+
readOnlyHint: true,
|
|
420
|
+
destructiveHint: false,
|
|
421
|
+
idempotentHint: true,
|
|
422
|
+
openWorldHint: true,
|
|
423
|
+
},
|
|
424
|
+
}, async ({ marketId, orderControlId, idempotencyKey }) => guardedTool(client, "orders.submit", async () => {
|
|
425
|
+
const response = await platformClient.orders.status(marketId, { orderControlId, idempotencyKey });
|
|
426
|
+
return toolResult(response, `Order control ${response.order_control_id} is ${response.status}.`);
|
|
427
|
+
}));
|
|
410
428
|
const handles = {
|
|
411
429
|
markets,
|
|
412
430
|
quote,
|
|
@@ -416,6 +434,7 @@ export async function createStrataMcpServer(options = {}) {
|
|
|
416
434
|
orderChallenge,
|
|
417
435
|
orderPrepare,
|
|
418
436
|
orderSubmit,
|
|
437
|
+
orderStatus,
|
|
419
438
|
};
|
|
420
439
|
applyCapabilityCatalog(handles, initialCatalog);
|
|
421
440
|
let closed = false;
|
|
@@ -449,6 +468,7 @@ function applyCapabilityCatalog(handles, catalog) {
|
|
|
449
468
|
setToolEnabled(handles.orderChallenge, capabilityAvailable(catalog, "orders.prepare"));
|
|
450
469
|
setToolEnabled(handles.orderPrepare, capabilityAvailable(catalog, "orders.prepare"));
|
|
451
470
|
setToolEnabled(handles.orderSubmit, capabilityAvailable(catalog, "orders.submit"));
|
|
471
|
+
setToolEnabled(handles.orderStatus, capabilityAvailable(catalog, "orders.submit"));
|
|
452
472
|
}
|
|
453
473
|
function setToolEnabled(tool, enabled) {
|
|
454
474
|
if (enabled)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratabook/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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.6",
|
|
48
48
|
"zod": "^3.25.76"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|