greet
Generates a personalized greeting message for a specified name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- examples/greet.ts:17-26 (handler)The execute handler for the 'greet' tool. It receives { name } and returns a personalized greeting: 'Hello, {name}! Nice to meet you.'
execute: async ({ name }) => { return { content: [ { type: 'text', text: `Hello, ${name}! Nice to meet you.`, // Returns a personalized greeting }, ], }; }, - examples/greet.ts:12-14 (schema)Input schema for the 'greet' tool, defining a required 'name' parameter with Zod string validation.
parameters: { name: z.string(), // Expects a string input named 'name' }, - examples/greet.ts:29-30 (registration)Registration of the 'greet' tool with the MCP server via server.tool(tool).
// Register the tool with the server server.tool(tool); - examples/greet-class.ts:23-32 (handler)Class-based execute handler for the 'greet' tool, returns the same greeting.
public async execute({ name }: z.infer<ZodObject<typeof this.parameters>>) { return { content: [ { type: 'text', text: `Hello, ${name}! Nice to meet you.`, }, ], }; } - src/definitions/mcp-tool.ts:3-11 (helper)Type definitions (McpTool and McpToolExecute) used to define tool handlers like 'greet'.
export type McpToolExecute<Args extends ZodRawShape> = ( request: z.infer<ZodObject<Args>>, ) => Promise<{ content: { type: string; text: string }[] }>; export type McpTool<Args extends ZodRawShape = ZodRawShape> = { execute: McpToolExecute<Args>; parameters: Args; name: string; };