Skip to content

Native sampling method on Context #1128

@simba-git

Description

@simba-git

Description

Sampling is done by manually sending a SamplingMessage directly, the user has to do things like manage checking that the client supports sampling.

Compared to eliciation which has its own method directly on Context
result = await ctx.elicit(

I'd imagine that having a similar ctx.sampling method would be a bit more consistent. Even if just as a thin wrapper over sending a sampling message with a clear error if sampling isn't supported. Happy to take that on.

A related issue, which I can separate into its own issue if you'd like: With FastMCP, if I have a tool that requires sampling, I want it to now show up in ListTools for clients like Claude Desktop that don't support it.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions