Commit graph

42 commits

Author SHA1 Message Date
Jeremiah Lowin
4ad78a60ef
Forward-port HTTP host guard compatibility (#4474) 2026-07-08 20:55:56 -04:00
Jeremiah Lowin
fd5d98bd13
Test: HTTP lifespan fires once per process across sessions (#4470) 2026-07-08 20:55:26 -04:00
Jeremiah Lowin
6621024ce4
Drive the FastMCP lifespan through the SDK session manager (#4446) 2026-07-07 07:49:16 -04:00
Jeremiah Lowin
3522a98766
Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
Jeremiah Lowin
57a279928d
Protect streamable HTTP from DNS rebinding (#4405) 2026-07-05 17:11:08 -04:00
Sarthak Bhardwaj
8209093871
fix(http): terminate active streamable-HTTP transports before lifespan shutdown (#4118) 2026-05-10 10:58:13 -04:00
Jeremiah Lowin
8c10bb8881
fix: remove stale ty:ignore directives for ty 0.0.26 (#3684) 2026-03-28 20:02:40 -04:00
Miguel Miranda Dias
5879119de5
fix: HTTP request headers not accessible in background task workers (#3631)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2026-03-27 21:48:33 -04:00
Jeremiah Lowin
c397e68d39
Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
Jeremiah Lowin
564b4c0d5c
Fix ty 0.0.17 diagnostics and bump lockfile 2026-02-16 16:13:38 -05:00
Jeremiah Lowin
d12d46b049
Exclude content-type header from get_http_headers() to prevent HTTP 415 errors (#3104)
Fixes #3097

When using FastMCP.from_openapi() with APIs that require specific
Content-Type headers (e.g., application/vnd.api+json), the transport
connection's content-type: application/json was being injected into
downstream API requests, causing HTTP 415 (Unsupported Media Type) errors.

This change adds content-type to the exclude_headers set in get_http_headers(),
similar to how accept is already excluded. The MCP transport's content type
has no relevance to downstream API calls and should not be forwarded.

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2026-02-06 20:19:36 -05:00
Jeremiah Lowin
2b6a0faf1c
Add loq file size limits and clean up type ignores (#2859) 2026-01-13 07:29:12 -05:00
Jeremiah Lowin
648684d2bb
Introduce ResourceResult as canonical resource return type (#2734) 2025-12-25 21:21:55 -05:00
Jeremiah Lowin
049bd22827
Replace type: ignore[attr-defined] with isinstance assertions in tests (#2665)
* Replace type: ignore[attr-defined] with isinstance assertions in tests

* Fix isinstance assertions in failing tests

- Fix enum test to check for ResponseEnum instead of str
- Fix binary resource test to check for BlobResourceContents instead of TextResourceContents
- Fix Root type tests to check attributes directly instead of isinstance checks

* Fix type errors without using type: ignore

- Remove execution methods from TransformingProvider (only handles transformations)
- Add execution methods to base Provider class with default implementations
- Fix type narrowing in tests using cast() instead of type: ignore
- Fix PromptResult type handling in prompt render tests
- Fix type narrowing in middleware test for arguments and structured_content
2025-12-21 16:37:20 -05:00
Jeremiah Lowin
07750efaab
Fix type errors for ty 0.0.1-alpha.31 upgrade (#2561)
* Fix type errors for ty 0.0.1-alpha.31 upgrade

Add type ignores and fixes for ty's stricter checking:
- Path(None) guards in cli.py
- isinstance checks for ElicitRequestFormParams (URL elicitation support)
- TODO(ty) comments for match/isinstance narrowing bugs
- Method override type ignores for generic covariance
- Starlette Middleware typing workarounds
- Dynamic type construction ignores in json_schema_type.py

* Fix remaining type errors for ty 0.0.1-alpha.31

- Add asserts for optional attribute access in tests
- Add type ignores for dynamic httpx transport internals
- Add TODO(ty) comments for `in` operator on str|bytes
- Add TODO(ty) comments for Starlette Middleware typing
- Use cast for prompt.fn async validation in server.py

* Upgrade ty to 0.0.1-alpha.31

Fixes additional test file type errors discovered after upgrade.
2025-12-05 21:29:14 -05:00
Jeremiah Lowin
246a0adefd
Fix get_access_token() returning stale token after OAuth refresh (#2505)
* Fix get_access_token() returning stale token after OAuth refresh

Fixes #1863

* Update dependencies.py
2025-12-01 10:51:02 -05:00
Jeremiah Lowin
254ff1a25d
Make CORS opt-in via middleware parameter (#2150) 2025-10-20 15:33:13 -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
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
Jeremiah Lowin
91af3cd2ae
Internal refactor of MCP handlers (#2005) 2025-10-05 08:45:10 -04:00
nate nowack
04831b75c2
optimize test suite (#1893)
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-22 20:07:04 -04:00
Jeremiah Lowin
d36ea42b92
Fix OAuth resource URL handling and WWW-Authenticate header (#1706) 2025-09-02 15:14:05 -04:00
Jeremiah Lowin
ce0a044835
Remove trailing slash in unit tests (#1535) 2025-08-18 08:10:46 -04:00
Jeremiah Lowin
c6768dad5f
Add documentation for get_access_token() dependency function (#1446)
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-08-11 13:01:44 -04:00
Panos Argyrakis
c3f4623690
fixes #1398: Add JWT claims to AccessToken (#1399)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-08-09 20:58:09 -04:00
Jeremiah Lowin
87e103222e
Improve redirect handling to address 307's (#1387) 2025-08-08 11:55:30 -04:00
Jeremiah Lowin
ec52e74b48
Introduce RemoteAuthProvider for cleaner external identity provider integration, update docs (#1346) 2025-08-02 20:36:38 -04:00
Jeremiah Lowin
b46d4934a8
Add comprehensive OAuth 2.1 authentication system with WorkOS integration (#1327) 2025-08-01 17:06:55 -04:00
Jeremiah Lowin
60ca72bb0b
Add complete support for TokenVerifier protocol (#1297) 2025-07-29 20:01:40 -04:00
Daniel Campos Olivares
448e794dc7
feat: Allow Resource Metadata URL as field in OAuthProvider (#1287) 2025-07-29 17:40:46 -04:00
Jeremiah Lowin
db24c85359 Update all tests 2025-06-27 21:41:37 -04:00
Jeremiah Lowin
b98b080c98 Implement TokenVerifier protocol for mcp-python-sdk compatibility
Fixes breaking changes from mcp-python-sdk PR #982 which updated
BearerAuthBackend to use TokenVerifier protocol instead of OAuth providers.

Changes:
- Add verify_token() method to BearerAuthProvider implementing TokenVerifier protocol
- Add verify_token() method to InMemoryOAuthProvider implementing TokenVerifier protocol
- Update BearerAuthBackend usage in setup_auth_middleware_and_routes() to pass TokenVerifier
- Add comprehensive unit tests for TokenVerifier implementations
- Add integration tests for BearerAuthBackend with TokenVerifier
- Add tests for HTTP auth setup functions

All existing functionality preserved with full backwards compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-26 15:08:31 -04:00
Jeremiah Lowin
76e3df1bc1 Add "http" as an alias for streamable-http 2025-06-22 18:55:07 -04:00
Jeremiah Lowin
18ae625fef Update docs and test 2025-06-20 13:06:48 -04:00
Jeremiah Lowin
099d340208 Update tests for prompts 2025-06-04 16:37:41 -04:00
Jeremiah Lowin
18615bc48b Remove empty parens 2025-06-04 15:41:28 -04:00
Jeremiah Lowin
8fb709c98c Simplify code for running servers in processes 2025-06-01 09:35:06 -04:00
Jeremiah Lowin
3e2fbb606b
Merge branch 'main' into fix-typing 2025-05-31 20:47:12 -04:00
Jeremiah Lowin
f1e3713fc6 Update test typing 2025-05-31 20:41:18 -04:00
Jeremiah Lowin
2390fb4da6 clean up test inits 2025-05-31 19:32:08 -04:00
Jeremiah Lowin
213abc4244 Pass client headers through to OpenAPI client 2025-05-23 12:38:24 -04:00
Jeremiah Lowin
189389a3a4 Ensure custom routes are respected 2025-05-22 12:20:29 -04:00