fix(params): accept native integer types for numeric tool parameters - #3411
Open
harish-gaggar wants to merge 1 commit into
Open
harish-gaggar wants to merge 1 commit into
harish-gaggar wants to merge 1 commit into
Conversation
MCP clients sometimes send JSON integers as int or json.Number rather than float64, which caused RequiredInt to reject valid issue_number values before any GitHub API call. Fixes github#2807
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Accept native integer and
json.Numbervalues in shared numeric parameter coercion so MCP clients that send JSON integers (not onlyfloat64) can call issue tools successfully.Why
Fixes #2807
Some MCP hosts pass
issue_numberas a JSON integer (int/json.Number).RequiredIntonly acceptedfloat64and numeric strings, so valid calls failed before reaching the GitHub API.What changed
toInt/toInt64to handle native integer types andjson.Numberwithout float64 round-trip precision loss.params_test.goand a regression case inissues_test.goforissue_readwithintissue_number.MCP impact
Tool names and input schemas are unchanged; only argument parsing is more permissive for numeric fields.
Prompts tested (tool changes only)
N/A — no tool schema changes. Regression covered by unit/handler tests for
issue_readwith integerissue_number.Security / limits
Tool renaming
Lint & tests
./script/lintgo test ./pkg/github -run 'Test_RequiredInt|Test_RequiredBigInt|Test_GetIssue' -count=1Docs