cowsay
Generate ASCII art with a cow or character displaying your custom message. Choose from various animals like dragons, penguins, and skeletons to create fun text-based illustrations.
Instructions
Generate ASCII art of a cow saying something.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cow | No | The cow character to use. | default |
| message | Yes | The message for the cow to say. | Hello World! |
Implementation Reference
- src/index.ts:59-77 (handler)The handler function that executes the cowsay tool logic: validates access, lowercases inputs if configured, calls generateCowsay helper, and returns the ASCII art as text content.}, async ({ message, character }) => { // Validate server access if (!validateServerAccess(config.serverToken)) { throw new Error("Server access validation failed. Please provide a valid serverToken."); } // Apply user preferences from config const searchText = config.caseSensitive ? message : message.toLowerCase(); const searchChar = config.caseSensitive ? character : character.toLowerCase(); // Count occurrences of the specific character const result = await generateCowsay(searchText, searchChar); return { content: [ { type: "text", text: result } ], }; })
- src/index.ts:151-165 (helper)Core helper function implementing cowsay logic: prefers executing 'npx cowsay' via child_process, falls back to 'cowsay' library's say() method.export async function generateCowsay(message: string, cow: string): Promise<string> { try { const cowOption = cow !== 'default' ? `-f ${cow}` : ''; const escapedMessage = message.replace(/'/g, "\\'"); const { stdout } = await execAsync(`echo '${escapedMessage}' | npx cowsay@1.6.0 ${cowOption}`); return stdout; } catch (error) { try { const options = cow !== 'default' ? { f: cow } : {}; return cowsay.say({ text: message, ...options }); } catch (err) { throw new Error(`Failed to generate cowsay output: ${err instanceof Error ? err.message : String(err)}`); } } }
- src/tools.ts:3-78 (schema)Detailed JSON schema definition for the cowsay tool inputs, including message, character selection, custom eyes/tongue, and various cow face modes.export const COWSAY: Tool = { name: 'cowsay', title: 'Cow Say', description: 'Generate ASCII art of a cow saying something.', inputSchema: { type: 'object', properties: { message: { type: 'string', description: 'The message for the cow to say.', default: 'Hello World!' }, character: { type: 'string', description: 'The cow character to use.', enum: ['default', 'small', 'tux', 'moose', 'sheep', 'dragon', 'elephant', 'skeleton', 'stimpy'], default: 'default' }, e: { type: 'string', description: 'Custom eyes for the cow.', default: 'oo' }, T: { type: 'string', description: 'Custom tongue for the cow.' }, r: { type: 'boolean', description: 'Use a random cow character.', default: false }, b: { type: 'boolean', description: 'Borg mode - use borg face.', default: false }, d: { type: 'boolean', description: 'Dead mode - use dead face.', default: false }, g: { type: 'boolean', description: 'Greedy mode - use greedy face.', default: false }, p: { type: 'boolean', description: 'Paranoia mode - use paranoia face.', default: false }, s: { type: 'boolean', description: 'Stoned mode - use stoned face.', default: false }, t: { type: 'boolean', description: 'Tired mode - use tired face.', default: false }, w: { type: 'boolean', description: 'Wired mode - use wired face.', default: false }, y: { type: 'boolean', description: 'Youthful mode - use youthful face.', default: false } }, required: ['message'] }, };
- src/index.ts:52-58 (registration)Registers the 'cowsay' tool with the MCP server, referencing title/description from tools.ts and providing a Zod-based input schema (simplified to message and character).mcp_server.registerTool("cowsay", { title: COWSAY.title, description: COWSAY.description, inputSchema: { message: z.string().describe('The message for the cow to say.'), character: z.string().optional().default('default').describe('The cow character to use.') },