Commit graph

45 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
Eric Robinson
9319a2c645 Support ImageContent and AudioContent in Message class
Message.content now accepts ImageContent and AudioContent in addition to
TextContent and EmbeddedResource, matching MCP's ContentBlock type. This
fixes ProxyPrompt.render() silently JSON-serializing image/audio content
instead of preserving it.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 17:12:29 -05:00
Bill Easton
b2f5551d22
Fix Field() handling in prompts (#3050)
Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
2026-02-01 21:28:44 -05:00
Jeremiah Lowin
8c471a499d
Run sync tools/resources/prompts in threadpool automatically (#2865) 2026-01-13 11:03:05 -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
1b723f302d
Decorators return functions instead of component objects (#2856) 2026-01-12 21:58:07 -05:00
Jeremiah Lowin
daa2dace2f
Add standalone decorators and eliminate fastmcp.fs module (#2832) 2026-01-10 12:16:35 -05:00
Jeremiah Lowin
61ebc64730
Introduce Message and PromptResult as canonical prompt types (#2738) 2025-12-25 22:16:26 -05:00
Jeremiah Lowin
f36b147f60
Unify component storage in LocalProvider (#2680) 2025-12-23 19:24:09 -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
d6654a2379
Add supports_tasks() method to replace string mode checks (#2664)
* Add supports_tasks() method to replace string mode checks

Consolidates task config mode checks into a readable method on TaskConfig.
Instead of `task_config.mode == "forbidden"` or `task_config.mode != "forbidden"`,
code now uses `task_config.supports_tasks()` for clearer intent.

Updated 20 instances across the codebase and added type assertions in tests
to resolve type checker warnings.

* Update test to match new error message
2025-12-21 15:41:46 -05:00
Jeremiah Lowin
8abd84bf1e
Revert "Revert "Refactor prompt behavior and add meta support (#2600)" (#2608)" (#2610)
This reverts commit f9e29cf58e.
2025-12-14 21:52:20 -05:00
Jeremiah Lowin
f9e29cf58e
Revert "Refactor prompt behavior and add meta support (#2600)" (#2608)
This reverts commit edb9d5ab65.
2025-12-13 14:57:50 -05:00
Jeremiah Lowin
edb9d5ab65
Refactor prompt behavior and add meta support (#2600)
* feat: add PromptResult as canonical internal type for prompts

Applies the same pattern as ResourceContent to prompts. PromptResult
wraps messages with description and meta. Public render() can return
either list[PromptMessage] or PromptResult (backwards compatible),
while private _render() always returns PromptResult.

* docs: fix incorrect PromptResult return type in example

* feat: add PromptResult canonical type with meta support

* fix: address PR #2600 review comments

Fixes test failures and code quality issues identified in PR review:

- Update 3 tests in test_server_interactions.py to access PromptResult.messages[0] instead of indexing directly
- Fix ProxyPromptManager to preserve meta field when converting GetPromptResult to PromptResult
- Fix ProxyPrompt.render() to return PromptResult instead of deprecated list[PromptMessage], preventing fastmcp tags from leaking into runtime meta
- Fix mask_error_details initialization to respect explicit False values
- Fix exception re-raising to preserve tracebacks (use bare raise instead of raise e)
- Update testing documentation to use pytest -n auto for parallel execution
2025-12-13 12:08:41 -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
William Easton
fe4f31c2c7
Enable more type checking rules (#1775) 2025-09-07 11:11:44 -04:00
Jeremiah Lowin
3fc2510110
Add meta parameter support to tools, resources, templates, and prompts decorators (#1294) 2025-07-29 17:16:05 -04:00
Jeremiah Lowin
228425e309
Avoid propagating logs (#1042)
* Avoid propagating logs

* Set up caplog for non-root loggers

* Update tests
2025-07-04 12:22:11 -04:00
Jeremiah Lowin
38036b1f42 Add automatic MCP list change notifications and client message handling
Implements comprehensive notification system for tools, resources, and prompts with automatic client updates and flexible message handlers.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 22:33:06 -04:00
Jeremiah Lowin
9714028cac Fix pyright type checking issues in tests
Add proper null checks and type assertions for prompt argument
handling in tests to satisfy pyright strict typing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 09:55:40 -04:00
Jeremiah Lowin
7114242e1e Update schema description wording for clarity
Change from 'Arguments must be strings conforming to this JSON schema'
to 'Provide as a JSON string matching the following schema' for clearer
instruction to LLMs about string format requirements.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 09:46:11 -04:00
Jeremiah Lowin
817018bf3b Add automatic JSON schema descriptions for non-string prompt arguments
- Fix ValueError -> PromptError for consistent error handling
- Add automatic JSON schema descriptions to non-string prompt arguments
- Include comprehensive tests for argument description enhancement
- Verify enhanced descriptions are visible via MCP protocol

This helps developers understand the expected string format for complex
types when calling prompts from MCP clients.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 09:38:57 -04:00
Jeremiah Lowin
7a793f4309 Fix prompt argument type annotation to support mixed typing
Updated FunctionPrompt.render() to accept dict[str, Any] instead of
dict[str, str | Context] to preserve the developer experience of
passing properly typed arguments while also supporting string-only
arguments from MCP clients.

The _convert_string_arguments method now intelligently handles both
scenarios:
- Already-typed arguments are passed through unchanged
- String arguments are converted to expected types when needed

This maintains backward compatibility while enabling MCP spec compliance.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-22 08:34:49 -04:00
Jeremiah Lowin
2e31b2704b Update tests 2025-06-19 14:05:19 -04:00
Jeremiah Lowin
9f8127bdfc Fix typing inference issue 2025-06-04 10:49:23 -04:00
Jeremiah Lowin
f1e3713fc6 Update test typing 2025-05-31 20:41:18 -04:00
Jeremiah Lowin
010170337f Ensure that tools/templates/prompts are compatible with callable objects 2025-05-23 18:53:55 -04:00
Jeremiah Lowin
53b067b4e7 Make error masking configurable 2025-05-22 09:08:16 -04:00
Jeremiah Lowin
82aa53e09b Refactor context to avoid unecessary passing 2025-05-06 21:24:29 -04:00
Jeremiah Lowin
2eb0e7c1b3 Ensure prompts return descriptions 2025-05-05 12:33:05 -04:00
Jeremiah Lowin
c449f1d697 Handle args/kwargs appropriately for various objects 2025-05-04 15:00:26 -04:00
Jeremiah Lowin
87031a62de Improve context injection type checks 2025-04-30 18:03:52 -04:00
Jeremiah Lowin
d27141a935 Refactor remote servers 2025-04-15 20:28:14 -04:00
Jeremiah Lowin
6e309e1354 Fix bug with duplicate behavior == ignore 2025-04-15 09:33:23 -04:00
Jeremiah Lowin
29b31573bc Fix typing issue 2025-04-13 21:45:17 -04:00
Jeremiah Lowin
3ea0685a17 Expand support for various method interactions 2025-04-13 21:39:19 -04:00
Jeremiah Lowin
f0d07e5f04 Add tags, improve duplicate import behavior 2025-04-12 11:20:25 -04:00
Jeremiah Lowin
96485c8dfe restore 1.x code
Attempting to subclass and monkeypatch was becoming too difficult; inflexibility between low-level types and the requirements of new high-level APIs requires the potential for breaking changes, even if they don't face users.
2025-04-09 11:54:42 -04:00
Jeremiah Lowin
728aeec293 Permit empty prefixes 2025-04-07 18:52:00 -04:00
Jeremiah Lowin
9b89715294 Support mounting FastMCPs as sub-servers 2025-04-07 17:54:55 -04:00
Jeremiah Lowin
ca810729d7 Use upstream FastMCP 2025-04-01 18:35:57 -04:00
Jeremiah Lowin
7331ec9712 Fix FileUrl 2024-12-03 13:49:50 -05:00
Jeremiah Lowin
5f58621f8b Add support for prompts 2024-11-30 18:06:00 -05:00
Jeremiah Lowin
5eec0b0d1d func → fn everywhere 2024-11-30 16:53:18 -05:00