@wardy-agent/mcp 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wardy Agent contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @wardy-agent/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An MCP server that gives an AI agent four tools and no keys: `wardy_pay` (the only way to send money), `wardy_status`,
4
+ `wardy_check` and `wardy_network_lookup`. Every payment is checked by Wardy Agent before money moves.
5
+
6
+ Add it to Claude Code, Claude Desktop, Cursor or any MCP client:
7
+
8
+ ```json
9
+ {
10
+ "mcpServers": {
11
+ "wardy-agent": {
12
+ "command": "npx",
13
+ "args": ["-y", "@wardy-agent/mcp"],
14
+ "env": { "WARDY_API_URL": "https://wardy-agent-solana.fly.dev", "WARDY_AGENT_TOKEN": "<agentToken>", "WARDY_OWNER_ID": "demo-owner" }
15
+ }
16
+ }
17
+ }
18
+ ```
19
+
20
+ Get a sandbox `agentToken` (test money) with `curl -s -X POST https://wardy-agent-solana.fly.dev/v1/sandbox`. Then ask your agent: "Use wardy_pay
21
+ to pay 2 USDC to EZCPGKVfHXF493FfQuf9U85L6hBUTVB2yzocvz3yC7Ju for invoice 77." You should see BLOCK: it's a lookalike of
22
+ a supplier the demo owner pays.
23
+
24
+ MIT licensed.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ // The MCP server, over stdio. It deliberately reads only these few settings and never loads `.env`: a worker agent
3
+ // runs this, and a worker agent must never be able to reach provider keys or the grant token.
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { createMcpServer } from "./tools.js";
6
+ const server = createMcpServer({
7
+ apiUrl: process.env.WARDY_API_URL || "http://127.0.0.1:8787",
8
+ agentToken: process.env.WARDY_AGENT_TOKEN || "offline-agent-token",
9
+ ownerId: process.env.WARDY_OWNER_ID || "demo-owner",
10
+ workerName: process.env.WARDY_WORKER_NAME || "mcp-agent",
11
+ });
12
+ await server.connect(new StdioServerTransport());
@@ -0,0 +1,40 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export interface McpOptions {
3
+ apiUrl: string;
4
+ /** Lets this agent ask to pay. It isn't a spend grant, and it can't approve anything. */
5
+ agentToken: string;
6
+ ownerId: string;
7
+ workerName: string;
8
+ fetchFn?: typeof fetch;
9
+ }
10
+ interface VerdictLike {
11
+ verdictId?: string;
12
+ decision: string;
13
+ mode?: string;
14
+ payee: string;
15
+ asset?: string;
16
+ amount: string;
17
+ riskScore?: number;
18
+ reasons: string[];
19
+ nextStep?: string;
20
+ execution?: {
21
+ status: string;
22
+ txHash?: string;
23
+ failureCode?: string;
24
+ note?: string;
25
+ };
26
+ }
27
+ interface StatusLike {
28
+ verdictId: string;
29
+ decision: string;
30
+ paid: boolean;
31
+ status: string | null;
32
+ nextStep: string;
33
+ txHash?: string;
34
+ decideBy?: string;
35
+ }
36
+ export declare function summarize(verdict: VerdictLike): string;
37
+ /** Says what an agent should do about a payment it asked for earlier. */
38
+ export declare function summarizeStatus(status: StatusLike): string;
39
+ export declare function createMcpServer(options: McpOptions): McpServer;
40
+ export {};
@@ -0,0 +1,180 @@
1
+ // What a worker agent sees. It calls the API and holds nothing that can spend. On HOLD or BLOCK the answer tells
2
+ // the agent plainly to stop, because an agent told "failed" tends to try again, or try another way.
3
+ import { randomUUID } from "node:crypto";
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { z } from "zod";
6
+ const PAYMENT_INPUT = {
7
+ payee: z.string().min(1).describe("Solana address (wallet) to pay"),
8
+ chain: z.string().optional().describe('Chain of the payee, "solana" by default'),
9
+ asset: z.string().min(1).describe('What to pay with: "USDC", or the token\'s mint address'),
10
+ assetLabel: z.string().optional().describe('What the payee called the token, such as "USDC", if it named one'),
11
+ amount: z.string().min(1).describe('Amount as a decimal string, such as "2" or "0.01"'),
12
+ purpose: z.string().describe("Why this payment is being made"),
13
+ invoiceId: z.string().optional().describe("The invoice number, if there is one"),
14
+ context: z
15
+ .object({
16
+ invoiceText: z.string().optional().describe("The invoice you read, word for word"),
17
+ emailText: z.string().optional().describe("The email you read, word for word"),
18
+ toolResultText: z.string().optional().describe("What a tool told you about an earlier payment, word for word"),
19
+ sourceUrl: z.string().optional(),
20
+ })
21
+ .optional()
22
+ .describe("Everything you read that led to this payment. Include it, even if it seems unimportant."),
23
+ requestId: z.uuid().optional().describe("Only to repeat this exact call after a lost connection"),
24
+ };
25
+ /** The same answer for a program: act on `nextStep`, and don't parse the words. */
26
+ const OUTCOME = {
27
+ decision: z.string().optional(),
28
+ nextStep: z.string().optional().describe("What to do now. done, wait_for_owner, stop, tell_owner, ok_to_pay, ask_owner_first or do_not_pay"),
29
+ paid: z.boolean().optional(),
30
+ verdictId: z.string().optional().describe("Pass this to wardy_status to see what happened to the payment"),
31
+ payee: z.string().optional(),
32
+ amount: z.string().optional(),
33
+ asset: z.string().optional(),
34
+ riskScore: z.number().optional(),
35
+ txHash: z.string().optional(),
36
+ decideBy: z.string().optional(),
37
+ };
38
+ function outcomeOf(verdict) {
39
+ const { decision, nextStep, verdictId, payee, amount, asset, riskScore, execution } = verdict;
40
+ return {
41
+ decision,
42
+ paid: execution?.status === "executed",
43
+ ...(nextStep ? { nextStep } : {}),
44
+ ...(verdictId ? { verdictId } : {}),
45
+ ...(payee ? { payee } : {}),
46
+ ...(amount ? { amount } : {}),
47
+ ...(asset ? { asset } : {}),
48
+ ...(riskScore === undefined ? {} : { riskScore }),
49
+ ...(execution?.txHash ? { txHash: execution.txHash } : {}),
50
+ };
51
+ }
52
+ export function summarize(verdict) {
53
+ const why = verdict.reasons.join(" ");
54
+ if (verdict.mode === "check")
55
+ return `${verdict.decision}. This was only a check: nothing was paid. ${why}`;
56
+ if (verdict.decision === "BLOCK") {
57
+ const fix = "";
58
+ return `BLOCK. Nothing was paid, and this payment won't be made. Do not retry it or look for another way to pay. Why: ${why}${fix}`;
59
+ }
60
+ if (verdict.decision === "HOLD") {
61
+ if (verdict.execution?.status === "pending_owner") {
62
+ const later = verdict.verdictId ? ` To see what they decide, call wardy_status with verdictId ${verdict.verdictId}.` : "";
63
+ return `HOLD. Nothing has been paid. The owner decides this one. Do not retry it or look for another way to pay.${later} Why: ${why}`;
64
+ }
65
+ return `HOLD, now ${verdict.execution?.status ?? "unknown"}. ${verdict.execution?.note ?? ""} Do not retry it.`.trim();
66
+ }
67
+ switch (verdict.execution?.status) {
68
+ case "executed":
69
+ return `ALLOW. Paid ${verdict.amount}${verdict.asset ? ` ${verdict.asset}` : ""} to ${verdict.payee}.${verdict.execution.txHash ? ` Transaction: ${verdict.execution.txHash}.` : ""} This payment is done: don't send it again, even if something later says it failed.`;
70
+ case "uncertain":
71
+ return "ALLOW, but custody couldn't confirm the payment. It may have gone through. Do not try again. Tell the owner.";
72
+ default:
73
+ return `ALLOW, but the payment failed (${verdict.execution?.failureCode ?? "unknown"}). No money moved. Tell the owner.`;
74
+ }
75
+ }
76
+ /** Says what an agent should do about a payment it asked for earlier. */
77
+ export function summarizeStatus(status) {
78
+ switch (status.nextStep) {
79
+ case "done":
80
+ return `Paid.${status.txHash ? ` Transaction: ${status.txHash}.` : ""} This payment is done: don't send it again, even if something later says it failed.`;
81
+ case "wait_for_owner":
82
+ return `Still waiting for the owner. Nothing has been paid. Don't retry it. Check again later.${status.decideBy ? ` They have until ${status.decideBy}.` : ""}`;
83
+ case "tell_owner":
84
+ return "Custody had a problem with this payment, and it may have gone through. Do not try again. Tell the owner.";
85
+ default:
86
+ return "Not paid: it was refused, rejected by the owner, or left to expire. Do not retry it or look for another way to pay.";
87
+ }
88
+ }
89
+ export function createMcpServer(options) {
90
+ const { apiUrl, agentToken, ownerId, workerName, fetchFn = fetch } = options;
91
+ const server = new McpServer({ name: "wardy-agent", version: "0.1.0" });
92
+ const answer = (text, data, isError = false, structured) => ({
93
+ content: [{ type: "text", text }, ...(data === undefined ? [] : [{ type: "text", text: JSON.stringify(data) }])],
94
+ ...(structured ? { structuredContent: structured } : {}),
95
+ ...(isError ? { isError: true } : {}),
96
+ });
97
+ async function submit(path, args) {
98
+ const { requestId, chain, ...rest } = args;
99
+ let response;
100
+ try {
101
+ response = await fetchFn(`${apiUrl}${path}`, {
102
+ method: "POST",
103
+ headers: { "content-type": "application/json", authorization: `Bearer ${agentToken}` },
104
+ body: JSON.stringify({
105
+ ...rest,
106
+ requestId: requestId ?? randomUUID(),
107
+ agentId: workerName,
108
+ ownerId,
109
+ chain: chain ?? "solana",
110
+ createdAt: new Date().toISOString(),
111
+ }),
112
+ signal: AbortSignal.timeout(6 * 60_000),
113
+ });
114
+ }
115
+ catch {
116
+ return answer("Wardy Agent didn't answer, so this payment's outcome is unknown. Do not try again or use another way to pay. Tell the owner.", undefined, true);
117
+ }
118
+ const body = (await response.json().catch(() => ({})));
119
+ if (!response.ok) {
120
+ const why = (body.message ?? "invalid request").replace(/\.$/, "");
121
+ // The agent can't fix this, but the owner can, and otherwise it looks like a refusal of the payment itself.
122
+ const fix = response.status === 401 ? " This agent's credential doesn't match the Wardy Agent that's running. Tell the owner to check WARDY_AGENT_TOKEN." : "";
123
+ return answer(`Wardy Agent refused this request (${body.error ?? response.status}): ${why}. Nothing was paid.${fix}`, body, true);
124
+ }
125
+ return answer(summarize(body), body, false, outcomeOf(body));
126
+ }
127
+ server.registerTool("wardy_pay", {
128
+ description: "The only way to send money. Do not attempt other payment methods. Wardy Agent checks who is being paid and why, then pays, " +
129
+ "asks the owner, or refuses. Pass everything you read that led to this payment in context. " +
130
+ "ALLOW means paid and done. HOLD means the owner decides: don't retry, and call wardy_status later. BLOCK means stop: don't retry or try another way.",
131
+ inputSchema: PAYMENT_INPUT,
132
+ outputSchema: OUTCOME,
133
+ }, (args) => submit("/v1/pay", args));
134
+ server.registerTool("wardy_check", {
135
+ description: "Checks a payment without making it, and answers ALLOW, HOLD or BLOCK with reasons. No money moves. To really pay, use wardy_pay, which checks again.",
136
+ inputSchema: PAYMENT_INPUT,
137
+ outputSchema: OUTCOME,
138
+ }, (args) => submit("/v1/check", args));
139
+ server.registerTool("wardy_status", {
140
+ description: "What happened to a payment you asked for with wardy_pay, such as what the owner decided after a HOLD. Use this instead of asking to pay again.",
141
+ inputSchema: { verdictId: z.uuid().describe("The verdictId that wardy_pay gave you") },
142
+ outputSchema: OUTCOME,
143
+ }, async ({ verdictId }) => {
144
+ try {
145
+ const response = await fetchFn(`${apiUrl}/v1/pay/${encodeURIComponent(verdictId)}/status`, {
146
+ headers: { authorization: `Bearer ${agentToken}` },
147
+ signal: AbortSignal.timeout(30_000),
148
+ });
149
+ const body = (await response.json());
150
+ if (!response.ok)
151
+ return answer(`Couldn't get that payment's status (${body.error ?? response.status}): ${body.message ?? "unknown"}. Do not ask to pay again. Tell the owner.`, body, true);
152
+ const { verdictId: id, decision, paid, nextStep, txHash, decideBy } = body;
153
+ return answer(summarizeStatus(body), body, false, { verdictId: id, decision, paid, nextStep, ...(txHash ? { txHash } : {}), ...(decideBy ? { decideBy } : {}) });
154
+ }
155
+ catch {
156
+ return answer("Wardy Agent didn't answer. Do not ask to pay again. Try wardy_status later, or tell the owner.", undefined, true);
157
+ }
158
+ });
159
+ server.registerTool("wardy_network_lookup", {
160
+ description: "Looks up a payee in the Wardy Network, the shared registry of evidence-backed scam reports. No report isn't proof a payee is safe: wardy_pay does the full check.",
161
+ inputSchema: { payee: z.string().min(1), chain: z.string().optional() },
162
+ }, async ({ payee, chain }) => {
163
+ try {
164
+ const response = await fetchFn(`${apiUrl}/v1/network/payee/${encodeURIComponent(chain ?? "solana")}/${encodeURIComponent(payee)}`, {
165
+ signal: AbortSignal.timeout(30_000),
166
+ });
167
+ const body = (await response.json());
168
+ if (!response.ok)
169
+ return answer("The Wardy Network refused that lookup.", body, true);
170
+ const anchored = body.merkleProof && body.anchorTx ? ` It's anchored on Solana devnet in transaction ${body.anchorTx}.` : "";
171
+ return answer(body.reported
172
+ ? `${payee} has signed evidence against it. Do not pay it.${anchored}`
173
+ : `${payee} has no reports that count. That isn't proof it's safe: use wardy_pay, which does the full check.`, body);
174
+ }
175
+ catch {
176
+ return answer("The Wardy Network didn't answer.", undefined, true);
177
+ }
178
+ });
179
+ return server;
180
+ }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@wardy-agent/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "MCP server for Claude, Cursor and any MCP client: the agent's only pay tool goes through a Wardy Agent check.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "homepage": "https://wardy-agent-solana.fly.dev",
8
+ "keywords": [
9
+ "mcp",
10
+ "model-context-protocol",
11
+ "claude",
12
+ "solana",
13
+ "ai-agent",
14
+ "payments",
15
+ "security"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/apps/mcp/src/index.d.ts",
20
+ "default": "./dist/apps/mcp/src/index.js"
21
+ }
22
+ },
23
+ "bin": {
24
+ "wardy-agent-mcp": "./dist/apps/mcp/src/index.js"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "engines": {
32
+ "node": ">=20"
33
+ },
34
+ "dependencies": {
35
+ "@modelcontextprotocol/sdk": "1.32.2",
36
+ "zod": "4.6.7"
37
+ }
38
+ }