@champz-llc/legends-mcp-server 1.3.5 ā 1.3.8
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/index.js +36 -9
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
ListToolsRequestSchema,
|
|
8
8
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
9
9
|
import fetch from 'node-fetch';
|
|
10
|
+
import sharp from 'sharp';
|
|
10
11
|
|
|
11
|
-
// Helper function to fetch image and convert to base64
|
|
12
|
+
// Helper function to fetch image, resize, and convert to base64
|
|
12
13
|
async function fetchImageAsBase64(imageUrl) {
|
|
13
14
|
try {
|
|
14
15
|
console.error(`[MCP] Fetching image: ${imageUrl}`);
|
|
@@ -21,12 +22,25 @@ async function fetchImageAsBase64(imageUrl) {
|
|
|
21
22
|
const contentType = response.headers.get('content-type');
|
|
22
23
|
console.error(`[MCP] Image content-type: ${contentType}`);
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
// Fetch image as buffer
|
|
26
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
27
|
+
const originalBuffer = Buffer.from(arrayBuffer);
|
|
28
|
+
console.error(`[MCP] Original image size: ${Math.round(originalBuffer.length / 1024)}KB`);
|
|
29
|
+
|
|
30
|
+
// Resize image to max 300x300 (maintains aspect ratio) and compress
|
|
31
|
+
const resizedBuffer = await sharp(originalBuffer)
|
|
32
|
+
.resize(300, 300, {
|
|
33
|
+
fit: 'inside',
|
|
34
|
+
withoutEnlargement: true
|
|
35
|
+
})
|
|
36
|
+
.png({ quality: 85, compressionLevel: 9 })
|
|
37
|
+
.toBuffer();
|
|
38
|
+
|
|
39
|
+
const base64 = resizedBuffer.toString('base64');
|
|
40
|
+
console.error(`[MCP] Resized image size: ${Math.round(resizedBuffer.length / 1024)}KB, base64: ${Math.round(base64.length / 1024)}KB`);
|
|
27
41
|
return base64;
|
|
28
42
|
} catch (error) {
|
|
29
|
-
console.error(`[MCP] Error
|
|
43
|
+
console.error(`[MCP] Error processing image ${imageUrl}:`, error.message);
|
|
30
44
|
return null;
|
|
31
45
|
}
|
|
32
46
|
}
|
|
@@ -701,7 +715,7 @@ You can still ask about:
|
|
|
701
715
|
content[0].text += throneText + throneList + '\n';
|
|
702
716
|
}
|
|
703
717
|
|
|
704
|
-
// Show legend summary
|
|
718
|
+
// Show legend summary with IDs
|
|
705
719
|
if (data.all_legends && data.all_legends.length > 0) {
|
|
706
720
|
const legendText = `\nš All Legends Owned (${data.all_legends.length}):\n`;
|
|
707
721
|
let legendSummary = '';
|
|
@@ -719,13 +733,24 @@ You can still ask about:
|
|
|
719
733
|
byRarity[legend.rarity]?.push(legend);
|
|
720
734
|
});
|
|
721
735
|
|
|
736
|
+
// Show each rarity group with IDs
|
|
722
737
|
Object.entries(byRarity).forEach(([rarity, legends]) => {
|
|
723
738
|
if (legends.length > 0) {
|
|
724
|
-
legendSummary +=
|
|
739
|
+
legendSummary += `\n${rarity.toUpperCase()} (${legends.length}):\n`;
|
|
740
|
+
|
|
741
|
+
// List legend IDs (limit to first 20 per rarity to avoid huge output)
|
|
742
|
+
const displayLegends = legends.slice(0, 20);
|
|
743
|
+
const legendIds = displayLegends.map(l => `#${l.legend_id} (${l.name})`).join(', ');
|
|
744
|
+
legendSummary += ` ${legendIds}`;
|
|
745
|
+
|
|
746
|
+
if (legends.length > 20) {
|
|
747
|
+
legendSummary += `... and ${legends.length - 20} more`;
|
|
748
|
+
}
|
|
749
|
+
legendSummary += '\n';
|
|
725
750
|
}
|
|
726
751
|
});
|
|
727
752
|
|
|
728
|
-
legendSummary += `\nTo view a
|
|
753
|
+
legendSummary += `\nTo view a legend image, ask: "Show me legend #<ID>"\n`;
|
|
729
754
|
legendSummary += `Example: "Show me legend #1010"\n\n`;
|
|
730
755
|
|
|
731
756
|
content[0].text += legendText + legendSummary;
|
|
@@ -804,8 +829,10 @@ You can still ask about:
|
|
|
804
829
|
output += `Rolled: ${new Date(legend.rolled_at).toLocaleDateString()}\n`;
|
|
805
830
|
output += `Saved: ${legend.is_saved ? 'Yes ā' : 'No'}\n`;
|
|
806
831
|
|
|
807
|
-
// Fetch
|
|
832
|
+
// Fetch image
|
|
808
833
|
const imageUrl = `https://img.champz.world${legend.image_path}`;
|
|
834
|
+
|
|
835
|
+
// Fetch and convert image to base64
|
|
809
836
|
const base64Data = await fetchImageAsBase64(imageUrl);
|
|
810
837
|
|
|
811
838
|
const content = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@champz-llc/legends-mcp-server",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
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",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
37
|
-
"node-fetch": "^3.3.2"
|
|
37
|
+
"node-fetch": "^3.3.2",
|
|
38
|
+
"sharp": "^0.34.5"
|
|
38
39
|
}
|
|
39
40
|
}
|