fastmcp/tests
Jeremiah Lowin 562e51b378
Improve OAuth error messages with custom handlers and middleware (#2221)
* Enhance OAuth Proxy error responses with branded HTML pages

OAuth Proxy authentication errors now show styled HTML error pages in browsers
instead of raw JSON, with content negotiation for API clients. Enhanced error
messages explain common causes (ephemeral storage, server restarts) and provide
clear remediation steps.

Changes:
- Created enhanced authorization handler that extends SDK's AuthorizationHandler
- Created enhanced auth middleware that extends SDK's RequireAuthMiddleware
- HTML error pages use server branding (icon, name) from FastMCP instance
- Added comprehensive troubleshooting section to OAuth Proxy docs
- Added FAQ entry linking to detailed troubleshooting

* Add comprehensive tests for enhanced OAuth error responses

Tests cover:
- HTML error pages for browser requests with server branding
- Enhanced JSON responses with registration endpoint hints
- Content negotiation between HTML and JSON
- Enhanced middleware error messages for invalid_token
- WWW-Authenticate header format consistency with SDK

* Update language for new storage defaults

* update docs

* Update tests for simplified error messages

* Clean up messages
2025-10-22 21:29:14 -04:00
..
cli Replace subprocess tests with in-process async servers (#2006) 2025-10-19 10:47:54 -04:00
client Replace subprocess tests with in-process async servers (#2006) 2025-10-19 10:47:54 -04:00
contrib feat: Add title, annotations and meta to mixin decorators 2025-10-10 14:23:02 +05:30
deprecated feat: introduce fastmcp.json configuration system (#1517) 2025-08-19 16:06:04 -04:00
experimental Replace subprocess tests with in-process async servers (#2006) 2025-10-19 10:47:54 -04:00
integration_tests Replace subprocess tests with in-process async servers (#2006) 2025-10-19 10:47:54 -04:00
prompts Enable more type checking rules (#1775) 2025-09-07 11:11:44 -04:00
resources Allow direct instantiation of Prompt and Resource classes (#2031) 2025-10-08 21:06:41 -04:00
server Improve OAuth error messages with custom handlers and middleware (#2221) 2025-10-22 21:29:14 -04:00
tools Add Pydantic-compatible input validation (#2073) 2025-10-14 11:49:30 -07:00
utilities Implement icon support (#2121) 2025-10-17 17:28:08 -04:00
__init__.py Update type handling for resources 2024-11-29 19:42:46 -05:00
conftest.py Add platform-aware OAuth token persistence (#2218) 2025-10-22 20:42:24 -04:00
test_examples.py Cleanup content conversion 2025-09-06 17:32:33 -05:00
test_mcp_config.py optimize test suite (#1893) 2025-09-22 20:07:04 -04:00