twzrd-mcp-server 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/dist/index.d.ts +14 -0
- package/dist/index.js +257 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TWZRD MCP Server — auto-pay x402 wrapper for TWZRD's Trust API.
|
|
3
|
+
*
|
|
4
|
+
* Solana x402: the 402 challenge includes a sponsored feePayer + recentBlockhash.
|
|
5
|
+
* The MCP builds a USDC transfer, signs with the agent's Solana keypair, retries.
|
|
6
|
+
* Always runs free preflight before auto-paying (spend cap enforced).
|
|
7
|
+
*
|
|
8
|
+
* ENV:
|
|
9
|
+
* TWZRD_SOLANA_KEYPAIR — Solana keypair JSON array (from solana config)
|
|
10
|
+
* TWZRD_API_URL — Base URL (default: https://intel.twzrd.xyz)
|
|
11
|
+
* TWZRD_SPEND_CAP_USDC — Max USDC per call (default: 0.05)
|
|
12
|
+
* TWZRD_DAILY_CAP_USDC — Max USDC per day (default: 1.00)
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TWZRD MCP Server — auto-pay x402 wrapper for TWZRD's Trust API.
|
|
3
|
+
*
|
|
4
|
+
* Solana x402: the 402 challenge includes a sponsored feePayer + recentBlockhash.
|
|
5
|
+
* The MCP builds a USDC transfer, signs with the agent's Solana keypair, retries.
|
|
6
|
+
* Always runs free preflight before auto-paying (spend cap enforced).
|
|
7
|
+
*
|
|
8
|
+
* ENV:
|
|
9
|
+
* TWZRD_SOLANA_KEYPAIR — Solana keypair JSON array (from solana config)
|
|
10
|
+
* TWZRD_API_URL — Base URL (default: https://intel.twzrd.xyz)
|
|
11
|
+
* TWZRD_SPEND_CAP_USDC — Max USDC per call (default: 0.05)
|
|
12
|
+
* TWZRD_DAILY_CAP_USDC — Max USDC per day (default: 1.00)
|
|
13
|
+
*/
|
|
14
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
15
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
16
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
17
|
+
import { Connection, Keypair, PublicKey, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
|
|
18
|
+
import { getOrCreateAssociatedTokenAccount, createTransferInstruction } from "@solana/spl-token";
|
|
19
|
+
import * as fs from "fs";
|
|
20
|
+
import * as path from "path";
|
|
21
|
+
// ── Config ─────────────────────────────────────────────────────────────────
|
|
22
|
+
const API_BASE = process.env.TWZRD_API_URL || "https://intel.twzrd.xyz";
|
|
23
|
+
const KEYPAIR_SOURCE = process.env.TWZRD_SOLANA_KEYPAIR || "";
|
|
24
|
+
const SPEND_CAP_USDC = parseFloat(process.env.TWZRD_SPEND_CAP_USDC || "0.05");
|
|
25
|
+
const DAILY_CAP_USDC = parseFloat(process.env.TWZRD_DAILY_CAP_USDC || "1.00");
|
|
26
|
+
if (!KEYPAIR_SOURCE) {
|
|
27
|
+
console.error("TWZRD_SOLANA_KEYPAIR required — set to the Solana keypair JSON path or array");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
// ── Solana wallet ──────────────────────────────────────────────────────────
|
|
31
|
+
function loadKeypair(source) {
|
|
32
|
+
let bytes;
|
|
33
|
+
if (source.startsWith("[") || source.startsWith("{")) {
|
|
34
|
+
const parsed = JSON.parse(source);
|
|
35
|
+
const arr = Array.isArray(parsed) ? parsed : (parsed.secretKey || parsed);
|
|
36
|
+
bytes = Uint8Array.from(arr);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Path to keypair file
|
|
40
|
+
const content = fs.readFileSync(path.resolve(source), "utf-8");
|
|
41
|
+
bytes = Uint8Array.from(JSON.parse(content));
|
|
42
|
+
}
|
|
43
|
+
return Keypair.fromSecretKey(bytes);
|
|
44
|
+
}
|
|
45
|
+
const agentKeypair = loadKeypair(KEYPAIR_SOURCE);
|
|
46
|
+
const agentPubkey = agentKeypair.publicKey.toBase58();
|
|
47
|
+
// ── Spend cap tracking (in-memory, per-process) ────────────────────────────
|
|
48
|
+
let dailySpentUsdc = 0;
|
|
49
|
+
let dailyResetAt = Date.now() + 24 * 60 * 60 * 1000;
|
|
50
|
+
function checkSpendCap(amountUsdc) {
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
if (now > dailyResetAt) {
|
|
53
|
+
dailySpentUsdc = 0;
|
|
54
|
+
dailyResetAt = now + 24 * 60 * 60 * 1000;
|
|
55
|
+
}
|
|
56
|
+
if (amountUsdc > SPEND_CAP_USDC)
|
|
57
|
+
throw new Error(`Per-call spend cap ${SPEND_CAP_USDC} USDC exceeded (requested: ${amountUsdc})`);
|
|
58
|
+
if (dailySpentUsdc + amountUsdc > DAILY_CAP_USDC)
|
|
59
|
+
throw new Error(`Daily spend cap ${DAILY_CAP_USDC} USDC exceeded (spent: ${dailySpentUsdc}, would add: ${amountUsdc})`);
|
|
60
|
+
}
|
|
61
|
+
// ── x402 fetch: 402 → preflight → sign → retry (Solana scheme="exact") ─────
|
|
62
|
+
async function twzrdFetch(path, options) {
|
|
63
|
+
const url = `${API_BASE}${path}`;
|
|
64
|
+
const method = options?.method || "GET";
|
|
65
|
+
const body = options?.body ? JSON.stringify(options.body) : undefined;
|
|
66
|
+
// First attempt
|
|
67
|
+
const resp = await fetch(url, { method, headers: { "Content-Type": "application/json" }, body });
|
|
68
|
+
if (resp.status !== 402)
|
|
69
|
+
return resp;
|
|
70
|
+
// ── Parse 402 challenge ──
|
|
71
|
+
const challenge = await resp.json();
|
|
72
|
+
if (!challenge.x402Version)
|
|
73
|
+
return resp;
|
|
74
|
+
// Find Solana scheme (scheme === "exact")
|
|
75
|
+
const accepts = challenge.accepts || [];
|
|
76
|
+
const scheme = accepts.find((a) => a.scheme === "exact" && a.network?.startsWith("solana:"));
|
|
77
|
+
if (!scheme) {
|
|
78
|
+
throw new Error(`No Solana payment scheme found (got: ${JSON.stringify(accepts.map((a) => a.scheme))})`);
|
|
79
|
+
}
|
|
80
|
+
const amountMicro = parseInt(scheme.amount || "0", 10);
|
|
81
|
+
const amountUsdc = amountMicro / 1_000_000;
|
|
82
|
+
const payTo = scheme.payTo;
|
|
83
|
+
const feePayer = scheme.extra?.feePayer;
|
|
84
|
+
const recentBlockhash = scheme.extra?.recentBlockhash;
|
|
85
|
+
const usdcMint = scheme.asset;
|
|
86
|
+
// ── Run free preflight before paying ──
|
|
87
|
+
const preflightResp = await fetch(`${API_BASE}/v1/intel/preflight`, {
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: { "Content-Type": "application/json" },
|
|
90
|
+
body: JSON.stringify({
|
|
91
|
+
seller_wallet: payTo,
|
|
92
|
+
resource_name: "MCP Tool Call",
|
|
93
|
+
price_usdc: amountUsdc,
|
|
94
|
+
agent_intent: "x402_mcp_auto_pay",
|
|
95
|
+
}),
|
|
96
|
+
});
|
|
97
|
+
const preflight = await preflightResp.json();
|
|
98
|
+
const card = preflight?.readiness_card || {};
|
|
99
|
+
if (card.decision === "block") {
|
|
100
|
+
throw new Error(`Preflight BLOCKED payment to ${payTo}: ${(card.caveats || []).join("; ")}`);
|
|
101
|
+
}
|
|
102
|
+
// ── Check spend cap ──
|
|
103
|
+
checkSpendCap(amountUsdc);
|
|
104
|
+
// ── Build Solana USDC transfer (scheme === "exact") ──
|
|
105
|
+
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
|
|
106
|
+
// Get or create the agent's USDC ATA
|
|
107
|
+
const agentAta = await getOrCreateAssociatedTokenAccount(connection, agentKeypair, new PublicKey(usdcMint), agentKeypair.publicKey);
|
|
108
|
+
// Build transfer instruction
|
|
109
|
+
const transferIx = createTransferInstruction(agentAta.address, // source (agent's USDC ATA)
|
|
110
|
+
new PublicKey(payTo), // destination (merchant)
|
|
111
|
+
agentKeypair.publicKey, // owner
|
|
112
|
+
BigInt(amountMicro));
|
|
113
|
+
// Build transaction with sponsored feePayer
|
|
114
|
+
const feePayerPubkey = new PublicKey(feePayer);
|
|
115
|
+
const message = new TransactionMessage({
|
|
116
|
+
payerKey: feePayerPubkey,
|
|
117
|
+
recentBlockhash,
|
|
118
|
+
instructions: [transferIx],
|
|
119
|
+
}).compileToV0Message();
|
|
120
|
+
const tx = new VersionedTransaction(message);
|
|
121
|
+
tx.sign([agentKeypair]);
|
|
122
|
+
// Serialize and base64 encode for X-Payment header
|
|
123
|
+
const txBytes = tx.serialize();
|
|
124
|
+
const paymentHeader = Buffer.from(txBytes).toString("base64");
|
|
125
|
+
// ── Record spend ──
|
|
126
|
+
dailySpentUsdc += amountUsdc;
|
|
127
|
+
// ── Retry with payment header ──
|
|
128
|
+
const retryResp = await fetch(url, {
|
|
129
|
+
method,
|
|
130
|
+
headers: { "Content-Type": "application/json", "X-Payment": paymentHeader },
|
|
131
|
+
body,
|
|
132
|
+
});
|
|
133
|
+
if (retryResp.status === 402) {
|
|
134
|
+
const err = await retryResp.json();
|
|
135
|
+
// Refund the spend cap on failure
|
|
136
|
+
dailySpentUsdc -= amountUsdc;
|
|
137
|
+
throw new Error(`x402 payment failed: ${JSON.stringify(err).slice(0, 200)}`);
|
|
138
|
+
}
|
|
139
|
+
// Log successful payment
|
|
140
|
+
console.error(`[twzrd-mcp] paid ${amountUsdc} USDC → ${payTo.slice(0, 8)}.. for ${path} (daily: ${dailySpentUsdc.toFixed(3)}/${DAILY_CAP_USDC})`);
|
|
141
|
+
return retryResp;
|
|
142
|
+
}
|
|
143
|
+
// ── MCP Server ────────────────────────────────────────────────────────────
|
|
144
|
+
const server = new Server({ name: "twzrd-mcp-server", version: "0.1.0" }, { capabilities: { tools: {} } });
|
|
145
|
+
const TOOLS = [
|
|
146
|
+
{
|
|
147
|
+
name: "quick_trust",
|
|
148
|
+
description: "$0.001 quick Solana wallet reputation check. Auto-pays via x402 (Solana USDC). Always runs free preflight first.",
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
wallet: { type: "string", description: "Solana wallet address (base58)" },
|
|
153
|
+
},
|
|
154
|
+
required: ["wallet"],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "full_trust",
|
|
159
|
+
description: "$0.05 full trust intelligence + signed V6 receipt. Auto-pays via x402. Runs free preflight first.",
|
|
160
|
+
inputSchema: {
|
|
161
|
+
type: "object",
|
|
162
|
+
properties: {
|
|
163
|
+
wallet: { type: "string", description: "Solana wallet address (base58)" },
|
|
164
|
+
},
|
|
165
|
+
required: ["wallet"],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "preflight",
|
|
170
|
+
description: "Free pre-payment check. No payment needed. Returns readiness_card with allow/warn/block decision.",
|
|
171
|
+
inputSchema: {
|
|
172
|
+
type: "object",
|
|
173
|
+
properties: {
|
|
174
|
+
seller_wallet: { type: "string", description: "Seller wallet to evaluate" },
|
|
175
|
+
},
|
|
176
|
+
required: ["seller_wallet"],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "verify_receipt",
|
|
181
|
+
description: "Free — verify a TWZRD V6 receipt offline.",
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
leaf: { type: "string", description: "Hex keccak256 receipt leaf" },
|
|
186
|
+
signature: { type: "string", description: "Ed25519 signature" },
|
|
187
|
+
signing_pubkey: { type: "string", description: "Signer pubkey (base58)" },
|
|
188
|
+
},
|
|
189
|
+
required: ["leaf"],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "wallet_lookup",
|
|
194
|
+
description: "Free — discover which facilitators and counterparties a Solana wallet has.",
|
|
195
|
+
inputSchema: {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
wallet: { type: "string", description: "Solana wallet address (base58)" },
|
|
199
|
+
},
|
|
200
|
+
required: ["wallet"],
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
205
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
206
|
+
const { name, arguments: args } = request.params;
|
|
207
|
+
async function api(path, opts) {
|
|
208
|
+
const resp = await twzrdFetch(path, opts);
|
|
209
|
+
const text = await resp.text();
|
|
210
|
+
if (!resp.ok)
|
|
211
|
+
throw new Error(`TWZRD API ${resp.status}: ${text.slice(0, 200)}`);
|
|
212
|
+
return text;
|
|
213
|
+
}
|
|
214
|
+
switch (name) {
|
|
215
|
+
case "quick_trust": {
|
|
216
|
+
const wallet = String(args?.wallet || "");
|
|
217
|
+
if (!wallet)
|
|
218
|
+
throw new Error("wallet required");
|
|
219
|
+
return { content: [{ type: "text", text: await api(`/v1/intel/quick/${wallet}`) }] };
|
|
220
|
+
}
|
|
221
|
+
case "full_trust": {
|
|
222
|
+
const wallet = String(args?.wallet || "");
|
|
223
|
+
if (!wallet)
|
|
224
|
+
throw new Error("wallet required");
|
|
225
|
+
return { content: [{ type: "text", text: await api(`/v1/intel/trust/${wallet}`) }] };
|
|
226
|
+
}
|
|
227
|
+
case "preflight": {
|
|
228
|
+
return {
|
|
229
|
+
content: [{
|
|
230
|
+
type: "text",
|
|
231
|
+
text: await api("/v1/intel/preflight", { method: "POST", body: { seller_wallet: args?.seller_wallet, resource_name: "MCP Tool Call", price_usdc: 0.05 } }),
|
|
232
|
+
}],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
case "verify_receipt": {
|
|
236
|
+
return {
|
|
237
|
+
content: [{
|
|
238
|
+
type: "text",
|
|
239
|
+
text: await api("/v1/receipts/verify", { method: "POST", body: { leaf: args?.leaf, signature: args?.signature, signing_pubkey: args?.signing_pubkey } }),
|
|
240
|
+
}],
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
case "wallet_lookup": {
|
|
244
|
+
const wallet = String(args?.wallet || "");
|
|
245
|
+
if (!wallet)
|
|
246
|
+
throw new Error("wallet required");
|
|
247
|
+
return { content: [{ type: "text", text: await api(`/v1/intel/get_facilitator_footprint?wallet=${wallet}`) }] };
|
|
248
|
+
}
|
|
249
|
+
default:
|
|
250
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
// ── Start ─────────────────────────────────────────────────────────────────
|
|
254
|
+
const transport = new StdioServerTransport();
|
|
255
|
+
await server.connect(transport);
|
|
256
|
+
console.error(`TWZRD MCP Server — agent ${agentPubkey.slice(0, 8)}.., cap ${SPEND_CAP_USDC}/${DAILY_CAP_USDC} USDC`);
|
|
257
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACnG,OAAO,EACL,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,oBAAoB,GACzE,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iCAAiC,EAAE,yBAAyB,EAAc,MAAM,mBAAmB,CAAC;AAE7G,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,yBAAyB,CAAC;AACxE,MAAM,cAAc,GAAG,OAAO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,IAAI,EAAE,MAAM,GAAG,CAAC,8CAA8C,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QAClH,CAAC;QACD;YACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,6EAA6E;AAE7E,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAChC,OAAO,CAAC,KAAK,CAAC,4BAA4B,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,cAAc,IAAI,cAAc,OAAO,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "twzrd-mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for TWZRD Trust API — auto-pay x402, no manual payment handling needed",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"twzrd-mcp": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"prepublishOnly": "tsc",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"start": "node dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"x402",
|
|
23
|
+
"twzrd",
|
|
24
|
+
"mcp",
|
|
25
|
+
"trust",
|
|
26
|
+
"reputation"
|
|
27
|
+
],
|
|
28
|
+
"author": "TWZRD",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
32
|
+
"@solana/spl-token": "^0.4.14",
|
|
33
|
+
"@solana/web3.js": "^1.98.4",
|
|
34
|
+
"@x402/core": "^2.16.0",
|
|
35
|
+
"@x402/mcp": "^2.16.0",
|
|
36
|
+
"bs58": "^6.0.0",
|
|
37
|
+
"viem": "^2.53.1",
|
|
38
|
+
"zod": "^4.4.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
}
|
|
43
|
+
}
|