@champz-llc/legends-mcp-server 1.3.2 → 1.3.5

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 +66 -47
  2. package/package.json +1 -2
package/index.js CHANGED
@@ -8,6 +8,29 @@ import {
8
8
  } from '@modelcontextprotocol/sdk/types.js';
9
9
  import fetch from 'node-fetch';
10
10
 
11
+ // Helper function to fetch image and convert to base64
12
+ async function fetchImageAsBase64(imageUrl) {
13
+ try {
14
+ console.error(`[MCP] Fetching image: ${imageUrl}`);
15
+ const response = await fetch(imageUrl);
16
+ if (!response.ok) {
17
+ console.error(`[MCP] Image fetch failed: ${response.status} ${response.statusText}`);
18
+ throw new Error(`Failed to fetch image: ${response.status}`);
19
+ }
20
+
21
+ const contentType = response.headers.get('content-type');
22
+ console.error(`[MCP] Image content-type: ${contentType}`);
23
+
24
+ const buffer = await response.buffer();
25
+ const base64 = buffer.toString('base64');
26
+ console.error(`[MCP] Image converted to base64, size: ${base64.length} chars`);
27
+ return base64;
28
+ } catch (error) {
29
+ console.error(`[MCP] Error fetching image ${imageUrl}:`, error.message);
30
+ return null;
31
+ }
32
+ }
33
+
11
34
  // MCP Signature Authentication (optional - for player data access)
12
35
  const WALLET = process.env.WALLET;
13
36
  const SIGNATURE = process.env.SIGNATURE;
@@ -664,23 +687,17 @@ You can still ask about:
664
687
  },
665
688
  ];
666
689
 
667
- // Add throne images (show all thrones)
690
+ // Show throne collection (text only - use show_throne tool for images)
668
691
  if (data.thrones && data.thrones.length > 0) {
669
692
  const throneText = `\nšŸ† Throne Collection (${data.thrones.length}):\n`;
670
693
  let throneList = '';
671
694
 
672
695
  data.thrones.forEach((throne, i) => {
673
- throneList += `${i + 1}. ${throne.name} (${throne.rarity.toUpperCase()}) - Cycle ${throne.cycle_id}\n`;
674
-
675
- // Add throne image
676
- const imageUrl = `https://img.champz.world${throne.image_path}`;
677
- content.push({
678
- type: 'image',
679
- data: imageUrl,
680
- mimeType: 'image/png',
681
- });
696
+ throneList += `${i + 1}. Throne #${throne.throne_id} - ${throne.name} (${throne.rarity.toUpperCase()}) - Cycle ${throne.cycle_id}\n`;
682
697
  });
683
698
 
699
+ throneList += `\nTo view a throne image, ask: "Show me throne #<ID>"\n`;
700
+
684
701
  content[0].text += throneText + throneList + '\n';
685
702
  }
686
703
 
@@ -714,7 +731,7 @@ You can still ask about:
714
731
  content[0].text += legendText + legendSummary;
715
732
  }
716
733
 
717
- // Add saved trainer images (premium collection)
734
+ // Show saved trainers (text only - use show_legend tool for images)
718
735
  if (data.saved_trainers && data.saved_trainers.length > 0) {
719
736
  const trainerText = `⭐ Saved Trainers (${data.saved_trainers.length}):\n`;
720
737
  let trainerList = '';
@@ -723,16 +740,10 @@ You can still ask about:
723
740
  trainerList += `${i + 1}. ${trainer.rarity.toUpperCase()} Legend #${trainer.legend_id} - Power: ${trainer.total_power}\n`;
724
741
  trainerList += ` ATK: ${trainer.attack} | DEF: ${trainer.defense} | SPD: ${trainer.speed}\n`;
725
742
  trainerList += ` Elements: ${trainer.elements.join(', ')}\n\n`;
726
-
727
- // Add trainer image
728
- const imageUrl = `https://img.champz.world${trainer.image_path}`;
729
- content.push({
730
- type: 'image',
731
- data: imageUrl,
732
- mimeType: 'image/png',
733
- });
734
743
  });
735
744
 
745
+ trainerList += `To view a legend image, ask: "Show me legend #<ID>"\n`;
746
+
736
747
  content[0].text += trainerText + trainerList;
737
748
  }
738
749
 
@@ -793,22 +804,26 @@ You can still ask about:
793
804
  output += `Rolled: ${new Date(legend.rolled_at).toLocaleDateString()}\n`;
794
805
  output += `Saved: ${legend.is_saved ? 'Yes ⭐' : 'No'}\n`;
795
806
 
796
- // Return with image
807
+ // Fetch and convert image to base64
797
808
  const imageUrl = `https://img.champz.world${legend.image_path}`;
809
+ const base64Data = await fetchImageAsBase64(imageUrl);
798
810
 
799
- return {
800
- content: [
801
- {
802
- type: 'text',
803
- text: output,
804
- },
805
- {
806
- type: 'image',
807
- data: imageUrl,
808
- mimeType: 'image/png',
809
- },
810
- ],
811
- };
811
+ const content = [
812
+ {
813
+ type: 'text',
814
+ text: output,
815
+ },
816
+ ];
817
+
818
+ if (base64Data) {
819
+ content.push({
820
+ type: 'image',
821
+ data: base64Data,
822
+ mimeType: 'image/png',
823
+ });
824
+ }
825
+
826
+ return { content };
812
827
  } catch (error) {
813
828
  return {
814
829
  content: [
@@ -862,22 +877,26 @@ You can still ask about:
862
877
  output += `Earned in Cycle: ${throne.cycle_id}\n`;
863
878
  output += `Earned: ${new Date(throne.earned_at).toLocaleDateString()}\n`;
864
879
 
865
- // Return with image
880
+ // Fetch and convert image to base64
866
881
  const imageUrl = `https://img.champz.world${throne.image_path}`;
882
+ const base64Data = await fetchImageAsBase64(imageUrl);
867
883
 
868
- return {
869
- content: [
870
- {
871
- type: 'text',
872
- text: output,
873
- },
874
- {
875
- type: 'image',
876
- data: imageUrl,
877
- mimeType: 'image/png',
878
- },
879
- ],
880
- };
884
+ const content = [
885
+ {
886
+ type: 'text',
887
+ text: output,
888
+ },
889
+ ];
890
+
891
+ if (base64Data) {
892
+ content.push({
893
+ type: 'image',
894
+ data: base64Data,
895
+ mimeType: 'image/png',
896
+ });
897
+ }
898
+
899
+ return { content };
881
900
  } catch (error) {
882
901
  return {
883
902
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@champz-llc/legends-mcp-server",
3
- "version": "1.3.2",
3
+ "version": "1.3.5",
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",
@@ -33,7 +33,6 @@
33
33
  "node": ">=18.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@champz-llc/legends-mcp-server": "^1.1.0",
37
36
  "@modelcontextprotocol/sdk": "^1.0.0",
38
37
  "node-fetch": "^3.3.2"
39
38
  }