fastmcp/tests/server
Jeremiah Lowin b07f9ce9ae
Honor OAuth application_type in DCR (SEP-837) (#4621)
* Honor OAuth application_type in DCR (SEP-837)

* Simplify web redirect check per ruff SIM103

* Enforce application_type over HTTP, at auth time, and tighten native scheme rules

Recover the DCR application_type the SDK RegistrationHandler drops (P1), enforce the stored type on the authorization redirect path (P2), restrict native to loopback http + custom schemes (P2), and document the web/native rules (P2).

* Fix loopback range detection and use a positive scheme allowlist

Classify loopback hosts with ipaddress.is_loopback so all of 127.0.0.0/8 counts (a web client could bypass the non-loopback rule with 127.0.0.2). Replace the NON_REDIRECT_NETWORK_SCHEMES denylist with STANDARD_URI_SCHEMES: native now accepts only https, loopback http, and unregistered private-use schemes per RFC 8252, so smb/smtp/nfs and other unlisted standard schemes no longer pass.

* Vendor the IANA scheme registry and consolidate the loopback classifier

Replace the hand-picked STANDARD_URI_SCHEMES with a vendored snapshot of the IANA URI scheme registry (423 schemes), so registered transports nobody enumerated (coap, coaps, stun, turn, mqtt) fail closed instead of passing as private-use. Delete the stale duplicate _is_loopback_host in oauth_proxy/models.py and reuse the ipaddress-based classifier from redirect_validation, restoring loopback port flexibility across all of 127.0.0.0/8.

* Treat the reserved localhost namespace and absolute host forms as loopback

RFC 6761 6.3 reserves the whole localhost namespace for the local machine, so app.localhost and localhost. are loopback just as much as localhost. Previously a web client could register https://app.localhost/callback and bypass the non-loopback rule, while native clients were wrongly refused legitimate http://app.localhost:3000 dev callbacks. The suffix test is anchored on a leading dot so localhost.evil.com and notlocalhost stay non-loopback.

* Narrow scope: drop native scheme classification, keep the web rule

Registry membership cannot separate app-dispatch schemes from network transports (vscode is registered because it is an app scheme), so classifying a native client's scheme rejected callbacks that real MCP clients need. Remove the vendored registry and the private-use test; native now accepts any scheme outside the unsafe set, with cleartext http still limited to loopback. Also reject web registrations that omit redirect_uris rather than storing an unusable localhost placeholder.
2026-07-26 14:24:50 -04:00
..
auth Honor OAuth application_type in DCR (SEP-837) (#4621) 2026-07-26 14:24:50 -04:00
http Support routable transport headers for gateways (SEP-2243) (#4622) 2026-07-26 13:40:09 -04:00
middleware Move task subsystem to fastmcp-tasks package, disconnect SEP-1686 wire from core 2026-07-21 21:51:45 -04:00
mount Implement SEP-2663 tasks extension: TasksExtension, poll-based task lifecycle 2026-07-21 23:00:38 -04:00
providers Support routable transport headers for gateways (SEP-2243) (#4622) 2026-07-26 13:40:09 -04:00
sampling Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
telemetry Audit mode="legacy" pins in server tests and top-level stragglers 2026-07-20 16:00:27 -04:00
transforms Audit mode="legacy" pins in server tests and top-level stragglers 2026-07-20 16:00:27 -04:00
versioning Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
test_app_state.py Update docs and test 2025-06-20 13:06:48 -04:00
test_auth_integration.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_auth_integration_errors.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_cache_hints.py Add server-level cache hints (SEP-2549) (#4464) 2026-07-08 09:10:41 -04:00
test_completions.py Let a server answer argument-completion requests (#4582) 2026-07-21 12:26:24 -04:00
test_context.py Make the unit suite fast: in-process HTTP tests, no real sleeps, parallel Windows CI (#4554) 2026-07-20 10:51:14 -04:00
test_dependencies.py Implement SEP-2663 tasks extension: TasksExtension, poll-based task lifecycle 2026-07-21 23:00:38 -04:00
test_dependencies_advanced.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_event_store.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_extensions.py Implement SEP-2663 tasks extension: TasksExtension, poll-based task lifecycle 2026-07-21 23:00:38 -04:00
test_fastapi_testclient_compat.py fix: FastAPI TestClient compatibility and lifespan re-initialization (#3736) 2026-04-06 19:53:27 -04:00
test_file_server.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_icons.py Audit mode="legacy" pins in server tests and top-level stragglers 2026-07-20 16:00:27 -04:00
test_input_validation.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_log_level.py Allow pre-bound HTTP sockets (#4222) 2026-05-23 10:08:49 -04:00
test_logging.py Refactor server.py into mixins (#2939) 2026-01-19 11:36:00 -05:00
test_mrtr_guards.py Rebuild guard tasks as end-and-reenter; remove imperative in-task elicit 2026-07-22 12:38:46 -04:00
test_pagination.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_protocol_eras.py Move task subsystem to fastmcp-tasks package, disconnect SEP-1686 wire from core 2026-07-21 21:51:45 -04:00
test_providers.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_server.py Repoint tests and examples off removed deprecations 2026-07-07 07:53:11 -04:00
test_server_docket.py Implement SEP-2663 tasks extension: TasksExtension, poll-based task lifecycle 2026-07-21 23:00:38 -04:00
test_server_lifespan.py Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
test_server_safety.py fix: reject self-mount to prevent infinite recursion (#3925) 2026-04-14 12:10:19 -04:00
test_session_provider.py Add stateless session state (UserSession / SessionId) (#4604) 2026-07-23 19:21:00 -04:00
test_session_visibility.py Audit mode="legacy" pins in server tests and top-level stragglers 2026-07-20 16:00:27 -04:00
test_sessions.py Add stateless session state (UserSession / SessionId) (#4604) 2026-07-23 19:21:00 -04:00
test_streamable_http_no_redirect.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_tool_annotations.py Implement SEP-2663 tasks extension: TasksExtension, poll-based task lifecycle 2026-07-21 23:00:38 -04:00
test_tool_transformation.py Migrate to MCP SDK v2.0.0b2 (httpx2) (#4503) 2026-07-18 15:12:47 -04:00
test_transport.py Forward-port HTTP host guard compatibility (#4474) 2026-07-08 20:55:56 -04:00