📝 Add docstrings to issue-345-withany
#619
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive godoc comments to the new
WithAny
function and related code in PR #618, improving documentation for the flexible tool properties feature.Problem
PR #618 introduced the
WithAny
function for flexible tool properties but lacked comprehensive godoc documentation. The new function and updated example code needed proper documentation to help developers understand how to use the any-type property feature.Solution
Added detailed godoc comments following Go documentation conventions to:
WithAny
function inmcp/tools.go
WithArray
function (expanded its existing docstring)Properties
function (clarified its purpose)main
function inexamples/typed_tools/main.go
typedGreetingHandler
function (documenting the newAnyData
field behavior)Changes Made
WithAny
function explaining its purpose, behavior, and how it handles the required flagWithArray
godoc to better describe its behavior with PropertyOption functions and the required field handlingProperties
function godoc to explain it sets the "properties" map for object schemasmain
function in typed_tools example, explaining the server setup and tool registrationtypedGreetingHandler
function, including error handling and the newAnyData
parameter formattingBreaking Changes
Testing
How to verify it
go test ./... -race
- All tests passgolangci-lint run
- 0 issues foundgo test -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v '/examples/' | grep -v '/testdata' | grep -v '/mcptest' | grep -v '/server/internal/gen')
- Coverage maintained (67-80% across packages)Checklist
Additional Notes
This is a documentation-only PR generated by CodeRabbit AI bot in response to a request from @otaviof on PR #618. The changes improve code documentation without modifying any functionality. Since this only adds documentation comments and doesn't change user-facing behavior, no changelog entry is required.