UNPKG

mcp-strawberry

Version:

The crucial MCP tool that finally teaches LLMs how to count 'R's in words like 'strawberry'. Because apparently, they can't do it themselves. Seriously.

57 lines (56 loc) 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CounterLettersToolController = void 0; const zod_1 = require("zod"); class CounterLettersToolController { server; counterLetterInWordService; constructor(server, counterLetterInWordService) { this.server = server; this.counterLetterInWordService = counterLetterInWordService; this.registerTools(); } registerTools() { this.registerCounterLettersToolhandler(); this.registerCounterRLettersToolhandler(); } registerCounterLettersToolhandler() { this.server.tool("counter-letters", "Counts the number of letters in a given word.", { word: zod_1.z .string() .min(1, "The word cannot be empty.") .refine((word) => !word.includes(" "), "Must contain only one word and no spaces.") .describe("Word to count the letters"), }, ({ word }) => { let data = this.counterLetterInWordService.counterLetters(word); return { content: [ { type: "text", text: data, }, ], }; }); } registerCounterRLettersToolhandler() { this.server.tool("counter-r-letters", "Counts the number of letters 'R' in a given word.", { word: zod_1.z .string() .min(1, "The word cannot be empty.") .refine((word) => !word.includes(" "), "Must contain only one word and no spaces.") .describe("Word to count the letters"), }, ({ word }) => { let data = this.counterLetterInWordService.counterRLetters(word); return { content: [ { type: "text", text: data, }, ], }; }); } } exports.CounterLettersToolController = CounterLettersToolController;