fastmcp/tests
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
..
cli fix: validate server names in install commands (#3522) 2026-03-15 14:54:24 -04:00
client fix: remove forced follow_redirects from httpx_client_factory calls (#3496) 2026-03-15 11:30:41 -04:00
contrib Block recursive self-invocation in BulkToolCaller (#3433) 2026-03-07 11:41:15 -05:00
deprecated perf: reduce PBKDF2 iterations in tests, fix warnings and timeouts (#3504) 2026-03-14 16:42:06 -04:00
experimental Remove stale catalog cache from CodeMode execute 2026-03-03 16:49:50 -05:00
fs fix: add version to components (#3458) 2026-03-13 17:33:50 -04:00
integration_tests Update repository references for transfer to prefecthq (#3207) 2026-02-18 10:33:56 -05:00
prompts Support ImageContent and AudioContent in Message class 2026-03-06 17:12:29 -05:00
resources fix: handle re.error from malformed URI templates in build_regex (#3501) 2026-03-14 16:34:06 -04:00
server fix: route ResourcesAsTools/PromptsAsTools through server middleware (#3495) 2026-03-15 16:35:54 -04:00
telemetry Use standard traceparent/tracestate keys per OTel MCP semconv (#3221) 2026-02-18 15:51:24 -05:00
tools fix: use raw strings for regex in pytest.raises match (#3523) 2026-03-15 15:14:15 -04:00
utilities fix: prevent path traversal in skill download (#3493) 2026-03-15 11:22:13 -04:00
__init__.py Update type handling for resources 2024-11-29 19:42:46 -05:00
conftest.py Expose minimum_check_interval, reduce task pickup latency (#3500) 2026-03-14 16:08:28 -04:00
test_apps.py Rename ui= to app= and consolidate ToolUI/ResourceUI into AppConfig (#3117) 2026-02-08 20:26:47 -05:00
test_apps_prefab.py Add Prefab Apps integration for MCP tool UIs (#3316) 2026-02-27 14:37:57 -05:00
test_fastmcp_app.py Add FastMCPApp — a Provider for composable MCP applications (#3385) 2026-03-09 13:46:14 -04:00
test_json_schema_generation.py fix: use SkipJsonSchema to exclude callable fields from JSON schema generation (#3048) 2026-02-01 21:30:48 -05:00
test_mcp_config.py perf: reduce PBKDF2 iterations in tests, fix warnings and timeouts (#3504) 2026-03-14 16:42:06 -04:00