@paylobster/mcp-server 1.3.0 → 1.5.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.
Files changed (135) hide show
  1. package/BUILD_SUMMARY.md +294 -0
  2. package/CHANGELOG.md +77 -0
  3. package/COMPLETION_REPORT.md +284 -0
  4. package/INTEGRATION.md +286 -0
  5. package/QUICKSTART.md +226 -0
  6. package/README.md +232 -127
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +19 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/config.d.ts +7 -0
  12. package/dist/lib/config.d.ts.map +1 -0
  13. package/dist/lib/config.js +16 -0
  14. package/dist/lib/config.js.map +1 -0
  15. package/dist/lib/contracts.d.ts +15 -0
  16. package/dist/lib/contracts.d.ts.map +1 -0
  17. package/dist/lib/contracts.js +148 -0
  18. package/dist/lib/contracts.js.map +1 -0
  19. package/dist/lib/types.d.ts +39 -0
  20. package/dist/lib/types.d.ts.map +1 -0
  21. package/dist/{types/index.js → lib/types.js} +1 -1
  22. package/dist/lib/types.js.map +1 -0
  23. package/dist/resources/agent.d.ts +3 -0
  24. package/dist/resources/agent.d.ts.map +1 -0
  25. package/dist/resources/agent.js +36 -0
  26. package/dist/resources/agent.js.map +1 -0
  27. package/dist/resources/escrow.d.ts +3 -0
  28. package/dist/resources/escrow.d.ts.map +1 -0
  29. package/dist/resources/escrow.js +33 -0
  30. package/dist/resources/escrow.js.map +1 -0
  31. package/dist/resources/services.d.ts +2 -0
  32. package/dist/resources/services.d.ts.map +1 -0
  33. package/dist/resources/services.js +55 -0
  34. package/dist/resources/services.js.map +1 -0
  35. package/dist/server.d.ts +6 -3
  36. package/dist/server.d.ts.map +1 -1
  37. package/dist/server.js +114 -834
  38. package/dist/server.js.map +1 -1
  39. package/dist/tools/agent.d.ts +17 -0
  40. package/dist/tools/agent.d.ts.map +1 -0
  41. package/dist/tools/agent.js +51 -0
  42. package/dist/tools/agent.js.map +1 -0
  43. package/dist/tools/balance.d.ts +16 -5
  44. package/dist/tools/balance.d.ts.map +1 -1
  45. package/dist/tools/balance.js +44 -26
  46. package/dist/tools/balance.js.map +1 -1
  47. package/dist/tools/escrow.d.ts +31 -90
  48. package/dist/tools/escrow.d.ts.map +1 -1
  49. package/dist/tools/escrow.js +98 -215
  50. package/dist/tools/escrow.js.map +1 -1
  51. package/dist/tools/reputation.d.ts +15 -49
  52. package/dist/tools/reputation.d.ts.map +1 -1
  53. package/dist/tools/reputation.js +45 -107
  54. package/dist/tools/reputation.js.map +1 -1
  55. package/dist/tools/search.d.ts +30 -54
  56. package/dist/tools/search.d.ts.map +1 -1
  57. package/dist/tools/search.js +122 -85
  58. package/dist/tools/search.js.map +1 -1
  59. package/examples/test-server.ts +36 -0
  60. package/examples/test-tools.ts +64 -0
  61. package/package.json +20 -11
  62. package/src/__tests__/server.test.ts +24 -0
  63. package/src/index.ts +24 -0
  64. package/src/lib/config.ts +22 -0
  65. package/src/lib/contracts.ts +164 -0
  66. package/src/lib/types.ts +44 -0
  67. package/src/resources/agent.ts +40 -0
  68. package/src/resources/escrow.ts +35 -0
  69. package/src/resources/services.ts +53 -0
  70. package/src/server.ts +190 -0
  71. package/src/tools/agent.ts +56 -0
  72. package/src/tools/balance.ts +61 -0
  73. package/src/tools/escrow.ts +142 -0
  74. package/src/tools/reputation.ts +69 -0
  75. package/src/tools/search.ts +148 -0
  76. package/tsconfig.json +20 -0
  77. package/dist/cli.d.ts +0 -3
  78. package/dist/cli.d.ts.map +0 -1
  79. package/dist/cli.js +0 -86
  80. package/dist/cli.js.map +0 -1
  81. package/dist/resources/index.d.ts +0 -9
  82. package/dist/resources/index.d.ts.map +0 -1
  83. package/dist/resources/index.js +0 -159
  84. package/dist/resources/index.js.map +0 -1
  85. package/dist/tools/bridge.d.ts +0 -142
  86. package/dist/tools/bridge.d.ts.map +0 -1
  87. package/dist/tools/bridge.js +0 -121
  88. package/dist/tools/bridge.js.map +0 -1
  89. package/dist/tools/cascade.d.ts +0 -59
  90. package/dist/tools/cascade.d.ts.map +0 -1
  91. package/dist/tools/cascade.js +0 -119
  92. package/dist/tools/cascade.js.map +0 -1
  93. package/dist/tools/compliance.d.ts +0 -36
  94. package/dist/tools/compliance.d.ts.map +0 -1
  95. package/dist/tools/compliance.js +0 -57
  96. package/dist/tools/compliance.js.map +0 -1
  97. package/dist/tools/credit.d.ts +0 -46
  98. package/dist/tools/credit.d.ts.map +0 -1
  99. package/dist/tools/credit.js +0 -102
  100. package/dist/tools/credit.js.map +0 -1
  101. package/dist/tools/disputes.d.ts +0 -71
  102. package/dist/tools/disputes.d.ts.map +0 -1
  103. package/dist/tools/disputes.js +0 -121
  104. package/dist/tools/disputes.js.map +0 -1
  105. package/dist/tools/intent.d.ts +0 -78
  106. package/dist/tools/intent.d.ts.map +0 -1
  107. package/dist/tools/intent.js +0 -192
  108. package/dist/tools/intent.js.map +0 -1
  109. package/dist/tools/portfolio.d.ts +0 -44
  110. package/dist/tools/portfolio.d.ts.map +0 -1
  111. package/dist/tools/portfolio.js +0 -166
  112. package/dist/tools/portfolio.js.map +0 -1
  113. package/dist/tools/revenue.d.ts +0 -42
  114. package/dist/tools/revenue.d.ts.map +0 -1
  115. package/dist/tools/revenue.js +0 -67
  116. package/dist/tools/revenue.js.map +0 -1
  117. package/dist/tools/streaming.d.ts +0 -60
  118. package/dist/tools/streaming.d.ts.map +0 -1
  119. package/dist/tools/streaming.js +0 -163
  120. package/dist/tools/streaming.js.map +0 -1
  121. package/dist/tools/swap.d.ts +0 -93
  122. package/dist/tools/swap.d.ts.map +0 -1
  123. package/dist/tools/swap.js +0 -150
  124. package/dist/tools/swap.js.map +0 -1
  125. package/dist/tools/treasury.d.ts +0 -169
  126. package/dist/tools/treasury.d.ts.map +0 -1
  127. package/dist/tools/treasury.js +0 -475
  128. package/dist/tools/treasury.js.map +0 -1
  129. package/dist/types/index.d.ts +0 -83
  130. package/dist/types/index.d.ts.map +0 -1
  131. package/dist/types/index.js.map +0 -1
  132. package/dist/utils/contracts.d.ts +0 -552
  133. package/dist/utils/contracts.d.ts.map +0 -1
  134. package/dist/utils/contracts.js +0 -401
  135. package/dist/utils/contracts.js.map +0 -1
package/dist/server.js CHANGED
@@ -4,31 +4,28 @@ exports.PayLobsterMCPServer = void 0;
4
4
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
5
5
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
6
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
7
- const contracts_js_1 = require("./utils/contracts.js");
8
- const search_js_1 = require("./tools/search.js");
9
- const escrow_js_1 = require("./tools/escrow.js");
7
+ const config_js_1 = require("./lib/config.js");
8
+ const contracts_js_1 = require("./lib/contracts.js");
9
+ // Tool handlers
10
10
  const reputation_js_1 = require("./tools/reputation.js");
11
11
  const balance_js_1 = require("./tools/balance.js");
12
- const streaming_js_1 = require("./tools/streaming.js");
13
- const disputes_js_1 = require("./tools/disputes.js");
14
- const credit_js_1 = require("./tools/credit.js");
15
- const cascade_js_1 = require("./tools/cascade.js");
16
- const intent_js_1 = require("./tools/intent.js");
17
- const revenue_js_1 = require("./tools/revenue.js");
18
- const compliance_js_1 = require("./tools/compliance.js");
19
- const swap_js_1 = require("./tools/swap.js");
20
- const bridge_js_1 = require("./tools/bridge.js");
21
- const portfolio_js_1 = require("./tools/portfolio.js");
22
- const treasury_js_1 = require("./tools/treasury.js");
23
- const index_js_2 = require("./resources/index.js");
12
+ const agent_js_1 = require("./tools/agent.js");
13
+ const escrow_js_1 = require("./tools/escrow.js");
14
+ const search_js_1 = require("./tools/search.js");
15
+ // Resource handlers
16
+ const agent_js_2 = require("./resources/agent.js");
17
+ const escrow_js_2 = require("./resources/escrow.js");
18
+ const services_js_1 = require("./resources/services.js");
24
19
  class PayLobsterMCPServer {
25
20
  server;
26
- client;
21
+ config;
22
+ contracts;
27
23
  constructor(config) {
28
- this.client = new contracts_js_1.ContractClient(config);
24
+ this.config = { ...(0, config_js_1.getConfig)(), ...config };
25
+ this.contracts = new contracts_js_1.ContractsClient(this.config);
29
26
  this.server = new index_js_1.Server({
30
- name: '@paylobster/mcp-server',
31
- version: '1.3.0',
27
+ name: 'paylobster-mcp-server',
28
+ version: '1.0.0',
32
29
  }, {
33
30
  capabilities: {
34
31
  tools: {},
@@ -41,849 +38,132 @@ class PayLobsterMCPServer {
41
38
  // List available tools
42
39
  this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
43
40
  tools: [
44
- {
45
- name: 'search_services',
46
- description: 'Find PayLobster services by capabilities, category, or price',
47
- inputSchema: {
48
- type: 'object',
49
- properties: {
50
- query: { type: 'string', description: 'Semantic search query' },
51
- filters: {
52
- type: 'object',
53
- properties: {
54
- category: { type: 'string' },
55
- capabilities: { type: 'array', items: { type: 'string' } },
56
- maxPrice: { type: 'string' },
57
- minReputation: { type: 'number' },
58
- currency: { type: 'string', default: 'USDC' },
59
- },
60
- },
61
- sort: { type: 'string', enum: ['price', 'reputation', 'relevance'], default: 'relevance' },
62
- limit: { type: 'number', default: 20 },
63
- },
64
- },
65
- },
66
- {
67
- name: 'create_escrow',
68
- description: 'Create a payment escrow for a service',
69
- inputSchema: {
70
- type: 'object',
71
- properties: {
72
- to: { type: 'string', description: 'Recipient address' },
73
- amount: { type: 'string', description: 'Amount in USDC' },
74
- currency: { type: 'string', default: 'USDC' },
75
- terms: {
76
- type: 'object',
77
- properties: {
78
- releaseOn: { type: 'string', enum: ['delivery-confirmed', 'timeout', 'manual'] },
79
- timeout: { type: 'string', description: 'ISO 8601 duration' },
80
- disputeWindow: { type: 'string', description: 'ISO 8601 duration' },
81
- },
82
- },
83
- metadata: { type: 'object' },
84
- },
85
- required: ['to', 'amount'],
86
- },
87
- },
88
- {
89
- name: 'release_escrow',
90
- description: 'Release funds from an escrow',
91
- inputSchema: {
92
- type: 'object',
93
- properties: {
94
- escrowId: { type: 'string', description: 'Escrow ID' },
95
- },
96
- required: ['escrowId'],
97
- },
98
- },
99
- {
100
- name: 'get_escrow',
101
- description: 'Get details of a specific escrow',
102
- inputSchema: {
103
- type: 'object',
104
- properties: {
105
- escrowId: { type: 'string', description: 'Escrow ID' },
106
- },
107
- required: ['escrowId'],
108
- },
109
- },
110
- {
111
- name: 'list_escrows',
112
- description: 'List escrows by creator or provider',
113
- inputSchema: {
114
- type: 'object',
115
- properties: {
116
- creator: { type: 'string', description: 'Filter by creator address' },
117
- provider: { type: 'string', description: 'Filter by provider address' },
118
- status: { type: 'string', enum: ['pending', 'active', 'released', 'disputed', 'refunded'] },
119
- limit: { type: 'number', default: 20 },
120
- },
121
- },
122
- },
123
- {
124
- name: 'get_reputation',
125
- description: 'Check an agent\'s reputation score and history',
126
- inputSchema: {
127
- type: 'object',
128
- properties: {
129
- address: { type: 'string', description: 'Ethereum address' },
130
- },
131
- required: ['address'],
132
- },
133
- },
134
- {
135
- name: 'register_agent',
136
- description: 'Register agent identity on PayLobster',
137
- inputSchema: {
138
- type: 'object',
139
- properties: {
140
- name: { type: 'string', description: 'Agent name' },
141
- metadata: {
142
- type: 'object',
143
- properties: {
144
- description: { type: 'string' },
145
- website: { type: 'string' },
146
- contact: { type: 'string' },
147
- },
148
- },
149
- stake: { type: 'string', description: 'USDC amount to stake (minimum 100)' },
150
- },
151
- required: ['name', 'stake'],
152
- },
153
- },
154
- {
155
- name: 'get_balance',
156
- description: 'Check USDC and credit balance',
157
- inputSchema: {
158
- type: 'object',
159
- properties: {},
160
- },
161
- },
162
- {
163
- name: 'create_streaming_payment',
164
- description: 'Create a streaming payment to another agent',
165
- inputSchema: {
166
- type: 'object',
167
- properties: {
168
- to: { type: 'string', description: 'Recipient address' },
169
- amountPerSecond: { type: 'string', description: 'Amount per second in USDC' },
170
- duration: { type: 'string', description: 'ISO 8601 duration (e.g., P1D for 1 day)' },
171
- metadata: { type: 'object' },
172
- },
173
- required: ['to', 'amountPerSecond', 'duration'],
174
- },
175
- },
176
- {
177
- name: 'cancel_stream',
178
- description: 'Cancel an active stream',
179
- inputSchema: {
180
- type: 'object',
181
- properties: {
182
- streamId: { type: 'string', description: 'Stream ID' },
183
- },
184
- required: ['streamId'],
185
- },
186
- },
187
- {
188
- name: 'get_stream',
189
- description: 'Get stream details',
190
- inputSchema: {
191
- type: 'object',
192
- properties: {
193
- streamId: { type: 'string', description: 'Stream ID' },
194
- },
195
- required: ['streamId'],
196
- },
197
- },
198
- {
199
- name: 'open_dispute',
200
- description: 'Open a dispute on an escrow',
201
- inputSchema: {
202
- type: 'object',
203
- properties: {
204
- escrowId: { type: 'string', description: 'Escrow ID to dispute' },
205
- reason: { type: 'string', description: 'Reason for dispute' },
206
- evidence: { type: 'string', description: 'Initial evidence (IPFS hash or URL)' },
207
- },
208
- required: ['escrowId', 'reason'],
209
- },
210
- },
211
- {
212
- name: 'submit_evidence',
213
- description: 'Submit evidence for a dispute',
214
- inputSchema: {
215
- type: 'object',
216
- properties: {
217
- disputeId: { type: 'string', description: 'Dispute ID' },
218
- evidence: { type: 'string', description: 'Evidence (IPFS hash or URL)' },
219
- description: { type: 'string', description: 'Description of evidence' },
220
- },
221
- required: ['disputeId', 'evidence', 'description'],
222
- },
223
- },
224
- {
225
- name: 'get_dispute',
226
- description: 'Get dispute details',
227
- inputSchema: {
228
- type: 'object',
229
- properties: {
230
- disputeId: { type: 'string', description: 'Dispute ID' },
231
- },
232
- required: ['disputeId'],
233
- },
234
- },
235
- {
236
- name: 'get_credit_score',
237
- description: "Get an agent's credit score",
238
- inputSchema: {
239
- type: 'object',
240
- properties: {
241
- address: { type: 'string', description: 'Agent address' },
242
- },
243
- required: ['address'],
244
- },
245
- },
246
- {
247
- name: 'request_credit_line',
248
- description: 'Request a credit line',
249
- inputSchema: {
250
- type: 'object',
251
- properties: {
252
- amount: { type: 'string', description: 'Requested credit line amount in USDC' },
253
- duration: { type: 'string', description: 'ISO 8601 duration (e.g., P30D for 30 days)' },
254
- collateral: { type: 'string', description: 'Collateral amount in USDC' },
255
- },
256
- required: ['amount', 'duration'],
257
- },
258
- },
259
- {
260
- name: 'create_cascade',
261
- description: 'Create cascading multi-agent escrow',
262
- inputSchema: {
263
- type: 'object',
264
- properties: {
265
- levels: {
266
- type: 'array',
267
- items: {
268
- type: 'object',
269
- properties: {
270
- recipient: { type: 'string', description: 'Recipient address' },
271
- amount: { type: 'string', description: 'Amount in USDC' },
272
- releaseCondition: { type: 'string', description: 'Condition for release' },
273
- },
274
- required: ['recipient', 'amount', 'releaseCondition'],
275
- },
276
- description: 'Cascade levels in order',
277
- },
278
- metadata: { type: 'object' },
279
- },
280
- required: ['levels'],
281
- },
282
- },
283
- {
284
- name: 'release_cascade_level',
285
- description: 'Release a cascade level',
286
- inputSchema: {
287
- type: 'object',
288
- properties: {
289
- cascadeId: { type: 'string', description: 'Cascade ID' },
290
- level: { type: 'number', description: 'Level to release (0-indexed)' },
291
- },
292
- required: ['cascadeId', 'level'],
293
- },
294
- },
295
- {
296
- name: 'post_intent',
297
- description: 'Post a service intent to marketplace',
298
- inputSchema: {
299
- type: 'object',
300
- properties: {
301
- description: { type: 'string', description: 'Service intent description' },
302
- tags: { type: 'array', items: { type: 'string' }, description: 'Service tags for discovery' },
303
- budget: { type: 'string', description: 'Maximum budget in USDC' },
304
- deadline: { type: 'string', description: 'ISO 8601 duration or timestamp' },
305
- requirements: { type: 'object' },
306
- },
307
- required: ['description', 'tags', 'budget', 'deadline'],
308
- },
309
- },
310
- {
311
- name: 'search_intents',
312
- description: 'Search intents by tags',
313
- inputSchema: {
314
- type: 'object',
315
- properties: {
316
- tags: { type: 'array', items: { type: 'string' }, description: 'Filter by tags' },
317
- minBudget: { type: 'string', description: 'Minimum budget in USDC' },
318
- maxBudget: { type: 'string', description: 'Maximum budget in USDC' },
319
- limit: { type: 'number', default: 20 },
320
- },
321
- },
322
- },
323
- {
324
- name: 'accept_offer',
325
- description: 'Accept an offer on your intent',
326
- inputSchema: {
327
- type: 'object',
328
- properties: {
329
- intentId: { type: 'string', description: 'Intent ID' },
330
- offerId: { type: 'string', description: 'Offer ID to accept' },
331
- },
332
- required: ['intentId', 'offerId'],
333
- },
334
- },
335
- {
336
- name: 'create_revenue_share',
337
- description: 'Create revenue sharing agreement',
338
- inputSchema: {
339
- type: 'object',
340
- properties: {
341
- participants: {
342
- type: 'array',
343
- items: {
344
- type: 'object',
345
- properties: {
346
- address: { type: 'string', description: 'Participant address' },
347
- share: { type: 'number', description: 'Share percentage (0-100)' },
348
- },
349
- required: ['address', 'share'],
350
- },
351
- description: 'Revenue share participants',
352
- },
353
- sourceEscrow: { type: 'string', description: 'Link to source escrow' },
354
- metadata: { type: 'object' },
355
- },
356
- required: ['participants'],
357
- },
358
- },
359
- {
360
- name: 'check_compliance',
361
- description: 'Check agent compliance status',
362
- inputSchema: {
363
- type: 'object',
364
- properties: {
365
- address: { type: 'string', description: 'Agent address to check' },
366
- checkTypes: { type: 'array', items: { type: 'string' }, description: 'Specific checks to run (kyc, sanctions, risk)' },
367
- },
368
- required: ['address'],
369
- },
370
- },
371
- {
372
- name: 'swap_quote',
373
- description: 'Get swap quote for Base tokens via 0x API',
374
- inputSchema: {
375
- type: 'object',
376
- properties: {
377
- sellToken: { type: 'string', description: 'Token address or symbol to sell' },
378
- buyToken: { type: 'string', description: 'Token address or symbol to buy' },
379
- sellAmount: { type: 'string', description: 'Amount to sell (in token units)' },
380
- buyAmount: { type: 'string', description: 'Amount to buy (in token units)' },
381
- slippagePercentage: { type: 'number', default: 0.01, description: 'Slippage tolerance (0.01 = 1%)' },
382
- takerAddress: { type: 'string', description: 'Address that will submit the transaction' },
383
- },
384
- required: ['sellToken', 'buyToken'],
385
- },
386
- },
387
- {
388
- name: 'swap_execute',
389
- description: 'Execute swap (returns unsigned tx)',
390
- inputSchema: {
391
- type: 'object',
392
- properties: {
393
- sellToken: { type: 'string', description: 'Token address or symbol to sell' },
394
- buyToken: { type: 'string', description: 'Token address or symbol to buy' },
395
- sellAmount: { type: 'string', description: 'Amount to sell (in token units)' },
396
- buyAmount: { type: 'string', description: 'Amount to buy (in token units)' },
397
- slippagePercentage: { type: 'number', default: 0.01, description: 'Slippage tolerance (0.01 = 1%)' },
398
- },
399
- required: ['sellToken', 'buyToken'],
400
- },
401
- },
402
- {
403
- name: 'swap_tokens',
404
- description: 'List available tokens on Base',
405
- inputSchema: {
406
- type: 'object',
407
- properties: {
408
- query: { type: 'string', description: 'Search query to filter tokens' },
409
- },
410
- },
411
- },
412
- {
413
- name: 'swap_price',
414
- description: 'Get token price in USDC',
415
- inputSchema: {
416
- type: 'object',
417
- properties: {
418
- token: { type: 'string', description: 'Token address or symbol' },
419
- },
420
- required: ['token'],
421
- },
422
- },
423
- {
424
- name: 'bridge_quote',
425
- description: 'Get cross-chain bridge quote via Li.Fi',
426
- inputSchema: {
427
- type: 'object',
428
- properties: {
429
- fromChain: { type: ['string', 'number'], description: 'Source chain ID or name' },
430
- toChain: { type: ['string', 'number'], description: 'Destination chain ID or name' },
431
- fromToken: { type: 'string', description: 'Source token address' },
432
- toToken: { type: 'string', description: 'Destination token address' },
433
- fromAmount: { type: 'string', description: 'Amount to bridge (in token units)' },
434
- fromAddress: { type: 'string', description: 'Sender address' },
435
- toAddress: { type: 'string', description: 'Recipient address (defaults to fromAddress)' },
436
- },
437
- required: ['fromChain', 'toChain', 'fromToken', 'toToken', 'fromAmount'],
438
- },
439
- },
440
- {
441
- name: 'bridge_execute',
442
- description: 'Execute bridge (returns tx data)',
443
- inputSchema: {
444
- type: 'object',
445
- properties: {
446
- fromChain: { type: ['string', 'number'], description: 'Source chain ID or name' },
447
- toChain: { type: ['string', 'number'], description: 'Destination chain ID or name' },
448
- fromToken: { type: 'string', description: 'Source token address' },
449
- toToken: { type: 'string', description: 'Destination token address' },
450
- fromAmount: { type: 'string', description: 'Amount to bridge (in token units)' },
451
- toAddress: { type: 'string', description: 'Recipient address' },
452
- },
453
- required: ['fromChain', 'toChain', 'fromToken', 'toToken', 'fromAmount'],
454
- },
455
- },
456
- {
457
- name: 'bridge_status',
458
- description: 'Check bridge transaction status',
459
- inputSchema: {
460
- type: 'object',
461
- properties: {
462
- txHash: { type: 'string', description: 'Transaction hash to check' },
463
- fromChain: { type: ['string', 'number'], description: 'Source chain ID' },
464
- toChain: { type: ['string', 'number'], description: 'Destination chain ID' },
465
- },
466
- required: ['txHash'],
467
- },
468
- },
469
- {
470
- name: 'bridge_chains',
471
- description: 'List supported chains',
472
- inputSchema: {
473
- type: 'object',
474
- properties: {
475
- query: { type: 'string', description: 'Filter chains by name' },
476
- },
477
- },
478
- },
479
- {
480
- name: 'get_portfolio',
481
- description: 'Get all token balances for an address on Base',
482
- inputSchema: {
483
- type: 'object',
484
- properties: {
485
- address: { type: 'string', description: 'Ethereum address to get portfolio for' },
486
- },
487
- required: ['address'],
488
- },
489
- },
490
- {
491
- name: 'get_token_price',
492
- description: 'Get price of any token on Base',
493
- inputSchema: {
494
- type: 'object',
495
- properties: {
496
- tokenAddress: { type: 'string', description: 'Token contract address on Base' },
497
- },
498
- required: ['tokenAddress'],
499
- },
500
- },
501
- {
502
- name: 'treasury_create',
503
- description: 'Create a new agent treasury',
504
- inputSchema: {
505
- type: 'object',
506
- properties: {
507
- name: { type: 'string', description: 'Treasury name' },
508
- },
509
- required: ['name'],
510
- },
511
- },
512
- {
513
- name: 'treasury_info',
514
- description: 'Get treasury summary including name, owner, balances, members, and stats',
515
- inputSchema: {
516
- type: 'object',
517
- properties: {
518
- address: { type: 'string', description: 'Treasury address' },
519
- },
520
- required: ['address'],
521
- },
522
- },
523
- {
524
- name: 'treasury_balances',
525
- description: 'Get all token balances in a treasury',
526
- inputSchema: {
527
- type: 'object',
528
- properties: {
529
- treasuryAddress: { type: 'string', description: 'Treasury address' },
530
- },
531
- required: ['treasuryAddress'],
532
- },
533
- },
534
- {
535
- name: 'treasury_deposit',
536
- description: 'Deposit tokens into a treasury',
537
- inputSchema: {
538
- type: 'object',
539
- properties: {
540
- treasuryAddress: { type: 'string', description: 'Treasury address' },
541
- token: { type: 'string', description: 'Token address' },
542
- amount: { type: 'string', description: 'Amount to deposit (in token units)' },
543
- },
544
- required: ['treasuryAddress', 'token', 'amount'],
545
- },
546
- },
547
- {
548
- name: 'treasury_withdraw',
549
- description: 'Withdraw tokens from a treasury',
550
- inputSchema: {
551
- type: 'object',
552
- properties: {
553
- treasuryAddress: { type: 'string', description: 'Treasury address' },
554
- token: { type: 'string', description: 'Token address' },
555
- to: { type: 'string', description: 'Recipient address' },
556
- amount: { type: 'string', description: 'Amount to withdraw (in token units)' },
557
- reason: { type: 'string', description: 'Withdrawal reason' },
558
- },
559
- required: ['treasuryAddress', 'token', 'to', 'amount', 'reason'],
560
- },
561
- },
562
- {
563
- name: 'treasury_members',
564
- description: 'List all members and their roles in a treasury',
565
- inputSchema: {
566
- type: 'object',
567
- properties: {
568
- treasuryAddress: { type: 'string', description: 'Treasury address' },
569
- },
570
- required: ['treasuryAddress'],
571
- },
572
- },
573
- {
574
- name: 'treasury_grant_role',
575
- description: 'Grant a role to an account (MANAGER=1, OPERATOR=2, AUDITOR=3)',
576
- inputSchema: {
577
- type: 'object',
578
- properties: {
579
- treasuryAddress: { type: 'string', description: 'Treasury address' },
580
- account: { type: 'string', description: 'Account address' },
581
- role: { type: ['string', 'number'], description: 'Role (MANAGER=1, OPERATOR=2, AUDITOR=3)' },
582
- },
583
- required: ['treasuryAddress', 'account', 'role'],
584
- },
585
- },
586
- {
587
- name: 'treasury_set_budget',
588
- description: 'Set budget allocation percentages (must sum to 10000 basis points = 100%)',
589
- inputSchema: {
590
- type: 'object',
591
- properties: {
592
- treasuryAddress: { type: 'string', description: 'Treasury address' },
593
- opsBps: { type: 'number', description: 'Operations budget (basis points, 0-10000)' },
594
- growthBps: { type: 'number', description: 'Growth budget (basis points, 0-10000)' },
595
- reservesBps: { type: 'number', description: 'Reserves budget (basis points, 0-10000)' },
596
- yieldBps: { type: 'number', description: 'Yield budget (basis points, 0-10000)' },
597
- },
598
- required: ['treasuryAddress', 'opsBps', 'growthBps', 'reservesBps', 'yieldBps'],
599
- },
600
- },
601
- {
602
- name: 'treasury_set_limit',
603
- description: 'Set spending limits for an operator',
604
- inputSchema: {
605
- type: 'object',
606
- properties: {
607
- treasuryAddress: { type: 'string', description: 'Treasury address' },
608
- operator: { type: 'string', description: 'Operator address' },
609
- maxPerTx: { type: 'string', description: 'Maximum amount per transaction' },
610
- maxPerDay: { type: 'string', description: 'Maximum amount per day' },
611
- },
612
- required: ['treasuryAddress', 'operator', 'maxPerTx', 'maxPerDay'],
613
- },
614
- },
615
- {
616
- name: 'treasury_lookup',
617
- description: 'Look up treasury address by owner address',
618
- inputSchema: {
619
- type: 'object',
620
- properties: {
621
- ownerAddress: { type: 'string', description: 'Owner address' },
622
- },
623
- required: ['ownerAddress'],
624
- },
625
- },
41
+ reputation_js_1.getReputationTool,
42
+ balance_js_1.getBalanceTool,
43
+ agent_js_1.getAgentTool,
44
+ escrow_js_1.getEscrowTool,
45
+ escrow_js_1.listEscrowsTool,
46
+ search_js_1.searchServicesTool,
626
47
  ],
627
48
  }));
628
49
  // Handle tool calls
629
50
  this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
630
51
  try {
631
- switch (request.params.name) {
632
- case 'search_services': {
633
- const params = search_js_1.searchServicesSchema.parse(request.params.arguments);
634
- const result = await (0, search_js_1.searchServices)(params, this.client);
635
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
636
- }
637
- case 'create_escrow': {
638
- const params = escrow_js_1.createEscrowSchema.parse(request.params.arguments);
639
- const result = await (0, escrow_js_1.createEscrow)(params, this.client);
640
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
641
- }
642
- case 'release_escrow': {
643
- const params = escrow_js_1.releaseEscrowSchema.parse(request.params.arguments);
644
- const result = await (0, escrow_js_1.releaseEscrow)(params, this.client);
645
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
646
- }
647
- case 'get_escrow': {
648
- const params = escrow_js_1.getEscrowSchema.parse(request.params.arguments);
649
- const result = await (0, escrow_js_1.getEscrow)(params, this.client);
650
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
651
- }
652
- case 'list_escrows': {
653
- const params = escrow_js_1.listEscrowsSchema.parse(request.params.arguments);
654
- const result = await (0, escrow_js_1.listEscrows)(params, this.client);
655
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
656
- }
657
- case 'get_reputation': {
658
- const params = reputation_js_1.getReputationSchema.parse(request.params.arguments);
659
- const result = await (0, reputation_js_1.getReputation)(params, this.client);
660
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
661
- }
662
- case 'register_agent': {
663
- const params = reputation_js_1.registerAgentSchema.parse(request.params.arguments);
664
- const result = await (0, reputation_js_1.registerAgent)(params, this.client);
665
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
666
- }
667
- case 'get_balance': {
668
- const params = balance_js_1.getBalanceSchema.parse(request.params.arguments);
669
- const result = await (0, balance_js_1.getBalance)(params, this.client);
670
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
671
- }
672
- case 'create_streaming_payment': {
673
- const params = streaming_js_1.createStreamingPaymentSchema.parse(request.params.arguments);
674
- const result = await (0, streaming_js_1.createStreamingPayment)(params, this.client);
675
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
676
- }
677
- case 'cancel_stream': {
678
- const params = streaming_js_1.cancelStreamSchema.parse(request.params.arguments);
679
- const result = await (0, streaming_js_1.cancelStream)(params, this.client);
680
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
681
- }
682
- case 'get_stream': {
683
- const params = streaming_js_1.getStreamSchema.parse(request.params.arguments);
684
- const result = await (0, streaming_js_1.getStream)(params, this.client);
685
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
686
- }
687
- case 'open_dispute': {
688
- const params = disputes_js_1.openDisputeSchema.parse(request.params.arguments);
689
- const result = await (0, disputes_js_1.openDispute)(params, this.client);
690
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
691
- }
692
- case 'submit_evidence': {
693
- const params = disputes_js_1.submitEvidenceSchema.parse(request.params.arguments);
694
- const result = await (0, disputes_js_1.submitEvidence)(params, this.client);
695
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
696
- }
697
- case 'get_dispute': {
698
- const params = disputes_js_1.getDisputeSchema.parse(request.params.arguments);
699
- const result = await (0, disputes_js_1.getDispute)(params, this.client);
700
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
701
- }
702
- case 'get_credit_score': {
703
- const params = credit_js_1.getCreditScoreSchema.parse(request.params.arguments);
704
- const result = await (0, credit_js_1.getCreditScore)(params, this.client);
705
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
706
- }
707
- case 'request_credit_line': {
708
- const params = credit_js_1.requestCreditLineSchema.parse(request.params.arguments);
709
- const result = await (0, credit_js_1.requestCreditLine)(params, this.client);
710
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
711
- }
712
- case 'create_cascade': {
713
- const params = cascade_js_1.createCascadeSchema.parse(request.params.arguments);
714
- const result = await (0, cascade_js_1.createCascade)(params, this.client);
715
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
716
- }
717
- case 'release_cascade_level': {
718
- const params = cascade_js_1.releaseCascadeLevelSchema.parse(request.params.arguments);
719
- const result = await (0, cascade_js_1.releaseCascadeLevel)(params, this.client);
720
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
721
- }
722
- case 'post_intent': {
723
- const params = intent_js_1.postIntentSchema.parse(request.params.arguments);
724
- const result = await (0, intent_js_1.postIntent)(params, this.client);
725
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
726
- }
727
- case 'search_intents': {
728
- const params = intent_js_1.searchIntentsSchema.parse(request.params.arguments);
729
- const result = await (0, intent_js_1.searchIntents)(params, this.client);
730
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
731
- }
732
- case 'accept_offer': {
733
- const params = intent_js_1.acceptOfferSchema.parse(request.params.arguments);
734
- const result = await (0, intent_js_1.acceptOffer)(params, this.client);
735
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
736
- }
737
- case 'create_revenue_share': {
738
- const params = revenue_js_1.createRevenueShareSchema.parse(request.params.arguments);
739
- const result = await (0, revenue_js_1.createRevenueShare)(params, this.client);
740
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
741
- }
742
- case 'check_compliance': {
743
- const params = compliance_js_1.checkComplianceSchema.parse(request.params.arguments);
744
- const result = await (0, compliance_js_1.checkCompliance)(params, this.client);
745
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
746
- }
747
- case 'swap_quote': {
748
- const params = swap_js_1.swapQuoteSchema.parse(request.params.arguments);
749
- const result = await (0, swap_js_1.swapQuote)(params, this.client);
750
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
751
- }
752
- case 'swap_execute': {
753
- const params = swap_js_1.swapExecuteSchema.parse(request.params.arguments);
754
- const result = await (0, swap_js_1.swapExecute)(params, this.client);
755
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
756
- }
757
- case 'swap_tokens': {
758
- const params = swap_js_1.swapTokensSchema.parse(request.params.arguments);
759
- const result = await (0, swap_js_1.swapTokens)(params, this.client);
760
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
761
- }
762
- case 'swap_price': {
763
- const params = swap_js_1.swapPriceSchema.parse(request.params.arguments);
764
- const result = await (0, swap_js_1.swapPrice)(params, this.client);
765
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
766
- }
767
- case 'bridge_quote': {
768
- const params = bridge_js_1.bridgeQuoteSchema.parse(request.params.arguments);
769
- const result = await (0, bridge_js_1.bridgeQuote)(params, this.client);
770
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
771
- }
772
- case 'bridge_execute': {
773
- const params = bridge_js_1.bridgeExecuteSchema.parse(request.params.arguments);
774
- const result = await (0, bridge_js_1.bridgeExecute)(params, this.client);
775
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
776
- }
777
- case 'bridge_status': {
778
- const params = bridge_js_1.bridgeStatusSchema.parse(request.params.arguments);
779
- const result = await (0, bridge_js_1.bridgeStatus)(params, this.client);
780
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
781
- }
782
- case 'bridge_chains': {
783
- const params = bridge_js_1.bridgeChainsSchema.parse(request.params.arguments);
784
- const result = await (0, bridge_js_1.bridgeChains)(params, this.client);
785
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
786
- }
787
- case 'get_portfolio': {
788
- const params = portfolio_js_1.getPortfolioSchema.parse(request.params.arguments);
789
- const result = await (0, portfolio_js_1.getPortfolio)(params, this.client);
790
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
791
- }
792
- case 'get_token_price': {
793
- const params = portfolio_js_1.getTokenPriceSchema.parse(request.params.arguments);
794
- const result = await (0, portfolio_js_1.getTokenPrice)(params, this.client);
795
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
796
- }
797
- case 'treasury_create': {
798
- const params = treasury_js_1.treasuryCreateSchema.parse(request.params.arguments);
799
- const result = await (0, treasury_js_1.treasuryCreate)(params, this.client);
800
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
801
- }
802
- case 'treasury_info': {
803
- const params = treasury_js_1.treasuryInfoSchema.parse(request.params.arguments);
804
- const result = await (0, treasury_js_1.treasuryInfo)(params, this.client);
805
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
806
- }
807
- case 'treasury_balances': {
808
- const params = treasury_js_1.treasuryBalancesSchema.parse(request.params.arguments);
809
- const result = await (0, treasury_js_1.treasuryBalances)(params, this.client);
810
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
811
- }
812
- case 'treasury_deposit': {
813
- const params = treasury_js_1.treasuryDepositSchema.parse(request.params.arguments);
814
- const result = await (0, treasury_js_1.treasuryDeposit)(params, this.client);
815
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
816
- }
817
- case 'treasury_withdraw': {
818
- const params = treasury_js_1.treasuryWithdrawSchema.parse(request.params.arguments);
819
- const result = await (0, treasury_js_1.treasuryWithdraw)(params, this.client);
820
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
821
- }
822
- case 'treasury_members': {
823
- const params = treasury_js_1.treasuryMembersSchema.parse(request.params.arguments);
824
- const result = await (0, treasury_js_1.treasuryMembers)(params, this.client);
825
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
826
- }
827
- case 'treasury_grant_role': {
828
- const params = treasury_js_1.treasuryGrantRoleSchema.parse(request.params.arguments);
829
- const result = await (0, treasury_js_1.treasuryGrantRole)(params, this.client);
830
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
831
- }
832
- case 'treasury_set_budget': {
833
- const params = treasury_js_1.treasurySetBudgetSchema.parse(request.params.arguments);
834
- const result = await (0, treasury_js_1.treasurySetBudget)(params, this.client);
835
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
836
- }
837
- case 'treasury_set_limit': {
838
- const params = treasury_js_1.treasurySetLimitSchema.parse(request.params.arguments);
839
- const result = await (0, treasury_js_1.treasurySetLimit)(params, this.client);
840
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
841
- }
842
- case 'treasury_lookup': {
843
- const params = treasury_js_1.treasuryLookupSchema.parse(request.params.arguments);
844
- const result = await (0, treasury_js_1.treasuryLookup)(params, this.client);
845
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
846
- }
52
+ const { name, arguments: args } = request.params;
53
+ let result;
54
+ switch (name) {
55
+ case 'paylobster_get_reputation':
56
+ result = await (0, reputation_js_1.handleGetReputation)(args, this.contracts);
57
+ break;
58
+ case 'paylobster_get_balance':
59
+ result = await (0, balance_js_1.handleGetBalance)(args, this.contracts);
60
+ break;
61
+ case 'paylobster_get_agent':
62
+ result = await (0, agent_js_1.handleGetAgent)(args, this.contracts);
63
+ break;
64
+ case 'paylobster_get_escrow':
65
+ result = await (0, escrow_js_1.handleGetEscrow)(args, this.contracts);
66
+ break;
67
+ case 'paylobster_list_escrows':
68
+ result = await (0, escrow_js_1.handleListEscrows)(args, this.contracts);
69
+ break;
70
+ case 'paylobster_search_services':
71
+ result = await (0, search_js_1.handleSearchServices)(args);
72
+ break;
847
73
  default:
848
- throw new Error(`Unknown tool: ${request.params.name}`);
74
+ throw {
75
+ code: 'ERR_UNKNOWN_TOOL',
76
+ message: `Unknown tool: ${name}`,
77
+ retryable: false,
78
+ };
849
79
  }
80
+ return {
81
+ content: [
82
+ {
83
+ type: 'text',
84
+ text: JSON.stringify(result, null, 2),
85
+ },
86
+ ],
87
+ };
850
88
  }
851
89
  catch (error) {
852
- const errorMessage = error instanceof Error ? error.message : String(error);
853
90
  return {
854
- content: [{ type: 'text', text: `Error: ${errorMessage}` }],
91
+ content: [
92
+ {
93
+ type: 'text',
94
+ text: JSON.stringify({
95
+ error: {
96
+ code: error.code || 'ERR_UNKNOWN',
97
+ message: error.message || 'An unknown error occurred',
98
+ details: error.details,
99
+ retryable: error.retryable ?? false,
100
+ },
101
+ }, null, 2),
102
+ },
103
+ ],
855
104
  isError: true,
856
105
  };
857
106
  }
858
107
  });
859
108
  // List available resources
860
109
  this.server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => ({
861
- resources: (0, index_js_2.listResources)(),
110
+ resources: [
111
+ {
112
+ uri: 'paylobster://services',
113
+ name: 'Service Catalog',
114
+ description: 'Browse all available AI agent services',
115
+ mimeType: 'application/json',
116
+ },
117
+ {
118
+ uri: 'paylobster://agent/{address}',
119
+ name: 'Agent Profile',
120
+ description: 'Get agent identity and reputation by address',
121
+ mimeType: 'application/json',
122
+ },
123
+ {
124
+ uri: 'paylobster://escrow/{id}',
125
+ name: 'Escrow Details',
126
+ description: 'Get details for a specific escrow',
127
+ mimeType: 'application/json',
128
+ },
129
+ ],
862
130
  }));
863
- // Read resource
131
+ // Handle resource reads
864
132
  this.server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
865
133
  try {
866
- const result = await (0, index_js_2.handleResource)(request.params.uri, this.client);
867
- return {
868
- contents: [
869
- {
870
- uri: request.params.uri,
871
- mimeType: 'application/json',
872
- text: JSON.stringify(result, null, 2),
873
- },
874
- ],
134
+ const uri = request.params.uri;
135
+ if (uri === 'paylobster://services') {
136
+ return await (0, services_js_1.getServicesResource)();
137
+ }
138
+ const agentMatch = uri.match(/^paylobster:\/\/agent\/(.+)$/);
139
+ if (agentMatch) {
140
+ return await (0, agent_js_2.getAgentResource)(agentMatch[1], this.contracts);
141
+ }
142
+ const escrowMatch = uri.match(/^paylobster:\/\/escrow\/(.+)$/);
143
+ if (escrowMatch) {
144
+ return await (0, escrow_js_2.getEscrowResource)(escrowMatch[1], this.contracts);
145
+ }
146
+ throw {
147
+ code: 'ERR_RESOURCE_NOT_FOUND',
148
+ message: `Unknown resource URI: ${uri}`,
149
+ retryable: false,
875
150
  };
876
151
  }
877
152
  catch (error) {
878
- const errorMessage = error instanceof Error ? error.message : String(error);
879
- throw new Error(`Failed to read resource: ${errorMessage}`);
153
+ throw new Error(error.message || 'Failed to read resource');
880
154
  }
881
155
  });
882
156
  }
883
157
  async start() {
884
158
  const transport = new stdio_js_1.StdioServerTransport();
885
159
  await this.server.connect(transport);
886
- console.error('PayLobster MCP server running on stdio');
160
+ // Log to stderr (stdout is used for MCP protocol)
161
+ console.error('PayLobster MCP Server started');
162
+ console.error(`Network: ${this.config.network}`);
163
+ console.error(`RPC URL: ${this.config.rpcUrl}`);
164
+ }
165
+ getServer() {
166
+ return this.server;
887
167
  }
888
168
  }
889
169
  exports.PayLobsterMCPServer = PayLobsterMCPServer;