Jeremiah Lowin Claude commited on
Commit
a7436dc
·
1 Parent(s): da5f976

Update client.mdx

Browse files

Co-Authored-By: Claude <claude@users.noreply.github.com>

Files changed (1) hide show
  1. docs/clients/client.mdx +24 -0
docs/clients/client.mdx CHANGED
@@ -234,6 +234,30 @@ The standard client methods return user-friendly representations that may change
234
  * **`list_prompts()`**: Retrieves available prompt templates.
235
  * **`get_prompt(name: str, arguments: dict[str, Any] | None = None)`**: Retrieves a rendered prompt message list.
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  ### Raw MCP Protocol Objects
238
 
239
  <VersionBadge version="2.2.7" />
 
234
  * **`list_prompts()`**: Retrieves available prompt templates.
235
  * **`get_prompt(name: str, arguments: dict[str, Any] | None = None)`**: Retrieves a rendered prompt message list.
236
 
237
+ <VersionBadge version="2.9.0" />
238
+
239
+ **Automatic Argument Serialization**: When calling prompts with complex arguments, the FastMCP client automatically serializes non-string values to JSON strings as required by the MCP specification. This allows you to pass typed objects directly while maintaining protocol compliance.
240
+
241
+ ```python
242
+ from dataclasses import dataclass
243
+
244
+ @dataclass
245
+ class UserData:
246
+ name: str
247
+ age: int
248
+
249
+ async with client:
250
+ # You can pass complex objects directly
251
+ result = await client.get_prompt("analyze_user", {
252
+ "user": UserData(name="Alice", age=30), # Automatically serialized to JSON
253
+ "preferences": {"theme": "dark"}, # Dict serialized to JSON string
254
+ "scores": [85, 92, 78], # List serialized to JSON string
255
+ "simple_name": "Bob" # Strings passed through unchanged
256
+ })
257
+ ```
258
+
259
+ The client handles the serialization automatically using `pydantic_core.to_json()` for consistent formatting, while the server can deserialize these JSON strings back to the expected types if using FastMCP's server-side type conversion.
260
+
261
  ### Raw MCP Protocol Objects
262
 
263
  <VersionBadge version="2.2.7" />