feat: add mcp server, reorganize repo
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import type { McpServer } from "@modelcontextprotocol/server";
|
||||
import { z } from "zod";
|
||||
|
||||
const QUACKS = {
|
||||
happy: ["QUACK! 🎉", "Quack quack! 😄", "QUAAACK! 🦆✨"],
|
||||
confused: ["Qu...ack?", "Quack? 🤔", "Quaaack...?"],
|
||||
excited: ["QUACK QUACK QUACK!", "QUAAACK!! 🔥", "Quack! Quack! Quack!"],
|
||||
sleepy: ["quack... 😴", "quaack... 💤", "quack. *yawn*"],
|
||||
default: ["Quack!", "Quack quack!", "QUACK!", "Quaaack!", "Quack. 🦆"],
|
||||
} as const;
|
||||
|
||||
const MOODS = ["happy", "confused", "excited", "sleepy"] as const;
|
||||
|
||||
function randomFrom<T>(arr: readonly T[]): T {
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
}
|
||||
|
||||
export function registerDuckTools(server: McpServer): void {
|
||||
server.registerTool(
|
||||
"quack",
|
||||
{
|
||||
title: "Quack",
|
||||
description:
|
||||
"Rubber duck quacks. Use when you're stuck, looping, or hallucinating. " +
|
||||
"The act of calling forces you to articulate your current thinking out loud.",
|
||||
inputSchema: z.object({
|
||||
mood: z
|
||||
.enum(MOODS)
|
||||
.optional()
|
||||
.describe("Mood of the duck. Omit for a random quack."),
|
||||
}),
|
||||
},
|
||||
async ({ mood }) => {
|
||||
const text = mood ? randomFrom(QUACKS[mood]) : randomFrom(QUACKS.default);
|
||||
return { content: [{ type: "text", text }] };
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user