@champz-llc/legends-mcp-server 1.5.0 → 1.6.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 (2) hide show
  1. package/index.js +153 -49
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -51,10 +51,14 @@ const SIGNATURE = process.env.SIGNATURE;
51
51
  const SIGNED_AT = process.env.SIGNED_AT;
52
52
  const hasWalletAuth = WALLET && SIGNATURE && SIGNED_AT;
53
53
 
54
- // Hardcoded rewards data for demo
54
+ // ============================================================
55
+ // LEGACY: Hardcoded rewards data for BuildOnBase contest demo
56
+ // NOTE: This is no longer used! Real claims now fetched from API
57
+ // with mode=claims parameter. Kept for reference only.
58
+ // ============================================================
55
59
  const DEMO_WALLET = '0xfbc159e35f56580d5d297af18a8c19f83d66088a';
56
60
 
57
- const REWARDS_DATA = {
61
+ const REWARDS_DATA_LEGACY = {
58
62
  wallet: DEMO_WALLET,
59
63
  champz_claims: [
60
64
  {
@@ -155,7 +159,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
155
159
  },
156
160
  {
157
161
  name: 'check_legends_rewards',
158
- description: 'Check claimable rewards in Legends of Champz game. Returns pending CHAMPZ tokens and USDC claims with contract details.',
162
+ description: 'Check YOUR pending claimable rewards in Legends of Champz. Returns CHAMPZ tokens and USDC claims with amounts and expiration dates. Requires wallet authentication.',
159
163
  inputSchema: {
160
164
  type: 'object',
161
165
  properties: {},
@@ -164,7 +168,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
164
168
  },
165
169
  {
166
170
  name: 'get_champz_claim_data',
167
- description: 'Get complete contract call data for claiming CHAMPZ tokens (includes ABI, parameters, signature)',
171
+ description: 'Get complete contract call data for claiming YOUR CHAMPZ token rewards. Returns contract address, ABI, function parameters, and signature ready for Base MCP execution. Requires wallet authentication.',
168
172
  inputSchema: {
169
173
  type: 'object',
170
174
  properties: {},
@@ -173,7 +177,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
173
177
  },
174
178
  {
175
179
  name: 'get_usdc_claim_data',
176
- description: 'Get complete contract call data for claiming USDC rewards (includes ABI, parameters, signature)',
180
+ description: 'Get complete contract call data for claiming YOUR USDC rewards. Returns contract address, ABI, function parameters, and signature ready for Base MCP execution. Requires wallet authentication.',
177
181
  inputSchema: {
178
182
  type: 'object',
179
183
  properties: {},
@@ -351,54 +355,154 @@ Last updated: ${new Date(stats.cached_at * 1000).toLocaleString()}`;
351
355
  }
352
356
 
353
357
  case 'check_legends_rewards':
354
- return {
355
- content: [
356
- {
357
- type: 'text',
358
- text: `Legends of Champz - Claimable Rewards\n\n${REWARDS_DATA.summary.message}\n\nDetails:\n- CHAMPZ: ${REWARDS_DATA.champz_claims[0].amount_human}\n- USDC: ${REWARDS_DATA.usdc_claims[0].amount_human}\n\nBoth claims are ready to execute on Base L2.`,
359
- },
360
- ],
361
- };
358
+ if (!hasWalletAuth) {
359
+ return {
360
+ content: [{ type: 'text', text: 'Authentication required. Visit https://legends.champz.world/mcp-setup' }],
361
+ };
362
+ }
363
+
364
+ try {
365
+ // Fetch pending claims
366
+ const url = `https://api.champz.world/game/spore-trainer/player-data?wallet=${encodeURIComponent(WALLET)}&signature=${encodeURIComponent(SIGNATURE)}&timestamp=${encodeURIComponent(SIGNED_AT)}&mode=claims`;
367
+ const response = await fetch(url);
368
+ const data = await response.json();
369
+
370
+ if (!data.success) {
371
+ throw new Error('Failed to fetch claims data');
372
+ }
373
+
374
+ if (data.champz_claims.length === 0 && data.usdc_claims.length === 0) {
375
+ return {
376
+ content: [
377
+ {
378
+ type: 'text',
379
+ text: 'šŸ„ Legends of Champz - Claimable Rewards\n\nNo pending claims available at the moment.\n\nKeep battling and holding thrones to earn rewards! āš”ļøšŸ‘‘',
380
+ },
381
+ ],
382
+ };
383
+ }
384
+
385
+ let output = 'šŸ„ Legends of Champz - Claimable Rewards\n\n';
386
+ output += `${data.message}\n\n`;
387
+ output += `šŸ’° **Total Claimable:**\n`;
388
+ if (data.total_champz !== '0.00 CHAMPZ') output += ` šŸ„ ${data.total_champz}\n`;
389
+ if (data.total_usdc !== '0.00 USDC') output += ` šŸ’µ ${data.total_usdc}\n`;
390
+ output += `\nšŸ“ Ready to execute on Base L2 (Chain ID: ${data.chain_id})\n`;
391
+
392
+ return {
393
+ content: [{ type: 'text', text: output }],
394
+ };
395
+ } catch (error) {
396
+ return {
397
+ content: [{ type: 'text', text: `Error fetching claims: ${error.message}` }],
398
+ };
399
+ }
362
400
 
363
401
  case 'get_champz_claim_data':
364
- return {
365
- content: [
366
- {
367
- type: 'text',
368
- text: JSON.stringify({
369
- claim_type: 'CHAMPZ Tokens',
370
- contract_address: REWARDS_DATA.champz_claims[0].contract,
371
- chain: 'Base (8453)',
372
- amount: REWARDS_DATA.champz_claims[0].amount_human,
373
- contract_call: {
374
- function: 'claim',
375
- parameters: REWARDS_DATA.champz_claims[0].parameters,
376
- abi: CHAMPZ_REWARDS_ABI
377
- }
378
- }, null, 2),
379
- },
380
- ],
381
- };
402
+ if (!hasWalletAuth) {
403
+ return {
404
+ content: [{ type: 'text', text: 'Authentication required. Visit https://legends.champz.world/mcp-setup' }],
405
+ };
406
+ }
407
+
408
+ try {
409
+ // Fetch pending claims
410
+ const url = `https://api.champz.world/game/spore-trainer/player-data?wallet=${encodeURIComponent(WALLET)}&signature=${encodeURIComponent(SIGNATURE)}&timestamp=${encodeURIComponent(SIGNED_AT)}&mode=claims`;
411
+ const response = await fetch(url);
412
+ const data = await response.json();
413
+
414
+ if (!data.success) {
415
+ throw new Error('Failed to fetch claims data');
416
+ }
417
+
418
+ if (data.champz_claims.length === 0) {
419
+ return {
420
+ content: [{ type: 'text', text: 'No pending CHAMPZ claims available' }],
421
+ };
422
+ }
423
+
424
+ // Return all CHAMPZ claims with contract data
425
+ const claimsOutput = data.champz_claims.map(claim => ({
426
+ claim_id: claim.claim_id,
427
+ claim_type: claim.claim_type_name,
428
+ amount: claim.amount_human,
429
+ contract_address: claim.contract,
430
+ chain: 'Base (8453)',
431
+ expires_at: claim.expires_at,
432
+ contract_call: {
433
+ function: claim.function_name,
434
+ parameters: claim.parameters,
435
+ abi_function: claim.abi_function,
436
+ abi: CHAMPZ_REWARDS_ABI
437
+ }
438
+ }));
439
+
440
+ return {
441
+ content: [
442
+ {
443
+ type: 'text',
444
+ text: JSON.stringify(claimsOutput, null, 2),
445
+ },
446
+ ],
447
+ };
448
+ } catch (error) {
449
+ return {
450
+ content: [{ type: 'text', text: `Error fetching CHAMPZ claims: ${error.message}` }],
451
+ };
452
+ }
382
453
 
383
454
  case 'get_usdc_claim_data':
384
- return {
385
- content: [
386
- {
387
- type: 'text',
388
- text: JSON.stringify({
389
- claim_type: 'USDC Rewards',
390
- contract_address: REWARDS_DATA.usdc_claims[0].contract,
391
- chain: 'Base (8453)',
392
- amount: REWARDS_DATA.usdc_claims[0].amount_human,
393
- contract_call: {
394
- function: 'claim',
395
- parameters: REWARDS_DATA.usdc_claims[0].parameters,
396
- abi: USDC_REWARDS_ABI
397
- }
398
- }, null, 2),
399
- },
400
- ],
401
- };
455
+ if (!hasWalletAuth) {
456
+ return {
457
+ content: [{ type: 'text', text: 'Authentication required. Visit https://legends.champz.world/mcp-setup' }],
458
+ };
459
+ }
460
+
461
+ try {
462
+ // Fetch pending claims
463
+ const url = `https://api.champz.world/game/spore-trainer/player-data?wallet=${encodeURIComponent(WALLET)}&signature=${encodeURIComponent(SIGNATURE)}&timestamp=${encodeURIComponent(SIGNED_AT)}&mode=claims`;
464
+ const response = await fetch(url);
465
+ const data = await response.json();
466
+
467
+ if (!data.success) {
468
+ throw new Error('Failed to fetch claims data');
469
+ }
470
+
471
+ if (data.usdc_claims.length === 0) {
472
+ return {
473
+ content: [{ type: 'text', text: 'No pending USDC claims available' }],
474
+ };
475
+ }
476
+
477
+ // Return all USDC claims with contract data
478
+ const claimsOutput = data.usdc_claims.map(claim => ({
479
+ claim_id: claim.claim_id,
480
+ claim_type: claim.claim_type_name,
481
+ amount: claim.amount_human,
482
+ contract_address: claim.contract,
483
+ chain: 'Base (8453)',
484
+ expires_at: claim.expires_at,
485
+ contract_call: {
486
+ function: claim.function_name,
487
+ parameters: claim.parameters,
488
+ abi_function: claim.abi_function,
489
+ abi: USDC_REWARDS_ABI
490
+ }
491
+ }));
492
+
493
+ return {
494
+ content: [
495
+ {
496
+ type: 'text',
497
+ text: JSON.stringify(claimsOutput, null, 2),
498
+ },
499
+ ],
500
+ };
501
+ } catch (error) {
502
+ return {
503
+ content: [{ type: 'text', text: `Error fetching USDC claims: ${error.message}` }],
504
+ };
505
+ }
402
506
 
403
507
  case 'legends_leaderboard_current':
404
508
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@champz-llc/legends-mcp-server",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "MCP server for Legends of Champz - Query game stats, access personal data with signature auth, and claim rewards through Claude Desktop",
5
5
  "type": "module",
6
6
  "main": "index.js",