Returning serde_json::Value is not allowed? #913
Unanswered
SteveL-MSFT
asked this question in
Q&A
Replies: 1 comment
-
|
Found a workaround: #[derive(Serialize, JsonSchema)]
#[serde(untagged)]
pub enum ExpressionResult {
Value(serde_json::Value),
}
#[derive(Serialize, JsonSchema)]
pub struct ExpressionResponse {
pub result: ExpressionResult,
}This works, seems unnecessary, but end result is equivalent. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Question Category
Your Question
I have a tool that will return a value that is any serde_json::Value. So I define my struct like this:
This compiles fine, but using MCP Inspector. When I list tools I get this error:
If I change it to a String and convert the Value to a string, it works fine. However, this also means potential number values or objects, etc... will just be strings. I'd rather not return it as a JSON string since it seems unnatural to have the resulting JSON contain a property that contains a JSON string. What's the right way to do this? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions