Is there interest in generating ToolOptions from struct tags/annotations? #328
Replies: 1 comment
-
I'm not sure if it is the job of the SDK to provide this level of abstraction. I think it is better to implement something like this for the specific MCP server implementation. I maintain an MCP server where I have something like this to automatically read a JSON file and convert it to tool properties. It is very opinionated parsing from JSON to tool options to be extracted into an SDK. I think the fact that you have easily do this with Go standard libraries and the mcp-go SDK is good enough. Unless you or others have strong reasons why this might be useful in general. Also TBH given the velocity at which this project is being developed and the MCP spec is being improved, this would be a very low priority feature with priority being given to spec compliance and bug fixes and developer experience. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a helper function I use to generate the mcp config based on struct tags (mcp in this case) that I'd be happy to PR if theres interest! This works well for simple tools (though if multiline comments/descriptions are needed it doesnt work as well in that you still need to provide additional Tool options or have really long struct tags).
Below is the rough proposal for what the api might look like (slight tweaks from my helper library to generalize to the package name/match local style):
Given a struct like:
registration might look like
Which under the hood would be invoking some reflection magic to grab/parse the tags into the appropriate json schema
Beta Was this translation helpful? Give feedback.
All reactions