mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-26 23:44:17 +02:00
Fix exclude_args with non-serializable types
Fixes issue #2431 where exclude_args fails when excluded parameters have non-serializable types (e.g., ServerSession). The fix excludes parameters from function annotations before Pydantic tries to serialize them. Also adds deprecation notice that exclude_args will be deprecated in FastMCP 2.14 in favor of dependency injection.
This commit is contained in:
parent
be90d6eb60
commit
52100b08ff
5 changed files with 105 additions and 3 deletions
|
|
@ -354,7 +354,9 @@ Field provides several validation and documentation features:
|
|||
|
||||
You can exclude certain arguments from the tool schema shown to the LLM. This is useful for arguments that are injected at runtime (such as `state`, `user_id`, or credentials) and should not be exposed to the LLM or client. Only arguments with default values can be excluded; attempting to exclude a required argument will raise an error.
|
||||
|
||||
Example:
|
||||
**Note:** `exclude_args` will be deprecated in FastMCP 2.14 in favor of dependency injection with `Depends()` for better lifecycle management and more explicit dependency handling. `exclude_args` will continue to work until then.
|
||||
|
||||
Example with `exclude_args`:
|
||||
|
||||
```python
|
||||
@mcp.tool(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue