fastmcp/docs
zzstoatzz 7d2f1f9671 Fix: Prompt arg handling & docs for #541
Addresses #541:
- Server now auto-deserializes JSON string args (list, dict, BaseModel) for prompts. This simplifies server-side prompt logic by reducing boilerplate `json.loads()` calls.
- Docs updated to clarify `list_resource_templates` usage for templatized resources.
- Docs updated to require client-side `json.dumps()` for complex `get_prompt` arguments, resolving the original Pydantic error.
- Adds a new example (`examples/dynamic_story_prompt/`) demonstrating the server-side deserialization benefit and correct client-side serialization.

Closes #541.

---
Notes for Reviewers:
- **Server-Side Auto-Deserialization:** This change introduces a "magic" `json.loads()` in `Prompt.render`. This is an intentional DX improvement. It only triggers for `str` inputs targeting `list`, `dict`, or `BaseModel` type hints. If `json.loads()` fails (e.g., malformed JSON), the original string is passed to Pydantic's `validate_call`, ensuring robust error handling. This avoids boilerplate in user prompt functions.
- **Client `get_prompt()` Return Value:** The `examples/dynamic_story_prompt/story_client.py` parses the result of `client.get_prompt()` by iterating and looking for a `('messages', ...)` tuple. This reflects the observed behavior of the current `client.get_prompt()`. This commit does *not* change `client.get_prompt()`'s return behavior; the example merely adapts to it. A separate discussion might be warranted for potentially simplifying `client.get_prompt()`'s return signature in the future.
2025-05-27 19:38:32 -05:00
..
assets Update readmeUpdate README 2024-11-30 19:30:36 -05:00
clients Fix: Prompt arg handling & docs for #541 2025-05-27 19:38:32 -05:00
deployment Add notes about uv and claude desktop 2025-05-25 13:57:21 -04:00
getting-started Split into routemapfn and mcpcomponentfn 2025-05-23 11:03:57 -04:00
patterns Ensure content-length is always stripped from client headers 2025-05-24 07:38:34 -04:00
servers Fix: Prompt arg handling & docs for #541 2025-05-27 19:38:32 -05:00
snippets update version badges 2025-04-24 20:27:27 -04:00
docs.json Add support for RouteMap tags, update docs 2025-05-22 21:59:16 -04:00
style.css update version badges 2025-04-24 20:27:27 -04:00