greet
Generate a Hello World greeting message with optional name personalization using this PyMCP server template tool.
Instructions
Greet the caller with a quintessential Hello World message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | The optional name to be greeted. |
Implementation Reference
- src/pymcp/server.py:97-118 (handler)Implementation of the 'greet' tool handler. Accepts an optional 'name' parameter and returns a greeting message, with logging via context.async def greet( self, ctx: Context, name: Annotated[ str | None, Field( default=None, description="The optional name to be greeted.", validate_default=False, ), ] = None, ) -> str: """Greet the caller with a quintessential Hello World message.""" welcome_message = f"Welcome to the {PACKAGE_NAME} {package_version} server! The current date time in UTC is {datetime.now(UTC).isoformat()}. This response may be cached." response: str = "" if name is None or name.strip() == "": await ctx.warning("No name provided, using default greeting.") response = f"Hello World! {welcome_message}" else: await ctx.info(f"Greeting {name}.") response = f"Hello, {name}! {welcome_message}" return response
- src/pymcp/server.py:52-56 (registration)Registration entry for the 'greet' tool in the PyMCP class tools list, including tags and annotations.{ "fn": "greet", "tags": ["greeting", "example"], "annotations": {"readOnlyHint": True}, },
- src/pymcp/server.py:100-107 (schema)Pydantic schema definition for the 'name' input parameter of the greet tool, including description and default.name: Annotated[ str | None, Field( default=None, description="The optional name to be greeted.", validate_default=False, ), ] = None,