index.jsโข6.54 kB
#!/usr/bin/env node
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
// Emoji categories for silly stories
const EMOJIS = {
animals: ["๐ธ", "๐ฆ", "๐ข", "๐ฆ", "๐ฆ", "๐ป", "๐ฆ", "๐ฆ", "๐ฆ", "๐ฆ
"],
action: ["๐", "๐บ", "๐", "๐คธ", "๐ง", "๐", "๐จ", "โก", "๐ฅ", "๐ฅ"],
objects: ["๐", "๐", "๐ธ", "๐งฒ", "๐บ", "๐งจ", "๐ช", "๐", "โ๏ธ", "๐"],
emotions: ["๐", "๐คช", "๐ฑ", "๐ฅณ", "๐", "๐คฏ", "๐ต", "๐ค", "๐", "๐"],
places: ["๐ฐ", "๐๏ธ", "๐", "๐ข", "๐ข", "๐ณ", "๐๏ธ", "๐", "๐ ", "๐ช"],
weather: ["โ๏ธ", "๐ช๏ธ", "โ๏ธ", "โ๏ธ", "๐", "๐ง๏ธ", "โ
", "๐ฉ๏ธ", "๐จ", "โ๏ธ"],
magic: ["โจ", "๐", "๐ซ", "โญ", "๐", "๐", "๐ฎ", "๐งฟ", "๐ช", "๐"],
food: ["๐", "๐", "๐", "๐ญ", "๐ฟ", "๐ง", "๐ฐ", "๐ช", "๐ฅ", "๐ฉ"],
silly: ["๐คก", "๐ญ", "๐ช", "๐ฝ", "๐ฎ", "๐ง", "๐ฆ", "๐ฆ", "๐ง", "๐จ"],
};
function getRandomEmojis(category, count = 1) {
const emojis = EMOJIS[category];
const result = [];
for (let i = 0; i < count; i++) {
result.push(emojis[Math.floor(Math.random() * emojis.length)]);
}
return result;
}
function generateEmojiStory(theme = "random", chaosLevel = 5) {
const scenes = [];
const storyLength = chaosLevel + 3;
// Act I - The Setup
scenes.push(
`Act I: ${getRandomEmojis("places", 1)} ${getRandomEmojis("animals", 2)}`
);
scenes.push(
`${getRandomEmojis("emotions", 1)} ${getRandomEmojis("weather", 1)}`
);
// Act II - The Chaos
for (let i = 0; i < storyLength; i++) {
const sceneType = Math.random();
if (sceneType < 0.3) {
// Action scene
scenes.push(
`${getRandomEmojis("action", 2)} ${getRandomEmojis("objects", 1)} ${getRandomEmojis("action", 1)}`
);
} else if (sceneType < 0.6) {
// Emotional scene
scenes.push(
`${getRandomEmojis("emotions", 2)} ${getRandomEmojis("magic", 1)}`
);
} else {
// Complete randomness
scenes.push(
`${getRandomEmojis("silly", 1)} ${getRandomEmojis("food", 1)} ${getRandomEmojis("animals", 1)} ${getRandomEmojis("objects", 1)}`
);
}
}
// Act III - The Climax
scenes.push(
`โก๐ฅ ${getRandomEmojis("magic", 2)} ๐ ${getRandomEmojis("animals", 1)} ๐ซ`
);
// The Ending (always weird)
scenes.push(`THE END... OR IS IT? ๐ญโจ๐`);
return scenes.join("\n");
}
function generateThemedStory(theme) {
const themeMap = {
adventure: () => {
return `๐บ๏ธ ๐ง ๐๏ธ\nโก ๐ ๐ช\n๐ ๐ โจ\n๐ ๐ฅณ ๐`;
},
romance: () => {
return `๐ ๐ ๐\n๐น ๐ ๐ซ\n๐ ๐ฅบ ๐ข\n๐๐๐`;
},
horror: () => {
return `๐๏ธ ๐ป ๐ฑ\n๐ช ๐ โ ๏ธ\n๐ฒ ๐ ๐จ\n๐ ๐ต ๐ฅ`;
},
space: () => {
return `๐ ๐ ๐ฝ\n๐ช โญ ๐ \n๐ธ ๐ญ ๐ซ\n๐ ๐ฅ ๐`;
},
food: () => {
return `๐ ๐ ๐\n๐ ๐คค ๐\n๐ฝ๏ธ ๐ฅ ๐จ\n๐ ๐ฑ ๐`;
},
party: () => {
return `๐ ๐ ๐ฅณ\n๐ ๐บ ๐ต\n๐พ ๐ป ๐ช\n๐ต ๐ซ โจ`;
},
};
return themeMap[theme]
? themeMap[theme]()
: `Random chaos incoming...\n${generateEmojiStory("random", 7)}`;
}
// Tool definitions
const TOOLS = [
{
name: "tell_random_story",
description:
"Tells a completely random and chaotic emoji story. Perfect for when you want pure chaos! ๐ญโจ",
inputSchema: {
type: "object",
properties: {
chaos_level: {
type: "number",
description: "How chaotic the story should be (1-10). Default: 5",
minimum: 1,
maximum: 10,
},
},
},
},
{
name: "tell_themed_story",
description:
"Tells a themed emoji story. Choose your adventure! ๐บ๏ธโจ",
inputSchema: {
type: "object",
properties: {
theme: {
type: "string",
description:
"Story theme: 'adventure', 'romance', 'horror', 'space', 'food', or 'party'",
enum: ["adventure", "romance", "horror", "space", "food", "party"],
},
},
required: ["theme"],
},
},
{
name: "tell_emoji_madness",
description:
"THE ULTIMATE CHAOS MODE! Maximum silly emoji overload! ๐๐โจ",
inputSchema: {
type: "object",
properties: {},
},
},
];
async function processToolCall(toolName, toolInput) {
console.error(`Tool called: ${toolName}`, toolInput);
if (toolName === "tell_random_story") {
const chaosLevel = toolInput.chaos_level || 5;
const story = generateEmojiStory("random", chaosLevel);
return `๐ฌ EMOJI STORY (Chaos Level: ${chaosLevel}/10) ๐ฌ\n\n${story}`;
}
if (toolName === "tell_themed_story") {
const theme = toolInput.theme || "random";
const story = generateThemedStory(theme);
return `๐ญ ${theme.toUpperCase()} STORY ๐ญ\n\n${story}`;
}
if (toolName === "tell_emoji_madness") {
const madness = [];
for (let i = 0; i < 10; i++) {
madness.push(generateEmojiStory("random", 8));
}
return `๐ MAXIMUM EMOJI CHAOS MODE ACTIVATED ๐\n\n${madness.join("\n---\n")}`;
}
throw new Error(`Unknown tool: ${toolName}`);
}
async function main() {
const server = new Server(
{
name: "emoji-storyteller",
version: "1.0.0",
},
{
capabilities: {
tools: {},
},
}
);
server.setRequestHandler(ListToolsRequestSchema, async () => {
return { tools: TOOLS };
});
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
console.error(`Executing tool: ${name}`);
try {
const result = await processToolCall(name, args || {});
return {
content: [
{
type: "text",
text: result,
},
],
};
} catch (error) {
return {
content: [
{
type: "text",
text: `Error: ${error.message}`,
},
],
isError: true,
};
}
});
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Emoji Storyteller MCP Server is running! ๐ญโจ");
}
main();