Commit graph

2,605 commits

Author SHA1 Message Date
Chris Guidry
61108a0bba
Merge pull request #2570 from jlowin/add-task-config-modes
Add TaskConfig for SEP-1686 execution modes
2025-12-08 09:41:59 -05:00
Chris Guidry
5d04b3a217
Merge branch 'main' into add-task-config-modes 2025-12-08 09:38:00 -05:00
Jeremiah Lowin
597286a633
Update VersionBadge to use Mintlify native Badge component (#2571)
Replace custom VersionBadge implementation with Mintlify's native Badge component while preserving custom color and border styling via CSS. This leverages Mintlify's built-in sizing, typography, and icon support while maintaining the original visual design.
2025-12-06 21:23:53 -05:00
Jeremiah Lowin
b291abb460 Fix inline snapshots for task_config rename 2025-12-06 21:05:11 -05:00
Jeremiah Lowin
a231ea4c3c Add TaskConfig for SEP-1686 execution modes
Expose the full MCP task execution modes (forbidden/optional/required)
via TaskConfig instead of just boolean task=True/False.
2025-12-06 21:01:11 -05:00
Jeremiah Lowin
8771f290bd
Rewrite background tasks documentation (#2567)
- Lead with concepts instead of code
- Explain MCP background tasks vs general Python concurrency
- Document Docket's Prefect origins and battle-tested infrastructure
- Add sections on graceful degradation and embedded workers
- Fix version badge to 2.14.0
- Link to SEP-1686 spec
2025-12-06 19:28:14 -05:00
Chris Egersdoerfer
6147c27995
add client kwargs to proxy clients and meta to proxy tool calls (#2520)
* add client kwargs to proxy clients and meta to proxy tool calls

* Update src/fastmcp/client/transports.py

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

* Update src/fastmcp/server/proxy.py

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

* Update src/fastmcp/utilities/mcp_config.py

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

* update formats and fix lint errors

* remove client callback passthrough

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-12-06 16:21:59 -05:00
Jeremiah Lowin
0cf12fa30c
Add regression tests for functools.wraps + Context (#2524) (#2566)
Follow-up to PR #2563 which fixed the signature handling in
create_function_without_params. These tests ensure the fix
works end-to-end for all object types that support Context injection.
2025-12-06 12:32:39 -05:00
alex
bc5c1bfbd7
docs: document stateless_http for horizontal scaling (#2547) 2025-12-06 11:59:01 -05:00
Aidan Allchin
b9cde3bdb6
Fix: Include signature modification in create_function_without_params (#2563)
* Fix: Include signature modification in create_function_without_params

When excluding parameters via create_function_without_params(), only
__annotations__ was being updated but not __signature__. This caused
Pydantic's _arguments_schema() to fail when it iterated over signature
parameters that didn't exist in the type hints dictionary.

The fix adds proper signature reconstruction matching the pattern used
in without_injected_parameters().
Fixes KeyError: 'ctx' when using @mcp.tool() with Context parameters.

* fix: add regression tests for create_function_without_params

The test_pydantic_typeadapter_compatibility test specifically reproduces the issue from #2562 and verifies the fix.

* fix: linter for test function

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-12-06 11:57:36 -05:00
Jeremiah Lowin
8d3deeecc9
Add v2.14.0 upgrade guide (#2565)
* Add v2.14.0 upgrade guide section

* Update upgrade guide to use CodeGroup tabs for all migration examples
2025-12-06 11:40:42 -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
1ed976b1d9
refactor: move task attribute to function-based variants only [SEP-1686] (#2560)
* refactor: move task attribute to function-based variants only

* fix: update snapshot test for ResourceTemplate without task field
2025-12-05 21:05:42 -05:00
Chris Guidry
960ce77c7e
Merge pull request #2558 from jlowin/unify-enable-tasks
Remove enable_docket setting; Docket is now always on
2025-12-05 12:40:04 -05:00
Chris Guidry
e63855ccf3 fix: use simple sleep for server readiness, restore Windows parallelism 2025-12-05 12:36:20 -05:00
Chris Guidry
bc587208aa fix: wait for HTTP server readiness via httpx request 2025-12-05 12:33:29 -05:00
Chris Guidry
7e4c854625 fix: use simple sleep instead of _wait_for_port on Windows 2025-12-05 12:32:49 -05:00
Chris Guidry
faa897b7d7 fix: skip wait_closed() on Windows to avoid socket shutdown hang 2025-12-05 12:30:27 -05:00
Chris Guidry
0d96f88d59 test: skip redis connection pool disconnect to fix Windows hangs 2025-12-05 12:27:53 -05:00
Chris Guidry
cf101c2a82 test: run Windows tests without xdist parallelism 2025-12-05 12:23:37 -05:00
Chris Guidry
c02c73f556 Use fresh FakeServer per test to prevent shared state issues
Docket stores a shared FakeServer as a class attribute (_memory_server).
When many tests run in parallel, shared state can cause issues on Windows.

Add autouse fixture to reset the shared server before each test.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 12:18:42 -05:00
Chris Guidry
55297a06a3 Disable Docket strike monitoring in tests (fakeredis busy-loop fix)
Fakeredis doesn't implement blocking xread properly - it returns
immediately instead of waiting. This causes Docket._monitor_strikes
to busy-loop, overwhelming pytest-xdist workers on Windows.

Mock the method to just sleep, since strike coordination isn't useful
with in-memory backends anyway.

See: https://github.com/cunla/fakeredis-py/issues/274

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 12:12:11 -05:00
Chris Guidry
bcd2e594f0 Use SelectorEventLoop on Windows to fix pytest crashes
Windows ProactorEventLoop has known memory corruption issues that cause
pytest-xdist worker crashes with "node down: Not properly terminated".

Setting WindowsSelectorEventLoopPolicy in conftest.py avoids this issue.

See: https://github.com/python/cpython/issues/116773

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 12:03:05 -05:00
Chris Guidry
53efaeba5b Add timeout to worker cleanup to prevent hanging on Windows
When pytest-xdist terminates worker processes on Windows, the event loop
may close before cleanup can complete. Adding a 2-second timeout to the
worker cancellation prevents indefinite hanging.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 11:52:43 -05:00
Chris Guidry
a34b680bb4 Add missing asyncio import
Lost during rebase conflict resolution.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 11:42:09 -05:00
Chris Guidry
47d3044b06 Remove enable_docket setting; Docket is now always on
Docket provides background task execution and is now always available
for all FastMCP servers. Only `enable_tasks` remains to control the
SEP-1686 task protocol support.

Changes:
- Remove `enable_docket` setting and related validation
- Docket/Worker lifecycle is always active in server lifespan
- CurrentDocket and CurrentWorker dependencies work without config
- Add server readiness signaling via `_started` event
- Fix test timing issues with proper port probing

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 11:40:04 -05:00
Jeremiah Lowin
e47abb4bd7
[SEP-1686] Raise ValueError when sync functions have task=True (#2554)
* Raise ValueError when sync functions have task=True

Move validation from server.py decorators to the from_function() class
methods on FunctionTool, FunctionPrompt, FunctionResource, and
FunctionResourceTemplate. This ensures the check runs regardless of how
the objects are created.

* Fix async check for callable classes and staticmethods

Move the task=True async validation to run AFTER callable classes and
staticmethods are unwrapped, preventing false positives for async
callable classes with sync-looking signatures.
2025-12-05 11:31:28 -05:00
Chris Guidry
66aaf420c9
[2.14] SEP-1686 tasks (#2378)
* Implement MCP background tasks (SEP-1686) using Docket

Adds support for background task execution via the MCP task protocol,
powered by Docket for task queue management.

- Tools, resources, and prompts can be marked with `task=True` to run async
- Progress dependency for tracking task progress
- CurrentDocket and CurrentWorker dependencies for advanced use cases
- Client API with `.call_tool(..., task=True)` returns task handles
- Task status notifications via subscriptions
- CLI worker command for distributed task processing

Configuration via environment:
- FASTMCP_ENABLE_DOCKET=true
- FASTMCP_ENABLE_TASKS=true
- FASTMCP_DOCKET_URL=redis://... (or memory:// for single-process)

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix tasks example import (TaskStatusResponse → GetTaskResult)

The example was using a non-existent TaskStatusResponse type.
Updated to use mcp.types.GetTaskResult which is what the
on_status_change callback actually receives.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix env var name in Docket error messages

The error messages referenced FASTMCP_EXPERIMENTAL_ENABLE_DOCKET but the
actual setting is FASTMCP_ENABLE_DOCKET.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove deprecated code re-added from pre-#2329 branch

- Remove ExtendedEnvSettingsSource (FASTMCP_SERVER_ prefix support)
- Remove dependencies parameter from FastMCP.__init__

* Replace fakeredis git pin with PyPI release

* Remove redundant fakeredis dev dep (pulled via pydocket)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-12-04 20:10:35 -05:00
SEONG SEOB KIM
b109cf05cb
Update FastMCP server documentation link (#2529)
The link to FastMCP Server Documentation was pointing to /servers/fastmcp which returns 404. Changed to /servers/server.

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-12-04 19:22:26 -05:00
William Easton
ffb8607e24
Reduce Marvin Test Failure noise
Reduce Marvin Test Failure noise
2025-12-04 18:01:47 -06:00
William Easton
b130c0161e
Small additional changes 2025-12-04 17:57:08 -06:00
William Easton
5838e90105
Purposefully fail the workflow 2025-12-04 17:40:58 -06:00
William Easton
8c2675447f
Update martian-test-failure.yml 2025-12-04 17:39:51 -06:00
William Easton
177eeaee50
Less noise 2025-12-04 17:37:41 -06:00
Jeremiah Lowin
707d664541
Add supabase docs (#2030)
* Add supabase docs

* Update supabase version badge to 2.13.0
2025-12-04 18:25:57 -05:00
Chris Guidry
9ea76e8e01
Merge pull request #2550 from jlowin/deflake-integration-tests-2
Improve rate limit detection for integration tests
2025-12-04 13:48:41 -05:00
Chris Guidry
6faef9d96f Add timeout to client cleanup to prevent hangs
When the MCP SDK's transport tries to terminate a session during cleanup,
it can hang if the server is unresponsive (e.g., rate-limited). Adding a
5-second timeout ensures we don't block forever during `__aexit__`.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 12:05:55 -05:00
Chris Guidry
a8bbd745fe Improve rate limit detection for integration tests
When GitHub's API rate limits cause asyncio shutdown issues, the test
times out rather than failing with the underlying 429 error. Updated the
detection logic to check for 429 indicators in the captured output when
a timeout occurs.

Also increased the per-test timeout from 15s to 30s to give remote API
calls more breathing room.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 11:52:40 -05:00
Jeremiah Lowin
acf4db0bf5
Add SEP-1034 default values support for elicitation (#2545)
- Add comprehensive tests for default values in elicitation schemas
- Document default values support in elicitation docs
- Confirms FastMCP automatically supports defaults via Pydantic

Closes #2544
2025-12-04 10:43:48 -05:00
Jeremiah Lowin
7f8a010798
Move TokenHandler to OAuthProvider for consistent error codes (#2538)
All OAuth providers now return correct invalid_client error codes
instead of unauthorized_client for auth failures. Previously only
OAuthProxy had this fix; now OAuthProvider (and InMemoryOAuthProvider)
also benefit.
2025-12-04 10:35:00 -05:00
Chris Guidry
97438db0ac
Deflake GitHub MCP remote integration tests (#2543)
The pytest-retry plugin was causing teardown crashes due to a bug with
pytest's tmp_path fixture stash. Removing `@pytest.mark.flaky` and instead
improving the rate limit detection to properly skip tests on 429 errors.

Also fixed a brittle error message regex - GitHub changed their error
format from "tool not found" to "unknown tool".

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-04 10:34:43 -05:00
Jeremiah Lowin
fe2ec99cc0
Validate tool names at registration time (SEP-986) (#2540) 2025-12-03 20:12:06 -05:00
Paulo Costa
e1e0553ecb
Make fastapi.cli a runnable module (#2532)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-12-03 19:23:22 -05:00
Jeremiah Lowin
9cade6c8c8
Fix RFC 8414 path-aware authorization server metadata discovery (#2533)
* Fix RFC 8414 path-aware authorization server metadata discovery

Override get_well_known_routes() in OAuthProvider to rewrite the
authorization server metadata route to be path-aware based on issuer_url,
matching how protected resource metadata already works.

Closes #2527

* Update readme
2025-12-03 19:16:59 -05:00
Chris Guidry
ee63405262
Merge pull request #2507 from jlowin/sdk-auth-updates
[2.14] Update for MCP SDK auth changes
2025-12-03 17:14:57 -05:00
Jeremiah Lowin
e3b103de40 Fix test to use handle() instead of deleted response() method 2025-12-03 16:46:01 -05:00
Jeremiah Lowin
c1e8aea578 Remove dead response() override from TokenHandler
The SDK now handles auth errors in handle() directly, so the response()
override checking for 'Invalid client_id' is never reached.
2025-12-03 15:59:55 -05:00
Jeremiah Lowin
8e57fe43a0 Update tests for client_secret=None behavior 2025-12-03 15:48:47 -05:00
Jeremiah Lowin
6c895aeb32 Fix client_secret validation for token_endpoint_auth_method=none
The MCP SDK now validates that client_secret is provided if it's set,
regardless of token_endpoint_auth_method. Since the proxy uses 'none'
for client auth (handling upstream auth itself), we must also set
client_secret=None to be consistent.
2025-12-03 15:42:25 -05:00
Chris Guidry
654442bfd3 Update FastMCP for MCP SDK 1.23.1 auth changes
- Bump mcp SDK to >=1.23.1
- Add `client_secret_basic` authentication support (SDK PR #1334)
- TokenHandler now wraps SDK's handle() to transform `unauthorized_client`
  to `invalid_client` on 401 responses per OAuth 2.1 spec
- Update `sample()` return type to use SDK's SamplingMessageContentBlock
- Update test expectations for new SDK fields (`task`, `_meta`)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 11:50:08 -05:00