Commit graph

3,289 commits

Author SHA1 Message Date
Georgios Roros
ee6f469aa5 Fix flaky timing test on Windows CI
Increase performance test threshold from 100ms to 1.0s. Windows CI runners
are slower than Linux, and the 100ms threshold was too tight. The test's
intent is to catch obvious regressions (e.g., accidentally re-introducing
code generation), not to precisely benchmark.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-02 13:28:28 -05:00
Jeremiah Lowin
33a69d7d0a
Add MultiAuth for composing multiple token verification sources (#3335)
* Add MultiAuth for composing multiple token verification sources

🤖 Generated with Claude Code

https://claude.ai/code/session_01WwKYDCqjM2FqYwY5ZNVvjb

* Fix ruff lint/format in MultiAuth tests

🤖 Generated with Claude Code

https://claude.ai/code/session_01WwKYDCqjM2FqYwY5ZNVvjb

* Fix MultiAuth well-known route delegation and empty scopes handling

🤖 Generated with Claude Code

https://claude.ai/code/session_01WwKYDCqjM2FqYwY5ZNVvjb

* Harden MultiAuth: exception resilience, mcp_path propagation, test coverage

- verify_token now catches exceptions from individual sources and
  continues to the next, so one broken verifier can't take down the
  whole chain
- set_mcp_path propagates to verifiers, not just the server
- Fix jwks_url→jwks_uri typo in class docstring
- Add tests for raising verifiers, valid-token HTTP acceptance,
  and set_mcp_path propagation

* Clean up MultiAuth: precompute sources, deduplicate test helpers

* Fix version badges to 3.1.0

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-02 12:09:22 -05:00
Magnus
1e72f2457b
Add search_result_serializer hook and serialize_tools_for_output_markdown (#3337) 2026-03-01 14:20:24 -05:00
dgenio
9d635bc026 Address maintainer review: reload support, type annotation, test imports 2026-03-01 13:29:54 -05:00
dgenio
52144ce20b Apply ruff formatting to test file 2026-03-01 13:29:54 -05:00
dgenio
2b28cd2a88 Add integration tests for module mode in run and inspector 2026-03-01 13:29:54 -05:00
dgenio
d35ce8dd2e Fix module mode docstring example order 2026-03-01 13:29:54 -05:00
dgenio
173b93a4c3 Use bare python for module mode when uv wraps the command 2026-03-01 13:29:54 -05:00
dgenio
f14f7783df Skip load_server() in inspector when --module is active 2026-03-01 13:29:54 -05:00
dgenio
7a582ff5a0 Add -m/--module flag to fastmcp run and dev inspector 2026-03-01 13:29:54 -05:00
Yang Geonhee
d7674b3c0c Handle AuthorizationError as exclusion in AuthMiddleware list hooks 2026-03-01 13:23:02 -05:00
Jeremiah Lowin
610551c7b6
Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
Claude
7690e995b8 Add tests for default sampling capability (issue #3329)
🤖 Generated with Claude Code

https://claude.ai/code/session_01BsxYNsUhJPx14QiJ4FHqx6
2026-02-28 11:06:21 -05:00
Claude
7a92b82097 Don't advertise sampling.tools capability by default
🤖 Generated with Claude Code

https://claude.ai/code/session_01BsxYNsUhJPx14QiJ4FHqx6
2026-02-28 11:06:21 -05:00
Jeremiah Lowin
72129c3d03 Fix symlink note in CLAUDE.md 2026-02-27 21:38:07 -05:00
Jeremiah Lowin
0afd990ee6 Improve code-mode docs formatting; add docs formatting guideline 2026-02-27 21:38:07 -05:00
Jeremiah Lowin
75d6e2fc10 Document resource limits for MontySandboxProvider 2026-02-27 21:38:07 -05:00
Jeremiah Lowin
18d5902367 Document transforms kwarg in server constructor reference 2026-02-27 21:28:34 -05:00
Jeremiah Lowin
14e64b3b22 Use transforms= kwarg in docs examples 2026-02-27 21:28:34 -05:00
Jeremiah Lowin
09a99e1ecc Accept transforms as FastMCP init kwarg 2026-02-27 21:28:34 -05:00
Jeremiah Lowin
b01e66dc58 Add resource limits to MontySandboxProvider 2026-02-27 21:24:56 -05:00
Jeremiah Lowin
3ff1472ea9
Add Prefab Apps integration for MCP tool UIs (#3316)
* Add prefab auto-wiring for MCP Apps (#3119)

Tools that return prefab types (UIResponse, Component) automatically get
wired to the shared prefab renderer resource. Works via app=True,
return type inference, or both.

* Prefab compatibility updates

* Use published prefab-ui >=0.6.0, remove local source override

* Migrate UIResponse to PrefabApp for Prefab UI integration

PrefabApp is a pure data object with to_json(), html(), and csp()
methods. Tools can return PrefabApp, bare Components, or
ToolResult with structured_content for custom LLM fallback text.

* Add Prefab UI apps documentation

* Add mini apps and full apps documentation pages

Mini apps covers the common single-screen patterns: charts (bar, line,
area, pie), data tables with sorting/search/pagination, forms (manual
and Pydantic-generated), status displays, conditional content, and
layout composition with tabs and accordions.

Full apps covers multi-page applications using Pages/Page components,
shared state across pages, and using ToolCall with result_key for
server-driven state updates.

* Reframe apps docs around motivation, add generative UIs page

The docs now lead with the problem — MCP tools stuff data into the LLM
context window, and building HTML/JS/CSS frontends is a non-starter for
Python developers — before introducing Prefab as the solution. Mini apps
are framed as the primary use case: focused, single-purpose UIs that
present data visually and collect structured input.

New generative UIs page covers the concept of LLMs producing component
JSON directly, enabling adaptive dashboards, tailored forms, and
exploratory workflows.

* Tag Prefab docs pages as SOON instead of NEW

* Rename Low-Level API to Custom HTML Apps

The page is about using the MCP Apps extension directly, not a FastMCP
or Prefab internal API. Reframed to make clear this is the open MCP
protocol with FastMCP providing convenience wrappers.

* Tighten apps docs and widen content area

Strip editorial motivation from all app doc pages — let code examples
do the talking. Add content-area max-width override (44rem) to style.css.

* Restructure apps docs, fix code issues

Rename Prefab UI → Prefab Apps, mini-apps → patterns, remove
generative-uis and full-apps pages. Rewrite prefab page to lead with
what users do (declare a UI, return it) before explaining internals.
Patterns page now has fully self-contained copy-pasteable examples with
explicit imports and links to prefab docs. Forms show the two-tool
pattern (form + handler). Add patterns_server.py example.

Code fixes: move get_args to module-level import, remove dead
AuthCheckCallable type alias, fix ToolCall→CallTool in all docs.

* Remove unused ToolResult import from chart_server

* Handle composite Prefab types in type inference and schema suppression

_has_prefab_return_type and the output schema suppression logic only
checked bare classes, missing unions (Column | None) and Annotated
wrappers (Annotated[PrefabApp | None, ...]). Recurse through Union,
types.UnionType, and Annotated to detect Prefab types in composite
annotations.
2026-02-27 14:37:57 -05:00
Jeremiah Lowin
2d1fe3ec0f
Narrate search example clients (#3321)
* Narrate search example clients for screenshot-readability

* Show actual call_tool invocation in result panels
2026-02-27 12:17:31 -05:00
Adam Azzam
b9153404f4
Add experimental CodeMode transform (#3297)
* code mode

* update uv.lock for monty optional dep

🤖 Generated with Claude Code

* retry CI

* Address PR review comments on CodeMode transform

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix ty unresolved-attribute error on search_helper

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* more idiomacy

* harden

* fix docs

* harden

* fix red CI

* Refactor CodeMode to use CatalogTransform base class

Removes the duplicate ContextVar bypass pattern in favor of the shared
CatalogTransform machinery. Also fixes a pre-existing bug where
`from __future__ import annotations` caused NameError for Annotated
in nested function scopes at runtime.

* Remove redundant _get_visible_tools wrapper in CodeMode

* Rewrite CodeMode docs with proper motivation and structure

* Fix type narrowing in collision test

* Stop unwrapping tool results in CodeMode's call_tool

call_tool() inside execute blocks now returns structured content as-is,
preserving the {"result": value} wrapping. This means the output schema
shown in search results accurately describes what call_tool() returns,
so LLMs can trust the schema when writing code.

Also adds examples/code_mode/ with a server and narrated client demo.

* Simplify call_tool return type: dict | str

* Fix example client to unwrap structured results

* Let server resolve tool versions instead of pinning first match

* Rewrite CodeMode docs to match current behavior

* Rename optional extra from monty to code-mode

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-02-27 12:14:03 -05:00
Jeremiah Lowin
3438b77e88 Fix stale docs: update tag filtering API and add output_schema ParamField 2026-02-27 12:10:22 -05:00
Wang Yiyang
9344224452 Update docs/servers/server.mdx(Fix "FastMCP Constructor Parameters")
Fix description of "FastMCP Constructor Parameters": Remove parameters `on_duplicate_tools`, `on_duplicate_resources` and `on_duplicate_prompts`, which are no longer accepted by FastMCP(). Add the new parameter `on_duplicate` and its description.
2026-02-27 11:52:00 -05:00
Jeremiah Lowin
c96c0400f3
feat: Search transforms for tool discovery (#3154)
* feat: Add search transforms for tool discovery

RegexSearchTransform and BM25SearchTransform collapse large tool
catalogs into a search interface so LLMs discover tools on demand
instead of receiving the full listing.

* chore: Update SDK documentation

* fix: call_tool recursion guard, atomic BM25 rebuild, hash includes descriptions

* Extract CatalogTransform base class for catalog-aware transforms

Transforms that replace list_tools() with synthetic components (like
search) need to read the real catalog at call time without triggering
their own replacement logic. CatalogTransform handles the re-entrant
bypass via per-instance ContextVar, exposing transform_tools() as the
subclass hook and get_tool_catalog() for catalog access.

* Add search transform examples for regex and BM25

* Add README for search transform examples

* Polish search example clients with rich output

* Remove hardcoded tool counts from search example subtitles

* Clarify that review bot feedback should be evaluated on its merits

* Expand search transform docs with proper hierarchy

---------

Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-02-26 22:42:38 -05:00
Jeremiah Lowin
c349bd9e25
Remove stale add_resource() key parameter from docs (#3309)
The `key` parameter was removed from `add_resource()` in the 2.x era and no longer exists in the implementation. Removes all references and the "Custom Resource Keys" section from both the current and v2 docs.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nc1qEJ1rKaRRxB5h6Qu5V3

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-26 16:10:02 -05:00
manojPal23234
507e6b80ab
OpenAPI: rewrite $ref under propertyNames and patternProperties in _replace_ref_with_defs; add regression test for dict[StrEnum, Model] (#3306)
* Normalize OpenAPI $ref everywhere (incl. propertyNames); migrate components→$defs; add regression test

* Fix: normalize $ref in propertyNames and additionalProperties; add regression test

* Deterministic migration: components.schemas override $defs on collision; preserve direct $defs refs via alias; add collision test

* Fix: rewrite $ref in propertyNames and patternProperties in _replace_ref_with_defs

* Fix syntax error, formatting, and stray files

* Skip boolean subschemas in patternProperties

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-02-26 16:08:54 -05:00
Jeremiah Lowin
2d3d0d5eab
Fix ty 0.0.19 type errors (#3310)
* Fix ty 0.0.19 type errors

🤖 Generated with Claude Code

* Fix ruff formatting in sampling/run.py

🤖 Generated with Claude Code

https://claude.ai/code/session_01GWzbyF1vHvVeS4yJ5bhScf

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-26 16:08:40 -05:00
marvin-context-protocol[bot]
80efbd3d57
chore: Update SDK documentation (#3273)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-02-26 11:19:53 -05:00
Jeremiah Lowin
43ac5395b9
Add SessionStart hook to install gh CLI in cloud sessions (#3308)
Co-authored-by: Marvin Context Protocol <41898282+Marvin Context Protocol@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2026-02-26 11:12:23 -05:00
Jeremiah Lowin
8a4c9b33e1
Add in-memory caching for token introspection results (#3298) 2026-02-26 10:43:40 -05:00
Claude
892e1731f7 Allow http_client with static public_key in JWTVerifier
🤖 Generated with Claude Code

https://claude.ai/code/session_012QKWmKd21vypDmxWbwuE4e
2026-02-25 16:41:24 -05:00
Claude
730175910c Raise error when http_client and ssrf_safe=True are both provided
🤖 Generated with Claude Code

https://claude.ai/code/session_012QKWmKd21vypDmxWbwuE4e
2026-02-25 16:41:24 -05:00
Claude
1704ffe88f Add http_client parameter to token verifiers for connection pooling
🤖 Generated with Claude Code

https://claude.ai/code/session_012QKWmKd21vypDmxWbwuE4e
2026-02-25 16:41:24 -05:00
Jeremiah Lowin
d773079aba Lazily expose server.dependencies instead of dropping it 2026-02-25 16:27:51 -05:00
Jeremiah Lowin
d9541c9c21 Lazy-load heavy imports to reduce import time
Defer auth providers (JWTVerifier, OAuthProxy, OIDCProxy) and Client
to avoid eagerly importing authlib, cryptography, key_value.aio, and
beartype on every `from fastmcp import FastMCP`.
2026-02-25 16:27:51 -05:00
Jeremiah Lowin
270783e614
reverse CLAUDE.md/AGENTS.md symlink direction (#3294) 2026-02-25 11:18:59 -05:00
Jeremiah Lowin
59bb0a3ce7
Fix link to loq repository in AGENTS.md (#3289) 2026-02-24 19:45:56 -05:00
Aymen El Amri
549f48bc7a
fix: skip max_completion_tokens when maxTokens is None (#3284) 2026-02-24 14:04:03 -05:00
Jeremiah Lowin
e87ede075c
fix: stop suppressing server stderr in fastmcp call (#3283)
Server subprocess stderr was being sent to /dev/null, which silently
discarded print(..., file=sys.stderr) and logging output from tools.
2026-02-23 15:07:31 -05:00
Cedric
5815e1eff8
fix: Replace hardcoded TTL with DEFAULT_TTL_MS - issue #3279 (#3280) 2026-02-23 12:05:22 -05:00
Jeremiah Lowin
37126d6d3f
fix: remove position override from docs banner CSS (#3282) 2026-02-23 11:26:48 -05:00
Jeremiah Lowin
e19f2396b3
Add v3.0.2 release notes (#3276) 2026-02-22 11:41:37 -05:00
Manrique Vargas
c71840631e
docs: add context-aware tool factory example (#3264) v3.0.2
Fixes PrefectHQ/fastmcp#1841

Signed-off-by: machov <mv1742@nyu.edu>
2026-02-22 11:24:22 -05:00
Guillaume FORTAINE
40d3190317
fix: propagate origin_request_id to background task workers (#3175)
* Fix background Context request correlation

* Make OptionalCurrentContext type-safe

Refactor OptionalCurrentContext to wrap CurrentContext instead of overriding __aenter__ with a wider return type. Adds a background-task origin_request_id round-trip test and applies ruff formatting.
2026-02-22 11:16:30 -05:00
Jeremiah Lowin
d85cfb84e1
Revert to long-lived PR approach for auto-generated docs/schema (#3272)
🤖 Generated with Claude Code

https://claude.ai/code/session_01LUn4EnV6nZS5UgFz9wtyB3

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-22 11:13:06 -05:00
Bill Easton
83d6254757
Allow Marvin to open PRs on comment (#3267)
* Update marvin-comment-on-issue.yml

* remove conflicting instructions
2026-02-21 15:07:27 -06:00
不做了睡大觉
0d4580fef3
fix: prevent MCP transport auth header from leaking to downstream OpenAPI APIs (#3260) (#3262)
* fix: prevent MCP transport auth header from leaking to downstream OpenAPI APIs (#3260)

Two issues in OpenAPITool.run():

1. get_http_headers() does not exclude 'authorization', so the MCP
   client's auth token is included in forwarded headers.

2. mcp_headers.update() overwrites existing request headers, including
   the Authorization header that was already set from the httpx client's
   configured API key.

Fix:
- Add 'authorization' to exclude_headers in get_http_headers() to
  prevent MCP transport credentials from being forwarded by default.
- Change mcp_headers forwarding to use the same non-overwriting pattern
  as client headers (only set if key not already present), making the
  behavior consistent and preventing accidental overwrites.

Fixes #3260

* Add include parameter to get_http_headers(); update proxy transports

The authorization exclusion is correct for the default case (OpenAPI
tools should not forward MCP transport credentials), but proxy
transports need auth headers forwarded to upstream MCP servers.

The new `include` parameter lets callers opt specific headers back in
despite the default exclusion set. Proxy transports now explicitly
request authorization forwarding.

* Include authorization header in CurrentHeaders dependency

CurrentHeaders is user-facing — tools use it to inspect the caller's
auth token for custom logic. Reading a header in your own code is safe;
the exclusion is meant to prevent blindly forwarding it to third-party
APIs.

---------

Co-authored-by: User <user@example.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-02-21 09:23:27 -05:00