Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameNoThe optional name to be greeted.

Implementation Reference

  • 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
  • Registration entry for the 'greet' tool in the PyMCP class tools list, including tags and annotations.
    {
        "fn": "greet",
        "tags": ["greeting", "example"],
        "annotations": {"readOnlyHint": True},
    },
  • 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,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/anirbanbasu/pymcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server