-
Notifications
You must be signed in to change notification settings - Fork 401
Closed
Description
Issue Description
Currently, tool functions can only return String directly or implement the IntoCallToolResult trait for custom types. This limits the flexibility and requires unnecessary boilerplate.
Suggested Enhancement
Allow tool functions to return any serializable type by:
- Making
#[tool(param)]attribute optional on function parameters - Automatically converting return values to
CallToolResultusing serde serialization
Benefits
- Easier function definitions
- Cleaner test code
- More intuitive API
- Less boilerplate implementation
- Better type safety
Example (Current vs Proposed)
Current approach:
#[tool(description = "Calculate sum")]
fn sum(&self, #[tool(param)] a: i32, #[tool(param)] b: i32) -> String {
(a + b).to_string()
}Proposed approach:
#[tool(description = "Calculate sum")]
fn sum(&self, a: i32, b: i32) -> i32 {
a + b
}This enhancement would make the API more ergonomic while maintaining all current functionality.
Metadata
Metadata
Assignees
Labels
No labels