@floatonnear/mcp 0.1.0 → 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.
- package/dist/payloads.d.ts +18 -0
- package/dist/payloads.js +55 -0
- package/dist/server.js +18 -2
- package/package.json +42 -42
package/dist/payloads.d.ts
CHANGED
|
@@ -103,3 +103,21 @@ export declare const OWNER_PLANNERS: {
|
|
|
103
103
|
};
|
|
104
104
|
/** A ready-to-run command, so approving does not require trusting this server. */
|
|
105
105
|
export declare function toCliCommand(p: OwnerPayload, network?: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Require the owner to approve payments above `amount` at this node.
|
|
108
|
+
*
|
|
109
|
+
* A threshold is a gate INSIDE the caps: it can only make the vault more
|
|
110
|
+
* conservative, never less, so there is no value of it that moves more money
|
|
111
|
+
* than the budget tree already allowed. `null` removes it.
|
|
112
|
+
*/
|
|
113
|
+
export declare function planSetApprovalThreshold(vault: string, nodeId: number, amountBase: string | null): OwnerPayload;
|
|
114
|
+
/**
|
|
115
|
+
* Execute a held payment.
|
|
116
|
+
*
|
|
117
|
+
* Every limit is re-checked at approval time, so this can still be refused --
|
|
118
|
+
* by a cap tightened while it waited, or by an Intents quote that expired. That
|
|
119
|
+
* is the honest outcome and the warning says so.
|
|
120
|
+
*/
|
|
121
|
+
export declare function planApprovePayment(vault: string, requestId: string): OwnerPayload;
|
|
122
|
+
/** Decline a held payment. The ticket is discarded and nothing moves. */
|
|
123
|
+
export declare function planRejectPayment(vault: string, requestId: string): OwnerPayload;
|
package/dist/payloads.js
CHANGED
|
@@ -290,3 +290,58 @@ export function toCliCommand(p, network = "testnet") {
|
|
|
290
290
|
`attached-deposit '${p.depositYocto} yoctoNEAR' ` +
|
|
291
291
|
`sign-as <YOUR-OWNER-ACCOUNT> network-config ${network} sign-with-keychain send`);
|
|
292
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Require the owner to approve payments above `amount` at this node.
|
|
295
|
+
*
|
|
296
|
+
* A threshold is a gate INSIDE the caps: it can only make the vault more
|
|
297
|
+
* conservative, never less, so there is no value of it that moves more money
|
|
298
|
+
* than the budget tree already allowed. `null` removes it.
|
|
299
|
+
*/
|
|
300
|
+
export function planSetApprovalThreshold(vault, nodeId, amountBase) {
|
|
301
|
+
return {
|
|
302
|
+
receiverId: vault,
|
|
303
|
+
methodName: "set_approval_threshold",
|
|
304
|
+
args: { node_id: nodeId, amount: amountBase },
|
|
305
|
+
gasTgas: DEFAULT_GAS_TGAS,
|
|
306
|
+
depositYocto: ONE_YOCTO,
|
|
307
|
+
summary: amountBase
|
|
308
|
+
? `Payments above ${amountBase} (base units) from node ${nodeId} will need your approval`
|
|
309
|
+
: `Remove the approval threshold on node ${nodeId} — payments up to the caps run unattended`,
|
|
310
|
+
warnings: amountBase
|
|
311
|
+
? []
|
|
312
|
+
: ["After this, nothing at this node waits for a human: only the caps apply."],
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Execute a held payment.
|
|
317
|
+
*
|
|
318
|
+
* Every limit is re-checked at approval time, so this can still be refused --
|
|
319
|
+
* by a cap tightened while it waited, or by an Intents quote that expired. That
|
|
320
|
+
* is the honest outcome and the warning says so.
|
|
321
|
+
*/
|
|
322
|
+
export function planApprovePayment(vault, requestId) {
|
|
323
|
+
return {
|
|
324
|
+
receiverId: vault,
|
|
325
|
+
methodName: "approve_payment",
|
|
326
|
+
args: { request_id: requestId },
|
|
327
|
+
gasTgas: DEFAULT_GAS_TGAS,
|
|
328
|
+
depositYocto: ONE_YOCTO,
|
|
329
|
+
summary: `Approve and send held payment ${requestId}`,
|
|
330
|
+
warnings: [
|
|
331
|
+
"This MOVES MONEY. Check the amount and payee with vault_pending_approval first.",
|
|
332
|
+
"Limits are re-checked now, so it can still be refused — a cap lowered since the request, or a cross-chain quote that has expired.",
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
/** Decline a held payment. The ticket is discarded and nothing moves. */
|
|
337
|
+
export function planRejectPayment(vault, requestId) {
|
|
338
|
+
return {
|
|
339
|
+
receiverId: vault,
|
|
340
|
+
methodName: "reject_payment",
|
|
341
|
+
args: { request_id: requestId },
|
|
342
|
+
gasTgas: DEFAULT_GAS_TGAS,
|
|
343
|
+
depositYocto: ONE_YOCTO,
|
|
344
|
+
summary: `Reject held payment ${requestId}`,
|
|
345
|
+
warnings: ["The agent must request again if it still needs the money."],
|
|
346
|
+
};
|
|
347
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -22,7 +22,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
22
22
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
23
23
|
import { z } from "zod";
|
|
24
24
|
import { fromBaseUnits, toBaseUnits } from "./amounts.js";
|
|
25
|
-
import { DEFAULT_GAS_TGAS, planAddNode, planCreateAgentAccount, planFreezeNode, planPurgeSettled, planSetCooldown, planSetNodeCaps, planSetPaused, planSetRecipients, toCliCommand, } from "./payloads.js";
|
|
25
|
+
import { DEFAULT_GAS_TGAS, planAddNode, planCreateAgentAccount, planFreezeNode, planPurgeSettled, planSetCooldown, planSetNodeCaps, planSetPaused, planSetRecipients, toCliCommand, planSetApprovalThreshold, planApprovePayment, planRejectPayment, } from "./payloads.js";
|
|
26
26
|
import { DEFAULT_RPC_URL, newRequestId, requireAgentKey, viewFunction } from "./rpc.js";
|
|
27
27
|
import { buildRoute, sendRequestPayment } from "./sign.js";
|
|
28
28
|
import { getQuote, signBinding, toBase64 } from "./quote.js";
|
|
@@ -77,7 +77,17 @@ const limitShape = z
|
|
|
77
77
|
decimals: z.number().int().min(0).max(38).default(6),
|
|
78
78
|
}))
|
|
79
79
|
.min(1);
|
|
80
|
-
|
|
80
|
+
// The name a client displays in its server list, so this string -- not the
|
|
81
|
+
// package name, not the config key -- is the product's label in the one place
|
|
82
|
+
// the product is visible. It was "near-vault": the repo's directory name,
|
|
83
|
+
// leaking outward as the user-facing identity while the config key create-float
|
|
84
|
+
// writes has always been `float`.
|
|
85
|
+
//
|
|
86
|
+
// The version stays a literal rather than being read from package.json at
|
|
87
|
+
// startup: a wrong relative path would break the server outright instead of
|
|
88
|
+
// merely reporting a stale version. server.smoke.test.ts asserts the two agree,
|
|
89
|
+
// so a bump cannot land with only one of them moved.
|
|
90
|
+
const server = new McpServer({ name: "float", version: "0.2.0" });
|
|
81
91
|
// ----------------------------------------------------------------- reads
|
|
82
92
|
server.tool("vault_tree", "Read the whole budget tree: every node, its caps, parent, bound agent account, cooldown and freeze state. No key required.", {}, async () => json(await viewFunction(cfg.rpcUrl, requireVault(), "get_tree", {})));
|
|
83
93
|
server.tool("vault_budget", "Read one node's budget for a UTC day: cap, executed, in-flight (pending) and available, in human units. Omit `day` for today. No key required.", {
|
|
@@ -198,6 +208,12 @@ server.tool("vault_plan_create_agent", "Build an UNSIGNED payload to create an a
|
|
|
198
208
|
server.tool("vault_plan_freeze", "Build an UNSIGNED payload to freeze or unfreeze a node. Freezing blocks the node AND its whole subtree. Not signed by this server.", { nodeId: z.number().int().min(0), frozen: z.boolean() }, async ({ nodeId, frozen }) => renderPlan(planFreezeNode(requireVault(), nodeId, frozen)));
|
|
199
209
|
server.tool("vault_plan_set_recipients", "Build an UNSIGNED payload to set a node's payee allowlist. This REPLACES the inherited list rather than adding to it; pass null to inherit. Not signed by this server.", { nodeId: z.number().int().min(0), recipients: z.array(z.string()).nullable() }, async ({ nodeId, recipients }) => renderPlan(planSetRecipients(requireVault(), nodeId, recipients)));
|
|
200
210
|
server.tool("vault_plan_set_cooldown", "Build an UNSIGNED payload to set the minimum seconds between a node's payments. Not signed by this server.", { nodeId: z.number().int().min(0), cooldownSec: z.number().int().min(0) }, async ({ nodeId, cooldownSec }) => renderPlan(planSetCooldown(requireVault(), nodeId, cooldownSec)));
|
|
211
|
+
server.tool("vault_pending_approval", "Look up a payment that is HELD awaiting the owner's approval. Returns null if there is no ticket for that id — already approved, already rejected, or never held.", { requestId: z.string().min(1) }, async ({ requestId }) => json((await viewFunction(cfg.rpcUrl, requireVault(), "get_pending_approval", {
|
|
212
|
+
request_id: requestId,
|
|
213
|
+
})) ?? null));
|
|
214
|
+
server.tool("vault_plan_set_approval_threshold", "Build an UNSIGNED payload requiring the owner's approval for payments above an amount at this node. A threshold sits INSIDE the caps and can only make the vault more conservative. Pass amountBase null to remove it. Not signed by this server.", { nodeId: z.number().int().min(0), amountBase: z.string().min(1).nullable() }, async ({ nodeId, amountBase }) => renderPlan(planSetApprovalThreshold(requireVault(), nodeId, amountBase)));
|
|
215
|
+
server.tool("vault_plan_approve_payment", "Build an UNSIGNED payload to APPROVE a held payment, which sends it. Every limit is re-checked at approval, so it can still be refused. Not signed by this server.", { requestId: z.string().min(1) }, async ({ requestId }) => renderPlan(planApprovePayment(requireVault(), requestId)));
|
|
216
|
+
server.tool("vault_plan_reject_payment", "Build an UNSIGNED payload to REJECT a held payment. Nothing moves and the ticket is discarded. Not signed by this server.", { requestId: z.string().min(1) }, async ({ requestId }) => renderPlan(planRejectPayment(requireVault(), requestId)));
|
|
201
217
|
server.tool("vault_plan_pause", "Build an UNSIGNED payload to pause or resume the whole vault. Pausing halts every agent payment. Not signed by this server.", { paused: z.boolean() }, async ({ paused }) => renderPlan(planSetPaused(requireVault(), paused)));
|
|
202
218
|
server.tool("vault_plan_purge", "Build an UNSIGNED payload to delete settled payment records older than a UTC day. Spend totals are NOT refunded, but a deleted request id becomes reusable. Not signed by this server.", {
|
|
203
219
|
beforeDay: z.number().int().min(0),
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@floatonnear/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "MCP server for the hierarchical budget vault. The agent key signs request_payment only; owner methods emit unsigned payloads for wallet approval.",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"bin": {
|
|
8
|
-
"mcp": "dist/server.js",
|
|
9
|
-
"float-mcp": "dist/server.js"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist/"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc -p tsconfig.json",
|
|
16
|
-
"prepack": "npm run build",
|
|
17
|
-
"test": "vitest run",
|
|
18
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
22
|
-
"@noble/curves": "^1.9.7",
|
|
23
|
-
"@noble/hashes": "^1.8.0",
|
|
24
|
-
"near-api-js": "^7.4.0",
|
|
25
|
-
"zod": "^4.6.7"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/node": "^24.0.0",
|
|
29
|
-
"typescript": "^5.9.0",
|
|
30
|
-
"vitest": "^5.0.5"
|
|
31
|
-
},
|
|
32
|
-
"exports": {
|
|
33
|
-
".": "./dist/index.js",
|
|
34
|
-
"./amounts": "./dist/amounts.js",
|
|
35
|
-
"./sign": "./dist/sign.js",
|
|
36
|
-
"./payloads": "./dist/payloads.js",
|
|
37
|
-
"./quote": {
|
|
38
|
-
"types": "./dist/quote.d.ts",
|
|
39
|
-
"import": "./dist/quote.js"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@floatonnear/mcp",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "MCP server for the hierarchical budget vault. The agent key signs request_payment only; owner methods emit unsigned payloads for wallet approval.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp": "dist/server.js",
|
|
9
|
+
"float-mcp": "dist/server.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.json",
|
|
16
|
+
"prepack": "npm run build",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
22
|
+
"@noble/curves": "^1.9.7",
|
|
23
|
+
"@noble/hashes": "^1.8.0",
|
|
24
|
+
"near-api-js": "^7.4.0",
|
|
25
|
+
"zod": "^4.6.7"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.0.0",
|
|
29
|
+
"typescript": "^5.9.0",
|
|
30
|
+
"vitest": "^5.0.5"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.js",
|
|
34
|
+
"./amounts": "./dist/amounts.js",
|
|
35
|
+
"./sign": "./dist/sign.js",
|
|
36
|
+
"./payloads": "./dist/payloads.js",
|
|
37
|
+
"./quote": {
|
|
38
|
+
"types": "./dist/quote.d.ts",
|
|
39
|
+
"import": "./dist/quote.js"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|