greeting
Generate personalized greetings in multiple languages including English, Spanish, Korean, Japanese, and Chinese by providing a name and preferred language.
Instructions
Greet a user in their specified language
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the person to greet | |
| language | Yes | The language for the greeting |
Input Schema (JSON Schema)
{
"properties": {
"language": {
"description": "The language for the greeting",
"enum": [
"korean",
"english",
"spanish",
"japanese",
"chinese"
],
"type": "string"
},
"name": {
"description": "The name of the person to greet",
"type": "string"
}
},
"required": [
"name",
"language"
],
"type": "object"
}
Implementation Reference
- src/index.ts:30-47 (handler)The handler function for the 'greeting' tool. It takes name and language parameters, maps languages to greeting strings, and returns a text content block with the appropriate greeting.async ({ name, language }: { name: string; language: 'korean' | 'english' | 'spanish' | 'japanese' | 'chinese' }) => { const greetings: Record<string, string> = { korean: `안녕하세요, ${name}님!`, english: `Hello, ${name}!`, spanish: `¡Hola, ${name}!`, japanese: `こんにちは、${name}さん!`, chinese: `你好,${name}!` } return { content: [ { type: 'text', text: greetings[language] } ] } }
- src/index.ts:27-29 (schema)Input schema for the 'greeting' tool using Zod, defining 'name' as string and 'language' as enum of supported languages.name: z.string().describe('The name of the person to greet'), language: z.enum(['korean', 'english', 'spanish', 'japanese', 'chinese']).describe('The language for the greeting') },
- src/index.ts:23-48 (registration)Registration of the 'greeting' tool on the MCP server using server.tool, specifying name, description, input schema, and handler function.server.tool( 'greeting', 'Greet a user in their specified language', { name: z.string().describe('The name of the person to greet'), language: z.enum(['korean', 'english', 'spanish', 'japanese', 'chinese']).describe('The language for the greeting') }, async ({ name, language }: { name: string; language: 'korean' | 'english' | 'spanish' | 'japanese' | 'chinese' }) => { const greetings: Record<string, string> = { korean: `안녕하세요, ${name}님!`, english: `Hello, ${name}!`, spanish: `¡Hola, ${name}!`, japanese: `こんにちは、${name}さん!`, chinese: `你好,${name}!` } return { content: [ { type: 'text', text: greetings[language] } ] } } )