Add RMCP interop functions to FunctionDeclaration - #66
Conversation
|
It looks like the format check failed. Could you run cargo fmt and push the changes again? |
There was a problem hiding this comment.
Pull request overview
Adds RMCP interop APIs to FunctionDeclaration so callers can set pre-parsed parameter/response JSON schema objects directly.
Changes:
- Add
with_parsed_parameters(Value)builder for settingparametersfrom an already-parsed JSON value - Add
with_parsed_response(Value)builder for settingresponsefrom an already-parsed JSON value
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub fn with_parsed_parameters(mut self, parameters: Value) -> Self { | ||
| self.parameters = Some(parameters.clone()); | ||
| self | ||
| } |
There was a problem hiding this comment.
Both methods take ownership of Value, but still .clone() it before storing. This adds unnecessary allocations/copies; assign the moved value directly (e.g., Some(parameters) / Some(response)).
| pub fn with_parsed_response(mut self, response: Value) -> Self { | ||
| self.response = Some(response.clone()); | ||
| self | ||
| } |
There was a problem hiding this comment.
Both methods take ownership of Value, but still .clone() it before storing. This adds unnecessary allocations/copies; assign the moved value directly (e.g., Some(parameters) / Some(response)).
| self.parameters = Some(generate_parameters_schema::<Parameters>()); | ||
| self | ||
| } | ||
| /// Sets the parameters for the function using a raw json_serde::Value. Allows interop with RMCP Tool structs. |
There was a problem hiding this comment.
The docs reference json_serde::Value, but the code uses Value (commonly serde_json::Value). Consider updating the wording to match the actual type/source, and fix the missing space after /// on line 263 for consistent rustdoc formatting.
| self.response = Some(generate_parameters_schema::<Response>()); | ||
| self | ||
| } | ||
| ///Sets the response schema for the function using a raw json_serde::Value. Allows interop with RMCP Tool structs. |
There was a problem hiding this comment.
The docs reference json_serde::Value, but the code uses Value (commonly serde_json::Value). Consider updating the wording to match the actual type/source, and fix the missing space after /// on line 263 for consistent rustdoc formatting.
Fixes #65 by adding functions to allow setting of parsed parameter and response schema objects.