| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2026-03-03 | 9.4 kB | |
| v3.1.0_ Code to Joy source code.tar.gz | 2026-03-03 | 17.4 MB | |
| v3.1.0_ Code to Joy source code.zip | 2026-03-03 | 18.1 MB | |
| Totals: 3 Items | 35.5 MB | 0 | |
FastMCP 3.1 is the Code Mode release. The 3.0 architecture introduced providers and transforms as the extensibility layer — 3.1 puts that architecture to work, shipping the most requested capability since launch: servers that can find and execute code on behalf of agents, without requiring clients to know what tools exist.
Code Mode
Standard MCP has two scaling problems. The entire tool catalog loads into context upfront — with a large server, that's tens of thousands of tokens before the LLM reads a single word of the user's request. And every tool call is a round-trip: the LLM calls a tool, the result flows back through the context window, the LLM reasons about it, calls another tool, and so on. Intermediate results that only exist to feed the next step still burn tokens every time.
CodeMode is an experimental transform that solves both. Instead of seeing your tool catalog directly, the LLM gets meta-tools: it searches for relevant tools on demand (using BM25), inspects their schemas, then writes Python that chains call_tool() calls in a sandbox and returns a final answer. Discovery is staged and targeted; intermediate results never touch the model's context window.
:::python
from fastmcp import FastMCP
from fastmcp.experimental.transforms.code_mode import CodeMode
mcp = FastMCP("Server", transforms=[CodeMode()])
Your existing tools don't change — CodeMode wraps them. The default three-stage flow (search → get schemas → execute) is configurable: collapse it to two stages for smaller catalogs, skip discovery entirely for tiny ones. The sandbox supports resource limits on time, memory, and recursion depth.
Read the docs here.
Search Transforms
Code Mode's discovery layer is also available as a standalone transform. SearchTools adds BM25 text search to any server — clients can query against tool names and descriptions and receive ranked results, without needing to know tool names upfront. This is useful anywhere the tool catalog is large, dynamic, or not known in advance.
Prefab Apps
3.1 adds early integration with Prefab, a frontend framework with a Python DSL that compiles to React. The vision: Python developers building MCP servers shouldn't have to leave Python to ship a proper UI. Prefab is still under very active development (their words: "probably shouldn't use it yet"), but the integration is here, the pieces are aligning, and 3.2 is where this gets interesting.
Auth Additions
MultiAuth lets you compose multiple token verification sources into a single auth layer — useful when you need to accept tokens from more than one provider (e.g., internal JWTs alongside a third-party OAuth provider). This release also adds out-of-the-box support for PropelAuth and a Google GenAI sampling handler.
Under the Hood
Heavy imports are now lazy-loaded, meaningfully reducing startup time for servers that don't use every feature. fastmcp run and dev inspector gain a -m/--module flag for module-style invocation, MCPConfigTransport now correctly persists sessions across tool calls, and search_result_serializer gives you a hook to customize how search results are serialized for markdown output. Eight new contributors, and the usual round of fixes.
What's Changed
New Features 🎉
- feat: Search transforms for tool discovery by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3154
- Add experimental CodeMode transform by @aaazzam in https://github.com/PrefectHQ/fastmcp/pull/3297
- Add Prefab Apps integration for MCP tool UIs by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3316
Enhancements 🔧
- Lazy-load heavy imports to reduce import time by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3295
- Add http_client parameter to all token verifiers for connection pooling by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3300
- Add in-memory caching for token introspection results by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3298
- Add SessionStart hook to install gh CLI in cloud sessions by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3308
- Fix ty 0.0.19 type errors by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3310
- Code Mode: Add resource limits to MontySandboxProvider by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3326
- Accept transforms as FastMCP init kwarg by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3324
- Split large test files to comply with loq line limit by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3328
- Add -m/--module flag to
fastmcp runanddev inspectorby @dgenio in https://github.com/PrefectHQ/fastmcp/pull/3331 - Add search_result_serializer hook and serialize_tools_for_output_markdown by @MagnusS0 in https://github.com/PrefectHQ/fastmcp/pull/3337
- Add MultiAuth for composing multiple token verification sources by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3335
- Adds PropelAuth as an AuthProvider by @andrew-propelauth in https://github.com/PrefectHQ/fastmcp/pull/3358
- Replace vendored DI with uncalled-for by @chrisguidry in https://github.com/PrefectHQ/fastmcp/pull/3301
- Decompose CodeMode into composable discovery tools by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3354
- feat(contrib): auto-sync MCPMixin decorators with from_function signatures by @AnkeshThakur in https://github.com/PrefectHQ/fastmcp/pull/3323
- Add Google GenAI Sampling Handler by @strawgate in https://github.com/PrefectHQ/fastmcp/pull/2977
- Add ListTools, search limit, and catalog size annotation to CodeMode by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3359
- Allow configuring FastMCP transport setting in the same way as other configuration by @jvdmr in https://github.com/PrefectHQ/fastmcp/pull/1796
- Add include_unversioned option to VersionFilter by @yangbaechu in https://github.com/PrefectHQ/fastmcp/pull/3349
Fixes 🐞
- Fix docs banner pushing nav down by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3282
- fix: Replace hardcoded TTL with DEFAULT_TTL_MS - issue [#3279] by @cedric57 in https://github.com/PrefectHQ/fastmcp/pull/3280
- fix: stop suppressing server stderr in fastmcp call by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3283
- fix: skip max_completion_tokens when maxTokens is None by @eon01 in https://github.com/PrefectHQ/fastmcp/pull/3284
- OpenAPI: rewrite $ref under propertyNames and patternProperties in _replace_ref_with_defs; add regression test for dict[StrEnum, Model] by @manojPal23234 in https://github.com/PrefectHQ/fastmcp/pull/3306
- Remove stale add_resource() key parameter from docs by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3309
- Handle AuthorizationError as exclusion in AuthMiddleware list hooks by @yangbaechu in https://github.com/PrefectHQ/fastmcp/pull/3338
- Fix flaky OpenAPI performance test threshold by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3355
- Fix flaky SSE timeout test by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3343
- Remove system role references from docs by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3356
- Fix session persistence across tool calls in multi-server MCPConfigTransport by @jer805 in https://github.com/PrefectHQ/fastmcp/pull/3330
Docs 📚
- Add v3.0.2 release notes by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3276
- Fix "FastMCP Constructor Parameters" in documentation server.mdx (Remove old parameters & Add new parameter) by @wangyy04 in https://github.com/PrefectHQ/fastmcp/pull/3317
- Fix stale docs: tag filtering API and missing output_schema param by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3322
- Narrate search example clients by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3321
- Code Mode: Document resource limits and fix docs formatting by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3327
- Add reverse proxy (nginx) section to HTTP deployment docs by @dgenio in https://github.com/PrefectHQ/fastmcp/pull/3344
- Restructure docs navigation: CLI section, Composition, More by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3361
Other Changes 🦾
- Don't advertise sampling.tools capability by default by @jlowin in https://github.com/PrefectHQ/fastmcp/pull/3334
New Contributors
- @cedric57 made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3280
- @eon01 made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3284
- @manojPal23234 made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3306
- @wangyy04 made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3317
- @yangbaechu made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3338
- @andrew-propelauth made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3358
- @jer805 made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/3330
- @jvdmr made their first contribution in https://github.com/PrefectHQ/fastmcp/pull/1796
Full Changelog: https://github.com/PrefectHQ/fastmcp/compare/v3.0.2...v3.1.0