greeting
Generate personalized greetings by specifying a name and choosing from formal, casual, or enthusiastic styles for customized messages.
Instructions
Create personalized greetings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the person to greet | |
| style | No | Style of greeting |
Implementation Reference
- src/index.ts:27-55 (registration)Primary registration of the 'greeting' tool. Includes tool name, description, Zod input schema (name: string, style: optional enum), and complete handler logic that generates personalized greetings based on style (formal, casual, enthusiastic). Returns structured text content.server.tool( "greeting", "Create personalized greetings", { name: z.string().describe("Name of the person to greet"), style: z.enum(["formal", "casual", "enthusiastic"]).optional().describe("Style of greeting"), }, async ({ name, style = "casual" }) => { let greeting; switch (style) { case "formal": greeting = `Good day, ${name}. I hope you're having a pleasant experience.`; break; case "enthusiastic": greeting = `HEY THERE ${name.toUpperCase()}! 🎉 You're AWESOME!`; break; default: // casual greeting = `Hey ${name}! Nice to meet you! 👋`; } return { content: [{ type: "text", text: greeting }] }; } );
- days/day-1/index-complete.ts:25-53 (registration)Exercise completion version of the 'greeting' tool registration, identical implementation to the main src/index.ts version.server.tool( "greeting", "Create personalized greetings", { name: z.string().describe("Name of the person to greet"), style: z.enum(["formal", "casual", "enthusiastic"]).optional().describe("Style of greeting"), }, async ({ name, style = "casual" }) => { let greeting; switch (style) { case "formal": greeting = `Good day, ${name}. I hope you're having a pleasant experience.`; break; case "enthusiastic": greeting = `HEY THERE ${name.toUpperCase()}! 🎉 You're AWESOME!`; break; default: // casual greeting = `Hey ${name}! Nice to meet you! 👋`; } return { content: [{ type: "text", text: greeting }] }; } );