hello
Generate personalized greetings by providing a name to create custom hello messages for user interactions.
Instructions
A simple greeting tool that says hello
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name to greet |
Implementation Reference
- src/basic-mcp/server.ts:86-96 (handler)The specific handler logic for the 'hello' tool within the CallToolRequestSchema request handler. It greets the user by name or defaults to 'World'.if (name === "hello") { const userName = (args?.name as string) || "World"; return { content: [ { type: "text", text: `Hello, ${userName}! Welcome to MCP!`, }, ], }; }
- src/basic-mcp/server.ts:41-55 (schema)The tool metadata and input schema definition for 'hello' returned in ListTools response.{ name: "hello", description: "A simple greeting tool that says hello", inputSchema: { type: "object", properties: { name: { type: "string", description: "The name to greet", }, }, required: ["name"], }, }, {
- src/basic-mcp/server.ts:38-82 (registration)The registration of the ListToolsRequestSchema handler, which advertises the available tools including 'hello'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "hello", description: "A simple greeting tool that says hello", inputSchema: { type: "object", properties: { name: { type: "string", description: "The name to greet", }, }, required: ["name"], }, }, { name: "calculate", description: "Perform basic arithmetic calculations", inputSchema: { type: "object", properties: { operation: { type: "string", enum: ["add", "subtract", "multiply", "divide"], description: "The arithmetic operation to perform", }, a: { type: "number", description: "First number", }, b: { type: "number", description: "Second number", }, }, required: ["operation", "a", "b"], }, }, ], }; }); // Handle tool execution
- src/fastmcp-example/server.ts:25-27 (handler)The execute handler for the 'hello' tool in the FastMCP example, returning a simple greeting string.execute: async (args) => { return `Hello, ${args.name}! Welcome to MCP!`; },
- src/fastmcp-example/server.ts:19-28 (registration)The complete registration of the 'hello' tool using FastMCP's addTool API, including schema (via Zod), description, and inline handler.server.addTool({ name: "hello", description: "A simple greeting tool that says hello", parameters: z.object({ name: z.string().describe("The name to greet"), }), execute: async (args) => { return `Hello, ${args.name}! Welcome to MCP!`; }, });