Skip to content

fix(params): accept native integer types for numeric tool parameters - #3411

Open
harish-gaggar wants to merge 1 commit into
github:mainfrom
harish-gaggar:fix/issue-number-native-int-types
Open

harish-gaggar wants to merge 1 commit into
github:mainfrom
harish-gaggar:fix/issue-number-native-int-types

Conversation

@harish-gaggar

Copy link
Copy Markdown

Summary

Accept native integer and json.Number values in shared numeric parameter coercion so MCP clients that send JSON integers (not only float64) can call issue tools successfully.

Why

Fixes #2807

Some MCP hosts pass issue_number as a JSON integer (int / json.Number). RequiredInt only accepted float64 and numeric strings, so valid calls failed before reaching the GitHub API.

What changed

  • Extend toInt / toInt64 to handle native integer types and json.Number without float64 round-trip precision loss.
  • Add unit tests in params_test.go and a regression case in issues_test.go for issue_read with int issue_number.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

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_read with integer issue_number.

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR
  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with go test ./pkg/github -run 'Test_RequiredInt|Test_RequiredBigInt|Test_GetIssue' -count=1

Docs

  • Not needed
  • Updated (README / docs / examples)

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
@harish-gaggar
harish-gaggar requested a review from a team as a code owner October 4, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add_issue_comment, update_issue, and get_issue reject valid integer issue_number

1 participant