fastmcp/docs/servers
Jeremiah Lowin f9ed06176a
fix: route ResourcesAsTools/PromptsAsTools through server middleware (#3495)
* fix: enforce auth/visibility in ResourcesAsTools and PromptsAsTools for non-FastMCP providers

🤖 Co-authored-by: Claude <noreply@anthropic.com>

* fix: honor stdio auth bypass and correct transform ordering in provider wrappers

Co-authored-by: Claude <noreply@anthropic.com>

* fix: move context/dependencies imports into function to break circular import

* fix: route ResourcesAsTools/PromptsAsTools through ctx.fastmcp

Instead of manually reimplementing auth, visibility, and session
transforms in the transform layer, tool functions now call
ctx.fastmcp.read_resource() / ctx.fastmcp.render_prompt() which
routes through the server's full middleware chain. This matches
the pattern CodeMode uses with ctx.fastmcp.call_tool().

The isinstance(provider, FastMCP) branching is removed entirely.

* feat: add _scope parameter for provider-scoped listing

AggregateProvider can now filter which child providers to query when
listing components. ResourcesAsTools and PromptsAsTools use this to
scope listings to their configured provider while still routing
through ctx.fastmcp for full middleware coverage.

The scope matching walks wrapped providers, so a
WrappedProvider(Namespace, inner=MyProvider) matches if MyProvider
is in the scope list.

* test: add coverage for ResourcesAsTools scoped to a sub-server

* fix: delegate to super() when _scope is None, add AggregateProvider to scope matching

* simplify: remove _scope machinery, route everything through ctx.fastmcp

Reverts the _scope parameter from Provider/AggregateProvider/Server.
ResourcesAsTools and PromptsAsTools now simply route through
ctx.fastmcp for all operations. Apply to a FastMCP server instance
for proper auth/visibility/middleware coverage.

Tests rewritten to use FastMCP server directly instead of raw providers.

* warn when ResourcesAsTools/PromptsAsTools is applied to a non-FastMCP provider

* docs: explain that ResourcesAsTools/PromptsAsTools should wrap a FastMCP server

* raise TypeError instead of warning when applied to non-FastMCP provider

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-15 16:35:54 -04:00
..
auth feat: make upstream_client_secret optional in OAuthProxy (#3486) 2026-03-15 11:14:56 -04:00
providers Cache component lists in ProxyProvider (#3479) 2026-03-13 19:44:45 -04:00
transforms fix: route ResourcesAsTools/PromptsAsTools through server middleware (#3495) 2026-03-15 16:35:54 -04:00
authorization.mdx Support async auth checks (#3152) 2026-02-11 12:48:51 -05:00
composition.mdx Restructure docs navigation: CLI section, Composition, More (#3361) 2026-03-02 21:09:48 -05:00
context.mdx Support non-serializable values in Context.set_state (#3171) 2026-02-12 15:06:42 -06:00
dependency-injection.mdx Replace vendored DI with uncalled-for (#3301) 2026-03-02 16:35:15 -05:00
elicitation.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
icons.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
lifespan.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
logging.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
middleware.mdx Deprecate PromptToolMiddleware and ResourceToolMiddleware (#3389) 2026-03-06 17:17:01 -05:00
pagination.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
progress.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
prompts.mdx Fix broken documentation links (#2952) 2026-01-19 23:17:29 -05:00
resources.mdx Remove stale add_resource() key parameter from docs (#3309) 2026-02-26 16:10:02 -05:00
sampling.mdx Add concurrent tool execution with sequential flag (#3022) 2026-02-09 20:43:53 -05:00
server.mdx Support logging/setLevel and add client_log_level setting (#3491) 2026-03-14 10:36:01 -04:00
storage-backends.mdx Drop diskcache dependency (CVE-2025-69872) (#3185) 2026-02-16 16:43:15 -05:00
tasks.mdx Update docs for 3.0 GA release (#3216) 2026-02-18 14:29:28 -05:00
telemetry.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00
testing.mdx Restructure docs navigation: CLI section, Composition, More (#3361) 2026-03-02 21:09:48 -05:00
tools.mdx Fix stale docs: update tag filtering API and add output_schema ParamField 2026-02-27 12:10:22 -05:00
versioning.mdx Add include_unversioned option to VersionFilter (#3349) 2026-03-02 21:06:50 -05:00
visibility.mdx Restructure documentation for FastMCP 3.0 (#2951) 2026-01-19 21:33:35 -05:00