Skip to content

Allow customizing property name and title for scalar elicitation types #3911

@pamelafox

Description

@pamelafox

Description

When using scalar types like bool or str as response_type in ctx.elicit(), FastMCP wraps them in an object schema with a hardcoded property name "value" and title "ScalarElicitationType":

{"requestedSchema":{"properties":{"value":{"title":"Value","type":"boolean"}},"required":["value"],"title":"ScalarElicitationType","type":"object"}}

Clients like VS Code render these as the field label ("Value") and object title ("ScalarElicitationType"), which looks generic and confusing to users. The MCP spec supports title and description on individual properties (spec reference).

Current workaround

Use a full Pydantic BaseModel to get control over field titles:

from pydantic import BaseModel, Field

class PurchaseConfirmation(BaseModel):
    confirm: bool = Field(title="Confirm purchase", description="Approve this transaction?")

response = await ctx.elicit(message="Buy 1x Baguette?", response_type=PurchaseConfirmation)

This works but is verbose for a simple confirmation.

Proposed enhancement

Allow passing title and/or description kwargs to ctx.elicit() when using scalar types, which would be applied to the wrapped property:

# Hypothetical API
response = await ctx.elicit(
    message="Buy 1x Baguette?",
    response_type=bool,
    title="Confirm purchase",
    description="Approve this transaction?",
)

Environment

  • FastMCP 3.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to existing functionality. For issues and smaller PR improvements.serverRelated to FastMCP server implementation or server-side functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions