Commit graph

51 commits

Author SHA1 Message Date
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
Antonio Iorga
7e6610b7b6
Add meta to call tool (#2206)
* feat: Add optional meta parameter to Client tool call methods

* fix: Add support for mcp<1.19

* chore: cleaner solution

* Refactor call_tool to directly accept meta parameter and add tests for meta functionality

---------

Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
2025-11-04 10:25:52 -05:00
Jeremiah Lowin
9c861b232b
Add manual initialization control to Client (#2355)
* Add manual initialization control to Client

- Add auto_initialize parameter (default True) to control automatic initialization
- Make initialize() method public with idempotent caching
- Add comprehensive test suite for initialization behavior

* Document client initialization control and server instructions

- Expand documentation to cover auto_initialize parameter
- Show manual initialization for advanced use cases
- Document accessing server instructions via initialize_result

* Update client.mdx
2025-11-03 16:01:30 -05:00
Jeremiah Lowin
e036cba383
Add Pydantic-compatible input validation (#2073) 2025-10-14 11:49:30 -07:00
Jeremiah Lowin
1f11b5e641
Refactor mounting logic from managers to server (#2069) 2025-10-11 18:28:21 -04:00
Jeremiah Lowin
b1458c6082
Default to FastMCP version when server version not specified (#2022)
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-10-08 19:57:30 -04:00
Christian Clauss
d6aa980ff5
Fix typos discovered by codespell (#1922) 2025-09-26 12:02:28 -04:00
Jeremiah Lowin
c40149d970
Ensure validation errors are raised when masked (#1330) 2025-08-01 17:06:27 -04:00
Jeremiah Lowin
c452164e86
Fix concurrent proxy client operations with session isolation (#1083)
* Refactor Client session state with ClientSessionState dataclass

Fixes #1068 by introducing ClientSessionState to encapsulate session management
attributes, simplifying Client.new() and preventing concurrent proxy client
context mixing through client factory pattern.

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

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

* Update proxy documentation for new client factory pattern

Documents the new session management behavior, client_factory parameter,
and concurrent operation safety introduced in v2.10.3 to fix #1068.

* Remove deprecation of client parameter and update documentation

- Undeprecated FastMCPProxy client parameter
- Made client_factory the advanced option for custom control
- Added detailed explanation of how client factories work internally
- Removed outdated note about proxy feature limitations
- Removed fabricated Advanced Usage section

* Re-do proxy documentation

* Fix deprecated client parameter to provide session isolation

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

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-08 17:22:43 -04:00
Jeremiah Lowin
0600834da4 Fix single-element list unwrapping in tool content
Single-element lists like [1] were being incorrectly unwrapped to "1"
in unstructured content while multi-element lists remained as lists.
This created inconsistent behavior where the structure was lost for
single items.

This fix ensures lists always preserve their structure in unstructured
content regardless of length, making behavior consistent and predictable.

Also removes pretty-printing from JSON serialization for more compact
output across tools, prompts, and resources.

Fixes #1064

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-07 12:07:16 -04:00
Jeremiah Lowin
d8dc28b9b2 Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
Jeremiah Lowin
73e1aa2112 Apply pre-commit formatting changes
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 10:29:15 -04:00
Jeremiah Lowin
a7f14d90a4 Implement client-side argument serialization with focused tests
- Add pydantic_core.to_json() serialization for non-string prompt arguments
- Update type annotations to accept dict[str, Any] instead of dict[str, str]
- Add focused tests covering specific scenarios:
  * Client always serializes non-string args regardless of server types
  * Integration with server-side type conversion
  * Client serialization error with specific PydanticSerializationError
  * Server deserialization error with specific McpError match

This ensures MCP protocol compliance while maintaining developer experience
with typed arguments.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 10:18:48 -04:00
Jeremiah Lowin
18ae625fef Update docs and test 2025-06-20 13:06:48 -04:00
Jeremiah Lowin
725c061d66 Fix import prefix behavior 2025-06-19 15:19:31 -04:00
Miki Yutani
60dada7026 Fix code formatting for pre-commit hooks 2025-06-16 13:08:44 +09:00
Miki Yutani
42121b2767 Add version parameter to FastMCP constructor 2025-06-16 12:38:15 +09:00
Jeremiah Lowin
bc59a4fbf5 Ensure client is only initialized once 2025-06-08 14:48:05 -04:00
Jeremiah Lowin
6d36171f38 Fix passing token string to client auth 2025-06-07 21:39:50 -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
d1549c3d35 Remove empty parens 2025-06-04 15:37:55 -04:00
Jeremiah Lowin
f1e3713fc6 Update test typing 2025-05-31 20:41:18 -04:00
Jeremiah Lowin
814a6e4419 Add concurrency test 2025-05-31 18:08:43 -04:00
Jeremiah Lowin
4e6b1bf611
Merge branch 'main' into mask-errors 2025-05-23 08:36:10 -04:00
Jeremiah Lowin
451fc3bfc2 Merge branch 'main' into clientconfig 2025-05-22 11:23:52 -04:00
Jeremiah Lowin
06b9b98b6c Raise an error if a Client is created with no servers in config 2025-05-22 11:22:45 -04:00
Jeremiah Lowin
53b067b4e7 Make error masking configurable 2025-05-22 09:08:16 -04:00
Jeremiah Lowin
1afe73c136 feat: support FastMCP v1 server transport 2025-05-21 17:42:26 -04:00
Jeremiah Lowin
fa1c94ccdc Support creating clients from mcpconfig 2025-05-20 20:48:16 -04:00
Jeremiah Lowin
02cb6f8291 Add config inference test 2025-05-20 17:45:13 -04:00
Jeremiah Lowin
7cad7373dd Merge branch 'main' into initialize-result 2025-05-20 10:41:21 -04:00
Jeremiah Lowin
3beabdbd1b
Merge branch 'main' into sse-inference 2025-05-20 10:29:47 -04:00
Jeremiah Lowin
a0e69a4cb2 Skip timeout tests on windows 2025-05-20 09:33:17 -04:00
Jeremiah Lowin
dde2dc4712 Flaky test 2025-05-20 09:30:03 -04:00
Jeremiah Lowin
8490905b0c Infer sse transport from url 2025-05-20 08:57:02 -04:00
Jeremiah Lowin
526b831bec Store the initialize result on the client 2025-05-19 20:49:03 -04:00
davenpi
a9c8969c12 Increase timeout in flaky test for reliability 2025-05-16 15:58:25 -04:00
Jeremiah Lowin
837d4c407d
Add timeout support to client (#455)
* Add timeouts kwargs

* Add timeout support

* Fix windows handling and docs

* Update client.mdx

* Windows tests

* Update test_sse.py

* Update test_sse.py

* Update test_sse.py

* Update test_sse.py

* Fix windows
2025-05-14 20:50:24 -04:00
Jeremiah Lowin
e7e301815f Handle template errors 2025-05-13 14:33:11 -04:00
Jeremiah Lowin
6fa7c1704a Improve error handling for tools and resources 2025-05-13 14:19:55 -04:00
Jeremiah Lowin
2eb0e7c1b3 Ensure prompts return descriptions 2025-05-05 12:33:05 -04:00
Jeremiah Lowin
085d4ae460 Update tests 2025-05-02 16:36:48 -04:00
Jeremiah Lowin
5ed101284a Remove mock transport 2025-04-23 14:26:13 -04:00
yihuang
ad41ca7dc8
fix format 2025-04-21 13:21:11 +08:00
yihuang
e962f4d312
fix test 2025-04-21 13:18:11 +08:00
yihuang
5bbad74044
add unit test 2025-04-21 13:14:46 +08:00
Jeremiah Lowin
d27141a935 Refactor remote servers 2025-04-15 20:28:14 -04:00
Jeremiah Lowin
d39f787537 rename mount -> import 2025-04-15 13:01:36 -04:00
Jeremiah Lowin
c2ca6e1fa2 Fix matching logic 2025-04-15 11:06:51 -04:00