github jlowin/fastmcp v2.14.1
v2.14.1: 'Tis a Gift to Be Sample

latest releases: v2.14.5, v2.14.4, v3.0.0b1...
one month ago

FastMCP 2.14.1 adds support for sampling with tools (SEP-1577). This exciting new feature lets servers pass tools to ctx.sample(), enabling agentic workflows where the server borrows the client's LLM and controls tool execution automatically. Pass any callable as a tool and FastMCP handles the loop: calling the LLM, executing tools, and feeding results back until a final response is produced. For fine-grained control, ctx.sample_step() makes a single LLM call and returns a SampleStep, letting you inspect tool calls, add custom logic, or build your own execution loop. Structured output via result_type returns validated Pydantic models instead of raw text. This release also adds AnthropicSamplingHandler alongside the existing OpenAI handler (newly promoted out of the experimental module), so clients and servers can provide sampling capability across major providers with ease.

What's Changed

New Features 🎉

Enhancements 🔧

  • Add Python 3.13 to Ubuntu CI tests by @jlowin in #2606
  • Remove legacy _task_capable_initialize() workaround by @jlowin in #2612
  • Consolidate session state reset logic and improve cancellation cleanup by @jlowin in #2615
  • Unify SamplingHandler and promote OpenAI handler by @jlowin in #2616
  • Add tool_names parameter to mount() for name overrides by @jlowin in #2619
  • Adopt streamable_http_client API from MCP SDK by @jlowin in #2620
  • Deprecate exclude_args in favor of Depends() by @jlowin in #2621

Fixes 🐞

  • fix: prompt tasks returning mcp.types.PromptMessage now work by @chrisguidry in #2603
  • Use WindowsSelectorEventLoopPolicy to fix Windows test warnings by @jlowin in #2607
  • Clean up cancelled connection startup by @shawnthapa in #2614
  • Consolidate sampling examples and fix tool_choice bug by @jlowin in #2618

Docs 📚

Dependencies 📦

New Contributors

Full Changelog: v2.14.0...v2.14.1

Don't miss a new fastmcp release

NewReleases is sending notifications on new releases.