clawdentials-mcp 0.1.0 → 0.7.2

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.
Files changed (35) hide show
  1. package/README.md +310 -58
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +225 -18
  4. package/dist/schemas/index.d.ts +141 -0
  5. package/dist/schemas/index.js +54 -0
  6. package/dist/services/firestore.d.ts +45 -2
  7. package/dist/services/firestore.js +410 -6
  8. package/dist/services/payments/alby.d.ts +104 -0
  9. package/dist/services/payments/alby.js +239 -0
  10. package/dist/services/payments/breez.d.ts +91 -0
  11. package/dist/services/payments/breez.js +267 -0
  12. package/dist/services/payments/cashu.d.ts +127 -0
  13. package/dist/services/payments/cashu.js +248 -0
  14. package/dist/services/payments/coinremitter.d.ts +84 -0
  15. package/dist/services/payments/coinremitter.js +176 -0
  16. package/dist/services/payments/index.d.ts +132 -0
  17. package/dist/services/payments/index.js +180 -0
  18. package/dist/services/payments/oxapay.d.ts +89 -0
  19. package/dist/services/payments/oxapay.js +221 -0
  20. package/dist/services/payments/x402.d.ts +61 -0
  21. package/dist/services/payments/x402.js +94 -0
  22. package/dist/services/payments/zbd.d.ts +88 -0
  23. package/dist/services/payments/zbd.js +221 -0
  24. package/dist/tools/admin.d.ts +195 -0
  25. package/dist/tools/admin.js +210 -0
  26. package/dist/tools/agent.d.ts +197 -0
  27. package/dist/tools/agent.js +200 -0
  28. package/dist/tools/escrow.d.ts +74 -16
  29. package/dist/tools/escrow.js +139 -28
  30. package/dist/tools/index.d.ts +3 -0
  31. package/dist/tools/index.js +3 -0
  32. package/dist/tools/payment.d.ts +144 -0
  33. package/dist/tools/payment.js +376 -0
  34. package/dist/types/index.d.ts +44 -1
  35. package/package.json +18 -2
@@ -1,50 +1,67 @@
1
- import { z } from 'zod';
2
- import { type EscrowCreateInput, type EscrowCompleteInput, type EscrowStatusInput } from '../schemas/index.js';
1
+ import { type EscrowCreateInput, type EscrowCompleteInput, type EscrowStatusInput, type EscrowDisputeInput } from '../schemas/index.js';
3
2
  export declare const escrowTools: {
4
3
  escrow_create: {
5
4
  description: string;
6
- inputSchema: z.ZodObject<{
7
- taskDescription: z.ZodString;
8
- amount: z.ZodNumber;
9
- currency: z.ZodDefault<z.ZodEnum<["USD", "USDC", "BTC"]>>;
10
- providerAgentId: z.ZodString;
11
- clientAgentId: z.ZodString;
12
- }, "strip", z.ZodTypeAny, {
5
+ inputSchema: import("zod").ZodObject<{
6
+ taskDescription: import("zod").ZodString;
7
+ amount: import("zod").ZodNumber;
8
+ currency: import("zod").ZodDefault<import("zod").ZodEnum<["USD", "USDC", "BTC"]>>;
9
+ providerAgentId: import("zod").ZodString;
10
+ clientAgentId: import("zod").ZodString;
11
+ apiKey: import("zod").ZodString;
12
+ }, "strip", import("zod").ZodTypeAny, {
13
13
  taskDescription: string;
14
14
  amount: number;
15
15
  currency: "USD" | "USDC" | "BTC";
16
16
  providerAgentId: string;
17
17
  clientAgentId: string;
18
+ apiKey: string;
18
19
  }, {
19
20
  taskDescription: string;
20
21
  amount: number;
21
22
  providerAgentId: string;
22
23
  clientAgentId: string;
24
+ apiKey: string;
23
25
  currency?: "USD" | "USDC" | "BTC" | undefined;
24
26
  }>;
25
27
  handler: (input: EscrowCreateInput) => Promise<{
28
+ success: boolean;
29
+ error: string;
30
+ escrowId?: undefined;
31
+ message?: undefined;
32
+ escrow?: undefined;
33
+ newBalance?: undefined;
34
+ } | {
26
35
  success: boolean;
27
36
  escrowId: string;
28
37
  message: string;
29
38
  escrow: {
30
39
  id: string;
31
40
  amount: number;
41
+ fee: number;
42
+ feeRate: number;
43
+ netAmount: number;
32
44
  currency: import("../types/index.js").Currency;
33
45
  status: import("../types/index.js").EscrowStatus;
34
46
  providerAgentId: string;
35
47
  createdAt: string;
36
48
  };
49
+ newBalance: number;
50
+ error?: undefined;
37
51
  }>;
38
52
  };
39
53
  escrow_complete: {
40
54
  description: string;
41
- inputSchema: z.ZodObject<{
42
- escrowId: z.ZodString;
43
- proofOfWork: z.ZodString;
44
- }, "strip", z.ZodTypeAny, {
55
+ inputSchema: import("zod").ZodObject<{
56
+ escrowId: import("zod").ZodString;
57
+ proofOfWork: import("zod").ZodString;
58
+ apiKey: import("zod").ZodString;
59
+ }, "strip", import("zod").ZodTypeAny, {
60
+ apiKey: string;
45
61
  escrowId: string;
46
62
  proofOfWork: string;
47
63
  }, {
64
+ apiKey: string;
48
65
  escrowId: string;
49
66
  proofOfWork: string;
50
67
  }>;
@@ -53,25 +70,29 @@ export declare const escrowTools: {
53
70
  error: string;
54
71
  message?: undefined;
55
72
  escrow?: undefined;
73
+ newBalance?: undefined;
56
74
  } | {
57
75
  success: boolean;
58
76
  message: string;
59
77
  escrow: {
60
78
  id: string;
61
79
  amount: number;
80
+ fee: number;
81
+ netAmount: number;
62
82
  currency: import("../types/index.js").Currency;
63
83
  status: import("../types/index.js").EscrowStatus;
64
84
  completedAt: string | undefined;
65
85
  proofOfWork: string | null;
66
86
  };
87
+ newBalance: number;
67
88
  error?: undefined;
68
89
  }>;
69
90
  };
70
91
  escrow_status: {
71
92
  description: string;
72
- inputSchema: z.ZodObject<{
73
- escrowId: z.ZodString;
74
- }, "strip", z.ZodTypeAny, {
93
+ inputSchema: import("zod").ZodObject<{
94
+ escrowId: import("zod").ZodString;
95
+ }, "strip", import("zod").ZodTypeAny, {
75
96
  escrowId: string;
76
97
  }, {
77
98
  escrowId: string;
@@ -88,11 +109,48 @@ export declare const escrowTools: {
88
109
  providerAgentId: string;
89
110
  taskDescription: string;
90
111
  amount: number;
112
+ fee: number;
113
+ feeRate: number;
114
+ netAmount: number;
91
115
  currency: import("../types/index.js").Currency;
92
116
  status: import("../types/index.js").EscrowStatus;
93
117
  createdAt: string;
94
118
  completedAt: string | null;
95
119
  proofOfWork: string | null;
120
+ disputeReason: string | null;
121
+ };
122
+ error?: undefined;
123
+ }>;
124
+ };
125
+ escrow_dispute: {
126
+ description: string;
127
+ inputSchema: import("zod").ZodObject<{
128
+ escrowId: import("zod").ZodString;
129
+ reason: import("zod").ZodString;
130
+ apiKey: import("zod").ZodString;
131
+ }, "strip", import("zod").ZodTypeAny, {
132
+ apiKey: string;
133
+ escrowId: string;
134
+ reason: string;
135
+ }, {
136
+ apiKey: string;
137
+ escrowId: string;
138
+ reason: string;
139
+ }>;
140
+ handler: (input: EscrowDisputeInput) => Promise<{
141
+ success: boolean;
142
+ error: string;
143
+ message?: undefined;
144
+ escrow?: undefined;
145
+ } | {
146
+ success: boolean;
147
+ message: string;
148
+ escrow: {
149
+ id: string;
150
+ status: import("../types/index.js").EscrowStatus;
151
+ disputeReason: string | null;
152
+ amount: number;
153
+ currency: import("../types/index.js").Currency;
96
154
  };
97
155
  error?: undefined;
98
156
  }>;
@@ -1,35 +1,64 @@
1
- import { escrowCreateSchema, escrowCompleteSchema, escrowStatusSchema, } from '../schemas/index.js';
2
- import { createEscrow, getEscrow, completeEscrow } from '../services/firestore.js';
1
+ import { escrowCreateSchema, escrowCompleteSchema, escrowStatusSchema, escrowDisputeSchema, } from '../schemas/index.js';
2
+ import { getEscrow, disputeEscrow, FEE_RATE, validateApiKey, createEscrowWithBalance, completeEscrowWithBalance, getBalance, } from '../services/firestore.js';
3
3
  export const escrowTools = {
4
4
  escrow_create: {
5
- description: 'Create a new escrow to lock funds for a task. The funds will be held until the task is completed.',
5
+ description: 'Create a new escrow to lock funds for a task. Requires API key and sufficient balance.',
6
6
  inputSchema: escrowCreateSchema,
7
7
  handler: async (input) => {
8
- const escrow = await createEscrow({
9
- clientAgentId: input.clientAgentId,
10
- providerAgentId: input.providerAgentId,
11
- taskDescription: input.taskDescription,
12
- amount: input.amount,
13
- currency: input.currency,
14
- status: 'pending',
15
- });
16
- return {
17
- success: true,
18
- escrowId: escrow.id,
19
- message: `Escrow created successfully. ${input.amount} ${input.currency} locked for task: "${input.taskDescription}"`,
20
- escrow: {
21
- id: escrow.id,
22
- amount: escrow.amount,
23
- currency: escrow.currency,
24
- status: escrow.status,
25
- providerAgentId: escrow.providerAgentId,
26
- createdAt: escrow.createdAt.toISOString(),
27
- },
28
- };
8
+ // Validate API key
9
+ const isValid = await validateApiKey(input.clientAgentId, input.apiKey);
10
+ if (!isValid) {
11
+ return {
12
+ success: false,
13
+ error: 'Invalid API key for client agent',
14
+ };
15
+ }
16
+ // Check balance first
17
+ const balance = await getBalance(input.clientAgentId);
18
+ if (balance < input.amount) {
19
+ return {
20
+ success: false,
21
+ error: `Insufficient balance: have ${balance} ${input.currency}, need ${input.amount} ${input.currency}. Add funds first.`,
22
+ };
23
+ }
24
+ try {
25
+ const escrow = await createEscrowWithBalance({
26
+ clientAgentId: input.clientAgentId,
27
+ providerAgentId: input.providerAgentId,
28
+ taskDescription: input.taskDescription,
29
+ amount: input.amount,
30
+ currency: input.currency,
31
+ status: 'pending',
32
+ });
33
+ const netAmount = escrow.amount - escrow.fee;
34
+ return {
35
+ success: true,
36
+ escrowId: escrow.id,
37
+ message: `Escrow created. ${input.amount} ${input.currency} deducted from your balance. Provider receives ${netAmount} ${input.currency} on completion (${FEE_RATE * 100}% fee).`,
38
+ escrow: {
39
+ id: escrow.id,
40
+ amount: escrow.amount,
41
+ fee: escrow.fee,
42
+ feeRate: escrow.feeRate,
43
+ netAmount,
44
+ currency: escrow.currency,
45
+ status: escrow.status,
46
+ providerAgentId: escrow.providerAgentId,
47
+ createdAt: escrow.createdAt.toISOString(),
48
+ },
49
+ newBalance: balance - input.amount,
50
+ };
51
+ }
52
+ catch (error) {
53
+ return {
54
+ success: false,
55
+ error: error instanceof Error ? error.message : 'Failed to create escrow',
56
+ };
57
+ }
29
58
  },
30
59
  },
31
60
  escrow_complete: {
32
- description: 'Mark an escrow as complete and release the funds to the provider agent. Requires proof of work.',
61
+ description: 'Mark an escrow as complete and release funds to provider. Only the provider can complete.',
33
62
  inputSchema: escrowCompleteSchema,
34
63
  handler: async (input) => {
35
64
  const existingEscrow = await getEscrow(input.escrowId);
@@ -39,6 +68,14 @@ export const escrowTools = {
39
68
  error: `Escrow not found: ${input.escrowId}`,
40
69
  };
41
70
  }
71
+ // Validate API key - must be the provider
72
+ const isValid = await validateApiKey(existingEscrow.providerAgentId, input.apiKey);
73
+ if (!isValid) {
74
+ return {
75
+ success: false,
76
+ error: 'Invalid API key. Only the provider agent can complete this escrow.',
77
+ };
78
+ }
42
79
  if (existingEscrow.status === 'completed') {
43
80
  return {
44
81
  success: false,
@@ -51,23 +88,34 @@ export const escrowTools = {
51
88
  error: 'Escrow was cancelled',
52
89
  };
53
90
  }
54
- const escrow = await completeEscrow(input.escrowId, input.proofOfWork);
91
+ if (existingEscrow.status === 'disputed') {
92
+ return {
93
+ success: false,
94
+ error: 'Escrow is disputed. Contact admin for resolution.',
95
+ };
96
+ }
97
+ const escrow = await completeEscrowWithBalance(input.escrowId, input.proofOfWork);
98
+ const netAmount = escrow.amount - escrow.fee;
99
+ const newBalance = await getBalance(escrow.providerAgentId);
55
100
  return {
56
101
  success: true,
57
- message: `Escrow completed. ${escrow.amount} ${escrow.currency} released to ${escrow.providerAgentId}`,
102
+ message: `Escrow completed! ${netAmount} ${escrow.currency} credited to your balance.`,
58
103
  escrow: {
59
104
  id: escrow.id,
60
105
  amount: escrow.amount,
106
+ fee: escrow.fee,
107
+ netAmount,
61
108
  currency: escrow.currency,
62
109
  status: escrow.status,
63
110
  completedAt: escrow.completedAt?.toISOString(),
64
111
  proofOfWork: escrow.proofOfWork,
65
112
  },
113
+ newBalance,
66
114
  };
67
115
  },
68
116
  },
69
117
  escrow_status: {
70
- description: 'Check the current status of an escrow.',
118
+ description: 'Check the current status of an escrow. Public - no auth required.',
71
119
  inputSchema: escrowStatusSchema,
72
120
  handler: async (input) => {
73
121
  const escrow = await getEscrow(input.escrowId);
@@ -85,13 +133,76 @@ export const escrowTools = {
85
133
  providerAgentId: escrow.providerAgentId,
86
134
  taskDescription: escrow.taskDescription,
87
135
  amount: escrow.amount,
136
+ fee: escrow.fee,
137
+ feeRate: escrow.feeRate,
138
+ netAmount: escrow.amount - escrow.fee,
88
139
  currency: escrow.currency,
89
140
  status: escrow.status,
90
141
  createdAt: escrow.createdAt.toISOString(),
91
142
  completedAt: escrow.completedAt?.toISOString() ?? null,
92
143
  proofOfWork: escrow.proofOfWork,
144
+ disputeReason: escrow.disputeReason,
93
145
  },
94
146
  };
95
147
  },
96
148
  },
149
+ escrow_dispute: {
150
+ description: 'Flag an escrow for dispute. Only the client can dispute.',
151
+ inputSchema: escrowDisputeSchema,
152
+ handler: async (input) => {
153
+ const existingEscrow = await getEscrow(input.escrowId);
154
+ if (!existingEscrow) {
155
+ return {
156
+ success: false,
157
+ error: `Escrow not found: ${input.escrowId}`,
158
+ };
159
+ }
160
+ // Validate API key - must be the client
161
+ const isValid = await validateApiKey(existingEscrow.clientAgentId, input.apiKey);
162
+ if (!isValid) {
163
+ return {
164
+ success: false,
165
+ error: 'Invalid API key. Only the client agent can dispute this escrow.',
166
+ };
167
+ }
168
+ if (existingEscrow.status === 'completed') {
169
+ return {
170
+ success: false,
171
+ error: 'Cannot dispute a completed escrow',
172
+ };
173
+ }
174
+ if (existingEscrow.status === 'cancelled') {
175
+ return {
176
+ success: false,
177
+ error: 'Cannot dispute a cancelled escrow',
178
+ };
179
+ }
180
+ if (existingEscrow.status === 'disputed') {
181
+ return {
182
+ success: false,
183
+ error: 'Escrow is already disputed',
184
+ };
185
+ }
186
+ try {
187
+ const escrow = await disputeEscrow(input.escrowId, input.reason);
188
+ return {
189
+ success: true,
190
+ message: `Escrow disputed. Funds are held pending admin review. Reason: "${input.reason}"`,
191
+ escrow: {
192
+ id: escrow.id,
193
+ status: escrow.status,
194
+ disputeReason: escrow.disputeReason,
195
+ amount: escrow.amount,
196
+ currency: escrow.currency,
197
+ },
198
+ };
199
+ }
200
+ catch (error) {
201
+ return {
202
+ success: false,
203
+ error: error instanceof Error ? error.message : 'Failed to dispute escrow',
204
+ };
205
+ }
206
+ },
207
+ },
97
208
  };
@@ -1 +1,4 @@
1
1
  export { escrowTools } from './escrow.js';
2
+ export { agentTools } from './agent.js';
3
+ export { adminTools } from './admin.js';
4
+ export { paymentTools } from './payment.js';
@@ -1 +1,4 @@
1
1
  export { escrowTools } from './escrow.js';
2
+ export { agentTools } from './agent.js';
3
+ export { adminTools } from './admin.js';
4
+ export { paymentTools } from './payment.js';
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Payment MCP Tools
3
+ *
4
+ * Tools for deposits and withdrawals in USDC, USDT, and BTC
5
+ */
6
+ export declare const paymentTools: {
7
+ /**
8
+ * Create a deposit request (USDC, USDT, or BTC)
9
+ */
10
+ deposit_create: {
11
+ description: string;
12
+ handler: (args: {
13
+ agentId: string;
14
+ apiKey: string;
15
+ amount: number;
16
+ currency: "USDC" | "USDT" | "BTC";
17
+ }) => Promise<{
18
+ success: boolean;
19
+ error: string | undefined;
20
+ depositId?: undefined;
21
+ currency?: undefined;
22
+ amount?: undefined;
23
+ paymentInstructions?: undefined;
24
+ message?: undefined;
25
+ } | {
26
+ success: boolean;
27
+ depositId: string | undefined;
28
+ currency: "USDC" | "BTC" | "USDT";
29
+ amount: number;
30
+ paymentInstructions: {
31
+ currency: import("../types/index.js").Currency;
32
+ network: import("../types/index.js").PaymentNetwork;
33
+ address?: string;
34
+ url?: string;
35
+ amount: number;
36
+ amountRaw?: string;
37
+ expiresAt?: Date;
38
+ qrData?: string;
39
+ } | undefined;
40
+ message: string;
41
+ error?: undefined;
42
+ }>;
43
+ };
44
+ /**
45
+ * Check deposit status - verifies with payment provider and auto-credits if paid
46
+ */
47
+ deposit_status: {
48
+ description: string;
49
+ handler: (args: {
50
+ depositId: string;
51
+ }) => Promise<any>;
52
+ };
53
+ /**
54
+ * Get payment configuration status
55
+ */
56
+ payment_config: {
57
+ description: string;
58
+ handler: () => Promise<{
59
+ success: boolean;
60
+ paymentMethods: {
61
+ usdc: {
62
+ configured: boolean;
63
+ network: string;
64
+ provider: string;
65
+ };
66
+ usdt: {
67
+ configured: boolean;
68
+ network: string;
69
+ provider: string;
70
+ };
71
+ btc: {
72
+ configured: boolean;
73
+ network: string;
74
+ provider: string;
75
+ };
76
+ };
77
+ supported: {
78
+ USDC: boolean;
79
+ USDT: boolean;
80
+ BTC: boolean;
81
+ };
82
+ }>;
83
+ };
84
+ /**
85
+ * Request crypto withdrawal
86
+ */
87
+ withdraw_crypto: {
88
+ description: string;
89
+ handler: (args: {
90
+ agentId: string;
91
+ apiKey: string;
92
+ amount: number;
93
+ currency: "USDC" | "USDT" | "BTC";
94
+ destination: string;
95
+ }) => Promise<{
96
+ success: boolean;
97
+ error: string;
98
+ withdrawalId?: undefined;
99
+ status?: undefined;
100
+ txId?: undefined;
101
+ message?: undefined;
102
+ newBalance?: undefined;
103
+ } | {
104
+ success: boolean;
105
+ withdrawalId: string;
106
+ status: string;
107
+ txId: string | undefined;
108
+ message: string;
109
+ error?: undefined;
110
+ newBalance?: undefined;
111
+ } | {
112
+ success: boolean;
113
+ withdrawalId: string;
114
+ status: string;
115
+ message: string;
116
+ newBalance: number;
117
+ error?: undefined;
118
+ txId?: undefined;
119
+ }>;
120
+ };
121
+ /**
122
+ * Set wallet addresses for an agent
123
+ */
124
+ agent_set_wallets: {
125
+ description: string;
126
+ handler: (args: {
127
+ agentId: string;
128
+ apiKey: string;
129
+ baseAddress?: string;
130
+ trc20Address?: string;
131
+ lightningAddress?: string;
132
+ }) => Promise<{
133
+ success: boolean;
134
+ error: string;
135
+ wallets?: undefined;
136
+ message?: undefined;
137
+ } | {
138
+ success: boolean;
139
+ wallets: any;
140
+ message: string;
141
+ error?: undefined;
142
+ }>;
143
+ };
144
+ };