Commit graph

2,359 commits

Author SHA1 Message Date
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
Jeremiah Lowin
e3d1750412
Update CLI logo (#2220) 2025-10-22 21:29:04 -04:00
Jeremiah Lowin
686082a5b5
Add platform-aware OAuth token persistence (#2218)
* Add comprehensive keyring integration tests

Prevents OS keyring pollution during testing by adding a global mock in
conftest.py. Tests verify keyring behavior across platforms and fallback
scenarios without writing to the actual system keyring.

- Add global mock_keyring fixture to tests/conftest.py
- Add TestOAuthProxyKeyring class with 6 keyring-specific tests
- Remove try/except ImportError for keyring (now required dependency)
- Add keyring extra to py-key-value-aio dependency
- Clean up extraneous implementation comments in oauth_proxy.py

* Update OAuth keyring documentation

Update all OAuth-related documentation to reflect keyring-based key management:
- Add version badges to jwt_signing_key, token_encryption_key, and client_storage parameters
- Standardize "Default behavior (`None`):" formatting with backticks
- Ensure consistent messaging about development-only defaults across all docs
- Update oauth-proxy.mdx, oidc-proxy.mdx, http.mdx, storage-backends.mdx, and upgrade-guide.mdx
2025-10-22 20:42:24 -04:00
William Easton
df7a485869
Merge pull request #2217 from jlowin/claude/issue-2216-20251022-2311
Fix dead links to py-key-value repository
2025-10-22 19:09:35 -05:00
claude[bot]
f127e33bbe Fix dead links to py-key-value repository
Update documentation links from py-key-value-aio to py-key-value repository.
The py-key-value-aio package lives in the py-key-value monorepo.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-22 23:15:03 +00:00
Jeremiah Lowin
8099201979
Use platformdirs for settings.home (#2213)
Changes settings.home from `Path.home() / ".fastmcp"` to use platformdirs.user_data_dir(), following platform conventions (~/Library/Application Support on macOS, ~/.local/share on Linux, %APPDATA% on Windows).
2025-10-22 16:06:46 -04:00
nate nowack
72b9acd707
Merge pull request #2201 from jlowin/update-smart-home-example-again
Update smart home example again
2025-10-21 20:32:02 -05:00
zzstoatzz
2ff72476b1 example: allow any str for bridge IP 2025-10-21 20:25:43 -05:00
zzstoatzz
bfa8ec43c1 example: allow any str for bridge IP 2025-10-21 20:25:31 -05:00
nate nowack
62ed19fb68
Merge pull request #2200 from jlowin/update-smart-home-example
example: update server init usage
2025-10-21 19:39:43 -05:00
zzstoatzz
29b0330882 example: update server init usage 2025-10-21 19:34:08 -05:00
William Easton
ac62a06158
Merge pull request #2196 from jlowin/bump-kv-aio
Bump py-key-value-aio to 0.2.6
2025-10-21 13:24:22 -05:00
William Easton
c833fff63c
Bump to 0.2.6 2025-10-21 11:38:07 -05:00
marvin-context-protocol[bot]
811e516699
chore: Update SDK documentation (#2171)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-21 11:32:32 -04:00
Valay Dave
19e97454a0
bug fix in fastmcp install claude-code (#2165)
* bug fix in `fastmcp install claude-code`

Calling the CLI like below command doenst end up working: 

```
fastmcp install claude-code "$SERVER_FILE" \
    --python 3.12 \
    --env "DOCS_DIR=$DOCS_DIR" \
    --env "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" \
    --with fastmcp \
    --with anthropic \
    --with click
```

It errors out like: 

```
Failed to install 'foo-mcp' in Claude Code: Invalid environment variable format: foo-mcp, environment variables should be added as: -e KEY1=value1 
-e KEY2=value2
```

The fix was simply ensuring that the claude code mcp command gets mcp name directly.

* Apply suggestion from @jlowin

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-10-21 10:19:34 -04:00
Jeremiah Lowin
908d085533
Restore gray monospace styling for OAuth callback screen (#2173) 2025-10-21 10:02:50 -04:00
Jeremiah Lowin
4d609ce74b
Move sampling fallback handler docs to server section (#2163) 2025-10-21 10:02:11 -04:00
Lukas Innig
f27a6fcd7a
Update environment vars in uvx transport (#2169)
The UvxStdioTransport class is not adding extra environment variables - like e.g. the NpxStdioTransport already does
2025-10-21 10:01:50 -04:00
Jeremiah Lowin
9987a456a0
Allow authorization consent screen to be disabled (#2172)
* Add optional authorization consent screen for OAuth providers

Adds `require_authorization_consent` parameter (default True) to OAuthProxy and all providers. When disabled, authorization skips the consent screen for local development/testing. Logs security warning when disabled.

* Update warning message to use 'authorization consent screen'
2025-10-21 10:00:39 -04:00
Jeremiah Lowin
422374c7bc
Remove fonts which weren't rendering in all browsers (#2174) 2025-10-21 10:00:27 -04:00
Jeremiah Lowin
83d77257da
Redesign OAuth consent screen for better UX (#2170)
Implements a user-friendly consent screen design that reduces intimidation for non-technical users while maintaining security.
2025-10-21 09:38:39 -04:00
marvin-context-protocol[bot]
77ae1cf2b5
chore: Update SDK documentation (#2157)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-20 21:13:47 -04:00
Jeremiah Lowin
99d3037694
allow non write users for marvin flows (#2161) v2.13.0rc2 2025-10-20 21:07:05 -04:00
Jeremiah Lowin
3b1ea0a564
Change auth init log to debug (#2160) 2025-10-20 20:49:23 -04:00
Jeremiah Lowin
c4e3adeccc
Update CLI logo (#2159) 2025-10-20 20:49:14 -04:00
Jeremiah Lowin
7cecac5db0
Remove warning message in common scenario of all client redirect uri's permitted (#2156) 2025-10-20 19:17:26 -04:00
Jeremiah Lowin
254ff1a25d
Make CORS opt-in via middleware parameter (#2150) 2025-10-20 15:33:13 -04:00
Jeremiah Lowin
09e899a699
docs: Add AWS Cognito resource server requirement and CORS guidance (#2149) 2025-10-20 15:28:16 -04:00
hyeonjae
24e2b09d95
Update content type in advanced_tool function (#2147) 2025-10-20 08:43:35 -04:00
marvin-context-protocol[bot]
9529fadd15
chore: Update SDK documentation (#2141)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-19 20:33:47 -04:00
Jeremiah Lowin
7da3b831d6
Update changelog for 2.12.5 (#2146) 2025-10-19 20:33:35 -04:00
Jeremiah Lowin
e7cde97e5b
Docs (#2145)
* Update fonts + styling

* Update docs.json

* Update welcome.mdx
2025-10-19 20:26:08 -04:00
Jeremiah Lowin
4c7463d5ae
Fix google scope example (#2144) 2025-10-19 19:51:40 -04:00
Jeremiah Lowin
b362444ddf
Add storage backend documentation (#2137)
* Add storage backend documentation

* Add storage patterns documentation for wrapper caching strategies

- Add PassthroughCacheWrapper section for multi-tier caching
- Document TTL clamping strategy for optimized memory usage
- Add example for wrapping custom storage implementations
- Explain how to combine fast in-memory caches with persistent remote stores

* Update docs
2025-10-19 19:24:13 -04:00
Jeremiah Lowin
96aa150cf0
Progress replacing asyncio with anyio (#2143) v2.13.0rc1
* Replace asyncio.sleep() with anyio.sleep()

- Replace asyncio.sleep() in error_handling.py retry middleware
- Replace asyncio.sleep() in oauth.py callback shutdown
- Keep asyncio.TimeoutError check for Python 3.10 compatibility
- Add anyio import to error_handling.py

All core library sleep calls now use anyio primitives. Tests and
example code still use asyncio where appropriate.

* Replace OAuth asyncio.Future with anyio.Event pattern

- Create OAuthCallbackResult dataclass for result storage
- Replace Future with Event + result container pattern
- Update oauth_callback.py to use anyio.Event coordination
- Update auth/oauth.py callback_handler to use Event pattern
- Remove asyncio imports from OAuth flow

OAuth callback now uses anyio primitives for async coordination
instead of asyncio.Future.

* Remove asyncio fire-and-forget task hack from Context

- Remove _try_flush_notifications() method entirely
- Update _queue_*_list_changed() to only queue notifications
- Remove asyncio import from context.py
- Keep _flush_notifications() for deferred sending on context exit

Notifications now flush reliably on request completion (__aexit__)
instead of attempting immediate delivery with asyncio.create_task().
Slight delay is acceptable - all notifications are deduplicated and
sent when the MCP request handler completes.
2025-10-19 14:08:06 -04:00
Jeremiah Lowin
3321644ad3
Replace subprocess tests with in-process async servers (#2006)
* Use anyio as testing backend

* Remove asyncio markers

* Update streamable http tests

* Replace all subprocess tests

* Replace anyio task groups with asyncio context managers in tests

- Convert run_server_async from anyio task group pattern to asyncio.create_task with async context manager
- Remove task_group fixture from conftest
- Update all test fixtures to use async with run_server_async pattern
- Remove TaskGroup imports from all test files
- Tests now work with pytest-asyncio instead of pytest-anyio

* Update test_github_provider_integration.py
2025-10-19 10:47:54 -04:00
marvin-context-protocol[bot]
39aebcf578
chore: Update SDK documentation (#2129)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-18 12:15:23 -04:00
Jeremiah Lowin
1cb30a4e42
Delete warning_box_test.html (#2136) 2025-10-18 11:50:34 -04:00
Jeremiah Lowin
9e78d755c2
Support custom server name, icons, and link in OAuth Proxy consent page (#2135)
* Implement icon support in fastmcp

* Fix icon feature tests

- Update snapshot for ResourceTemplate to include icons field
- Remove OAuth mounting tests (belong to PR #2119, not this feature)

* Update docs

* Customize consent screen

* Use server website link if available

* Anchor link shouldnt have trailing slash

* Remove 'a FastMCP server named' from consent page message

* Update docs
2025-10-18 11:49:26 -04:00
Omer Aharonian
5ce67f756b
transform NotFoundError to standard MCP error (#2133) 2025-10-18 11:46:57 -04:00
Jeremiah Lowin
6f627b58fd
Implement icon support (#2121)
* Implement icon support in fastmcp

* Fix icon feature tests

- Update snapshot for ResourceTemplate to include icons field
- Remove OAuth mounting tests (belong to PR #2119, not this feature)

* Update docs
2025-10-17 17:28:08 -04:00
Jeremiah Lowin
330eaed11f
OAuth proxy issues its own tokens (#2109)
* OAuth proxy issues its own tokens

Implement token factory pattern where proxy issues FastMCP JWTs
instead of forwarding upstream tokens. Tokens are minimal references
(JTI) that map to encrypted upstream credentials stored server-side.

* Update run-tests.yml

* Update secret generation and docs

* Add upgrade guide
2025-10-17 14:31:53 -04:00
Jeremiah Lowin
d472e30765
Support mounting OAuth-protected servers under path prefixes (#2119)
* Add issuer_url parameter to OAuth providers for mounting scenarios

* Add get_well_known_routes

* Update docs

* Improve docs and tests

* Trigger CI

* Fix conditional test execution for Windows
2025-10-17 11:44:49 -04:00
Jeremiah Lowin
d4837b41c5
Disable parallel test execution on Windows (#2128) 2025-10-17 11:28:42 -04:00
Jeremiah Lowin
4f5aebe59b
Update version badge for azure auth docs (#2120)
* Update version badge for azure auth docs

* Revert "Update version badge for azure auth docs"

This reverts commit 8b0537e295.
2025-10-17 09:38:59 -04:00
Jeremiah Lowin
4a9f02c87c
Upgrade to MCP 1.17+ with RFC 9728 compliance (#2122)
* Upgrade to MCP 1.17+ with RFC 9728 compliance

Updates FastMCP to require MCP 1.17+ and implements RFC 9728-compliant
OAuth protected resource metadata URL handling.

The key change is that .well-known/oauth-protected-resource endpoints
are now registered at path-aware locations. For example, if an MCP
server is mounted at /mcp, the metadata endpoint is now at
/.well-known/oauth-protected-resource/mcp instead of
/.well-known/oauth-protected-resource.

This ensures proper OAuth discovery for path-based resource servers
and aligns with the MCP SDK's implementation of RFC 9728 §3.1.

Changes include:
- Update minimum MCP version from 1.12.4 to 1.17.0
- Use build_resource_metadata_url() for RFC 9728 compliance
- Configure CI to test with latest package versions (--upgrade)
- Update tests for path-aware metadata URLs
- Add icons field to Tool model (introduced in MCP 1.17)

* Fix RemoteAuthProvider integration tests for RFC 9728

* Fix parameterized test for nested base URL paths
2025-10-17 09:29:23 -04:00
William Easton
83adbc0a79
Merge pull request #1845 from jlowin/responsecachingmiddleware
Add Response Caching Middleware
2025-10-16 22:12:31 -05:00
William Easton
f5d770e801
update lock 2025-10-16 22:00:57 -05:00
William Easton
831a5dd070
Unwind tool result changes 2025-10-16 21:59:55 -05:00
William Easton
b713b5e4d0
Merge branch 'main' into responsecachingmiddleware 2025-10-16 21:59:20 -05:00