Commit graph

25 commits

Author SHA1 Message Date
Jeremiah Lowin
c397e68d39
Update ty ignore comments for 0.0.25 compatibility (#3614) 2026-03-24 20:26:26 -04:00
Jeremiah Lowin
360c9c31e5
fix: resolve Pyright "Module is not callable" on @tool, @resource, @prompt decorators (#3540)
* pin pydantic-monty to 0.0.8

* rename tool/prompt/resource base modules to avoid decorator name shadow

* add sys.modules shims for old submodule import paths

* preserve original module paths in deprecation warnings

* clarify when sys.modules shims can be removed
2026-03-17 18:11:42 -04:00
Jeremiah Lowin
610551c7b6
Split large test files to comply with loq line limit (#3328) 2026-02-28 11:21:11 -05:00
Jeremiah Lowin
3f2090f10a
Fix non-serializable state lost between middleware and tools (#3234)
* Fix non-serializable state lost between middleware and tools

Inherit _request_state dict from parent Context in __aenter__ so
middleware and tool contexts share the same in-memory state.

Closes #3228

* chore: Update SDK documentation

---------

Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-02-19 10:57:59 -05:00
Jeremiah Lowin
a2efd686a9
Normalize repo references to PrefectHQ/fastmcp casing (#3218) 2026-02-18 14:51:18 -05:00
Jeremiah Lowin
9b248a15b3
Update repository references for transfer to prefecthq (#3207)
* Update repository references from jlowin/fastmcp to prefecthq/fastmcp

* Retrigger CI after repo transfer

* chore: Update SDK documentation

* Only run deep triage on bug issues for jlowin

---------

Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
2026-02-18 10:33:56 -05:00
Jeremiah Lowin
d8ab493664
Add session-specific visibility control via Context (#2917) 2026-01-18 22:31:06 -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
fc19f1f8de
Add task_meta parameter to read_resource() for explicit task control (#2750) 2025-12-26 12:59:01 -05:00
Jeremiah Lowin
648684d2bb
Introduce ResourceResult as canonical resource return type (#2734) 2025-12-25 21:21:55 -05:00
Jeremiah Lowin
b05801d66f
Consolidate execution method chains into single public API (#2728) 2025-12-25 10:38:12 -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
19fdac7b02
Refactor provider execution: components own their execution (#2663)
* Add test_custom_subclass_tasks.py

* Refactor provider execution: delegate to middleware via wrapper components

- Remove execution methods (call_tool, read_resource, etc.) from Provider base
- Add FastMCPProvider* wrapper classes that delegate to child server middleware
- Move task routing to Tool._run() using contextvars (_task_metadata, _tool_call_key)
- Add convert_to_tool_result(result, output_schema) utility for Docket results
- Add convert_to_prompt_result() utility for prompt task results
- Pass namespaced key via add_to_docket(name=) for mounted tool lookup

* Standardize add_to_docket() with fn_key/task_key parameters

All components now use explicit fn_key (function lookup) and task_key
(result storage) parameters instead of relying on implicit key handling.
This fixes mounted component task execution where the MCP-visible key
differs from the Docket-registered function name.

* Add middleware chain tests for three-level mount hierarchy

Tests verify middleware runs at parent, child, and grandchild levels
for tools, resources, prompts, and resource templates.

* WIP: Provider refactor - unified submit_to_docket, template _read() in progress

Work in progress on refactoring execution to use component _read()/_run()/_render() methods.
Template background tasks not yet working - needs fix for Docket key lookup.

* Fix conversion functions to take full component for attribute access

Pass Tool/Prompt/Resource/Template to conversion functions instead of
individual attributes, ensuring access to serializer, output_schema,
mime_type, etc. Also fixes mixed-content output schema validation.

* Refactor: unified convert_result() methods and check_background_task helper

- Add convert_result() instance methods to all component types (Tool, Prompt, Resource, ResourceTemplate)
- Extract duplicated task routing logic into check_background_task() helper
- Fix type annotations on FastMCPProviderResource.read() and FastMCPProviderPrompt.render()
- Update protocol.py to use component.convert_result() uniformly

* Update tests to use namespace= instead of deprecated prefix= parameter
2025-12-21 15:03:24 -05:00
Jeremiah Lowin
ba1ba86a64
Support initialize requests in middleware (#1546) 2025-10-05 10:20:13 -04:00
Jeremiah Lowin
df284ba824
Add unit tests and docs for denying tool calls with middleware (#1333) 2025-08-01 16:55:42 -04:00
Jeremiah Lowin
6fdb8d6a1c
Add test for proxy tags visibility (#1302) 2025-07-30 11:01:07 -04:00
Jeremiah Lowin
07655e6620
Fix typing, add tests for tool call middleware (#1269) 2025-07-25 18:46:48 -04:00
Jeremiah Lowin
767de312f9
Fix middleware list result types (#1125)
* Catch more openapi changes

* Simplify middleware list operations to use lists directly

- Updated middleware signatures to work with list[Tool], list[Resource], etc instead of wrapper objects
- Removed unnecessary ListToolsResult, ListResourcesResult wrapper types
- Updated documentation to show simpler list-based filtering pattern
- Added tests for list-based middleware filtering

Closes #1121

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

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-11 18:04:20 -04:00
Jeremiah Lowin
6b2df6be51 Fix middleware tests 2025-06-26 17:57:30 -04:00
Jeremiah Lowin
0beb79d11a Minor updates 2025-06-19 15:28:55 -04:00
Jeremiah Lowin
703589e6f5 Add proxy middleware test 2025-06-19 15:00:11 -04:00
Jeremiah Lowin
35e13ef9bf Update resource manager 2025-06-19 12:22:14 -04:00
Jeremiah Lowin
a42c0c40b0 Add middleware for all current handlers 2025-06-18 21:41:28 -04:00
Jeremiah Lowin
c183e3a99c Updated list_tools 2025-06-18 21:17:38 -04:00
Jeremiah Lowin
0702bad1c2 Add single-component methods 2025-06-18 19:47:19 -04:00