Commit graph

2,417 commits

Author SHA1 Message Date
Jeremiah Lowin
38af6228f4 Fix merge conflicts in context.py 2025-11-02 16:48:33 -05:00
Cole Murray
c8ddbff488
Security: Update authlib to 1.6.5 (CVE-2025-61920) (#2347)
Updates authlib from 1.6.1 to 1.6.5 to address CVE-2025-61920, which
fixes a denial of service vulnerability in JOSE implementation that
accepts unbounded JWS/JWT header and signature segments.
2025-11-02 11:46:55 -05:00
Jeremiah Lowin
c9ec1459e1
Mark flaky Windows test for retry (#2344)
* Mark flaky Windows test for retry

test_multi_client_transform_with_filtering occasionally times out on Windows CI during exception formatting in linecache.checkcache(). Add @pytest.mark.flaky with 3 retries.

* Remove unnecessary delay from flaky marker
2025-11-01 16:52:08 -04:00
Jeremiah Lowin
dab125e069
Remove test warnings (#2331) 2025-11-01 14:53:51 -04:00
Harshith Thota
321f404046
Added to_data_uri method for Image class. (#2227)
* Added to_data_uri method and path_to_data_uri classmethod for Image class.

* Removed path_to_data_uri classmethod and modified _get_mime_type to use mimetypes.guess_type function instead of hardcoded dictionary.

* Register image/webp with mimetypes before guess_type to support WEBP mimetype detection on Python 3.10.

* Improved branch coverage for Image.to_data_uri.

* Added Image._to_data_uri example in the docs.
2025-11-01 11:40:08 -04:00
Josh Thomas
08c49e62e8
Fix query-only resource templates not matching URIs without query strings (#2323)
* Fix query-only resource templates not matching URIs without query strings

* apply the same fix to `has_resource`
2025-11-01 11:27:37 -04:00
Jeremiah Lowin
443c44c507
Configure Marvin to auto-create PRs and label issues (#2319)
* Update marvin.yml

* Configure Marvin to auto-create PRs and label issues

* Make Marvin instructions more assertive with MUST
2025-10-31 10:38:15 -04:00
Jeremiah Lowin
de58bb0e6c
Add DebugTokenVerifier with custom sync/async validation (#2296)
* Add DebugTokenVerifier with custom sync/async validation

* move import
2025-10-31 10:38:01 -04:00
Jeremiah Lowin
87adacfc8b
Require uvicorn>=0.35 for websockets-sansio support (#2307)
Fixes #2299

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-31 10:22:55 -04:00
William Easton
d12f51d22c
Merge pull request #2311 from jlowin/claude/issue-2310-20251029-2141
Add maturity warnings for py-key-value backends
2025-10-30 13:01:35 -05:00
claude[bot]
237f0decd2 Add maturity warnings for py-key-value backends
Add warning notes to documentation directing users to review
py-key-value documentation for backend maturity and limitations
before production use.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-29 21:43:31 +00:00
Jeremiah Lowin
e2d317eeb6
Add OIDCProxy to auth module exports (#2308)
Fixes #2298

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-29 14:28:26 -04:00
Jeremiah Lowin
1ca53b4134
Add base_authority parameter to AzureProvider for Azure Government support (#2306) 2025-10-29 14:06:21 -04:00
Jeremiah Lowin
463b336941
Fix Chrome CSP blocking OAuth consent form with custom protocol redirects (#2305)
* Fix Chrome CSP blocking OAuth consent form with custom protocol redirects

* Fix Chrome CSP blocking OAuth consent form with custom protocol redirects

Dynamically include custom protocol schemes in CSP form-action directive
when redirect URIs use custom protocols like cursor://
2025-10-29 14:04:56 -04:00
Jake Kaplan
9c750fe5e4
Merge pull request #2294 from jlowin/exec-info-from-run
Switch to `logger.exception` for `fastmcp run/inspect`
2025-10-28 11:22:40 -04:00
jake@prefect.io
4262468b44 use logger.exeception 2025-10-28 10:18:21 -04:00
jake@prefect.io
a2f710fa9d add exc_info to fastmcp run 2025-10-28 10:14:53 -04:00
Jeremiah Lowin
887e72b39b
Replace openapi-core with jsonschema-path (#2291) 2025-10-28 06:46:52 -07:00
Jeremiah Lowin
318da83f6b
Fix py-key-value-aio minimum version to 0.2.8 (#2288)
* Fix py-key-value-aio minimum version to 0.2.8

FernetEncryptionWrapper was introduced in 0.2.8, not 0.2.6.

Fixes #2284

* Update lockfile
2025-10-28 06:30:03 -07:00
coderabbitai[bot]
4ea896c246
📝 Add docstrings to enhancement/support-jwt-multiple-issuers (#2282)
* 📝 Add docstrings to `enhancement/support-jwt-multiple-issuers`

Docstrings generation was requested by @jlowin.

* https://github.com/jlowin/fastmcp/pull/2233#issuecomment-3453446122

The following files were modified:

* `src/fastmcp/server/auth/providers/jwt.py`

* Fix formatting issues in JWT provider docstrings

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-27 19:26:25 -04:00
mhassaninmsft
b24d771457
Supporting Multiple Issuers For JWTVerifier Oauth Workflow (#2233)
* multiple issuers

* Update tests/server/auth/test_jwt_provider.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix static checks

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-10-27 18:13:40 -04:00
Jeremiah Lowin
15dbe7ecf0
Add custom token verifier support to OIDCProxy (#2279)
* Add custom token verifier support to OIDCProxy

OIDCProxy now accepts an optional token_verifier parameter to support
non-JWT token formats like opaque tokens from providers such as Clerk.

When provided, the custom verifier is used instead of creating a default
JWTVerifier. Parameters that only apply to JWTVerifier creation (algorithm,
required_scopes) raise clear errors when specified alongside a custom
verifier. Parameters with other purposes (audience for OAuth flow,
timeout_seconds for config fetch) remain allowed.

The custom verifier's required_scopes are automatically loaded and
advertised through OAuth discovery endpoints.

* Document custom token verifier support in OIDC proxy
2025-10-27 13:38:20 -04:00
Jeremiah Lowin
6d600e36db
Remove trailing slashes from MCP endpoint URLs in docs (#2277) 2025-10-27 10:36:47 -04:00
William Easton
7999dcbf2c
Merge pull request #2276 from JonZeolla/fixdocs/key-value-project
fix(docs): correct the key_value repo link
2025-10-27 07:52:55 -05:00
Jon Zeolla
11277f6e21 fix(docs): correct the key_value repo link 2025-10-27 07:35:10 -04:00
Jeremiah Lowin
8a48146aad
Cleanly render oauth errors from proxy (#2268) 2025-10-26 21:08:05 -04:00
Jeremiah Lowin
5ceafe425c
Fix OAuth token storage documentation (#2272)
Correct imports (DiskStore not FileStore) and simplify structure.
2025-10-26 21:07:54 -04:00
Jeremiah Lowin
9a7c04873c
Add note about docs version (#2271) 2025-10-26 21:00:49 -04:00
Jeremiah Lowin
f5bdf8f6d3
Improve OAuth client token storage security documentation (#2270)
* Update docs for required scopes

* add scopes

* Fix Azure scope validation

Azure returns unprefixed scopes in JWT tokens but requires prefixed scopes in authorization requests. The previous implementation incorrectly validated tokens against prefixed scopes, causing "invalid_token" errors.

Simplified AzureProvider to use standard JWTVerifier with unprefixed scopes for validation. Scopes are only prefixed when building the Azure authorization URL via _build_upstream_authorize_url() override.

Closes #2263

* Improve OAuth client token storage security documentation

Updated warning message and documentation to address security concerns
around storing OAuth credentials for multiple MCP servers.
2025-10-26 20:04:54 -04:00
Jeremiah Lowin
8bd3a308c9
Update Azure sidebar title to include Entra ID (#2266)
* Update Azure sidebar title to include Entra ID

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

* Update Azure title to emphasize Microsoft Entra ID

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

* Update Azure title to emphasize Azure over Entra ID

Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-26 19:49:40 -04:00
Jeremiah Lowin
ba47db9b8c
Fix Azure scope validation (#2269) v2.13.0.1
* Update docs for required scopes

* add scopes

* Fix Azure scope validation

Azure returns unprefixed scopes in JWT tokens but requires prefixed scopes in authorization requests. The previous implementation incorrectly validated tokens against prefixed scopes, causing "invalid_token" errors.

Simplified AzureProvider to use standard JWTVerifier with unprefixed scopes for validation. Scopes are only prefixed when building the Azure authorization URL via _build_upstream_authorize_url() override.

Closes #2263
2025-10-26 11:41:22 -04:00
William Easton
9d4c378e1b
Add "High Value" Ruff Rules (#2255)
* Safe Fixes from ruff

* Fix remaining issues

* lint/check

* Fix mysterious ty check errors

* small cleanup

* pr fixes
2025-10-26 10:20:31 -04:00
Copilot
e74918a544
Add CI test job for lowest-direct dependency resolution (#2261)
* Initial plan

* Add test job for lowest-direct dependency resolution

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
2025-10-26 10:16:54 -04:00
marvin-context-protocol[bot]
716e50dae0
chore: Update SDK documentation (#2214) v2.13.0
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2025-10-25 08:52:43 -04:00
Jeremiah Lowin
5896daf6a1
Stage 2.13.0 updates (#2252)
* Add 2.13.0 updates

* Small tweaks
2025-10-25 08:52:21 -04:00
Jeremiah Lowin
b57a39c69c
Remove redundant None checks from Context methods (#2251) v2.13.0rc3
The fastmcp property already raises RuntimeError if None, making these checks unreachable.
2025-10-24 19:32:45 -04:00
William Easton
380835593c
Async FileResource and DirectoryResource (#2241)
* Improve DirectoryResource exception logging and async implementation

- Add exception logging before raising ResourceError in read() method
- Convert list_files() to async-native using anyio.Path
- Update read() to await async list_files() and use async is_file() check
- Remove synchronous thread wrapper in favor of native async I/O

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Clean-up DirectoryResource

* Update src/fastmcp/resources/types.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 19:25:15 -04:00
William Easton
1e5776f69c
Add list_resources, list_prompts, and get_prompt methods to Context (#2249)
* Add list_resources, list_prompts, and get_prompt methods to Context

- Add Context.list_resources() to list all available resources
- Add Context.list_prompts() to list all available prompts
- Add Context.get_prompt() to get a specific prompt with arguments
- Update ToolInjectionMiddleware to use new Context methods instead of creating temporary Client instances
- Remove unused Client and FastMCPTransport imports from tool_injection.py

This improves API consistency by allowing middleware/tools to use Context methods directly without needing to create temporary Client instances.

Fixes #2245

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Update docs

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-10-24 19:24:02 -04:00
William Easton
a83824c04d
Merge branch 'main' into claude/issue-2245-20251024-2225 2025-10-24 18:16:34 -05:00
Jeremiah Lowin
7de74c05cb Update docs 2025-10-24 19:16:25 -04:00
William Easton
2f13119684
Add Documentation for FastMCP Server Testing (#2244)
* Add doc with recommendations for server testing

* Updates to testing doc

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* add to sidebar under patterns

* Update docs/patterns/testing.mdx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 19:11:21 -04:00
William Easton
c002bc389c
Small Clean-up (#2247)
* Project Clean-up

* Move pytest-asyncio to dev dependencies and update agents.md
2025-10-24 19:11:01 -04:00
Jeremiah Lowin
19fbc8435e
delete ratio test (#2250) 2025-10-24 19:10:19 -04:00
William Easton
063ffe9f64
Derive jwt_signing_key from Client Secret, default to Encrypted Disk Store (#2223)
* Checkpoint progress

* Checkpoint progress

* add derive b64 method

* PR clean-up

* refactor da proxy

* Updates to tests

* Make jwt_signing_key required for oauth proxy

* use typing_extensions and fix tests

* PR Cleanup

* also adjust integration tests

* Update docs, use client secret to derive jwt signing key

* You win some you lose some, gg claude

* check for both in derive

* update documentation / clean up

* Update http.mdx

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-10-24 19:08:58 -04:00
Jeremiah Lowin
577ed6e9a3
Fix middleware example: add context parameter to call_next() (#2215)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-24 18:41:00 -04:00
Jeremiah Lowin
65260c91d5
Add version badge for run_server_async in tests docs (#2237)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Jeremiah Lowin <jlowin@users.noreply.github.com>
2025-10-24 18:40:30 -04:00
claude[bot]
63add18970 Add list_resources, list_prompts, and get_prompt methods to Context
- Add Context.list_resources() to list all available resources
- Add Context.list_prompts() to list all available prompts
- Add Context.get_prompt() to get a specific prompt with arguments
- Update ToolInjectionMiddleware to use new Context methods instead of creating temporary Client instances
- Remove unused Client and FastMCPTransport imports from tool_injection.py

This improves API consistency by allowing middleware/tools to use Context methods directly without needing to create temporary Client instances.

Fixes #2245

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-24 22:34:45 +00:00
Adam Azzam
69b273ee8e
Add exc_info=True to inspect command error logging (#2232)
Fixes #2231

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-24 18:20:45 -04:00
William Easton
f5dbabff4e
Add ToolInjectionMiddleware + Tools for Read/List Resource/Prompt for Client Compat (#2142)
* Add compatibility tools contrib module

Implements four standalone tools that expose resources and prompts
as callable tools for clients that only support the tools capability.

Features:
- list_resources: List all available resources
- get_resource: Read a resource by URI
- list_prompts: List all available prompts
- get_prompt: Get a prompt with optional arguments

The tools use Context to access the server instance and can be easily
added to any FastMCP server using the add_compatibility_tools helper
or by adding individual tool instances directly.

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

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Simplify compatibility tools to return raw MCP protocol objects

Return raw MCP protocol objects (ListResourcesResult, ReadResourceResult,
ListPromptsResult, GetPromptResult) instead of custom dictionaries. This
makes the tools simpler and more predictable by directly exposing what
the client methods return.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Add tool injection middleware

* cleanup contrib module

* More clean-up

* Clean up tool injection middleware.

* Update src/fastmcp/server/middleware/tool_injection.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add tool injection docs

* Small cleanup of prompt middleware

* PR Feedback

* Fix tool injection tests

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-24 18:06:58 -04:00
William Easton
c1e154ad66
Use abstract types for FastMCP class instantiation (#2219)
* feat: use abstract collection types in FastMCP.__init__

Use Sequence, Collection, and Mapping from collections.abc for more
flexible typing in FastMCP.__init__ parameters. This allows downstream
developers to pass tuples, sets, and other collection types instead of
being restricted to list and dict.

Changes:
- middleware: list -> Sequence (converted to list internally)
- tools: list -> Sequence
- tool_transformations: dict -> Mapping (ToolManager updated)
- include_tags: set -> Collection
- exclude_tags: set -> Collection
- dependencies: kept as list per maintainer request

Closes #2212

Co-authored-by: William Easton <strawgate@users.noreply.github.com>

* Concrete types in class inits

* Small imports cleanup

* Fix include/exclude tag handling

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-24 17:50:07 -04:00