Fix: handle string-encoded number parameters from MCP clients #93
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/OpenSpec
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
RFC - Request For Comments
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
Status/Need More Info
hermes-attempted
hermes-needs-clarification
hermes-ready
hermes-review
hermes-wip
human-required
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
agentic-forges/forgejo-mcp!93
Loading…
Reference in a new issue
No description provided.
Delete branch "refs/pull/93/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
MCP clients (notably Claude Code) may serialize
number-typed tool parameters as JSON strings instead of JSON numbers. For example, a parameter declared asmcp.WithNumber("index", ...)arrives as"17"(string) rather than17(float64) inreq.GetArguments().The current code extracts all number parameters via bare Go type assertions:
When the value is a string, this assertion silently returns 0 (the
_discards theok=false). This causes cryptic errors like:...even though the caller passed
index: 17. The bug affects all 62 number parameter extractions across 9 operation files — every tool that acceptsindex,page,limit,comment_id,run_id, etc.Fix
New helper
to.Float64()(pkg/to/number.go) that handles multiple incoming types:float64— standard JSON number (pass-through)int,int64— alternative integer representationsstring— string-encoded number (parsed viastrconv.ParseFloat)nilor unexpected typesReplaced all 62 bare
.(float64)assertions withto.Float64()calls across:operation/issue/issue.go(17 occurrences)operation/pull/pull.go(16 occurrences)operation/pull/review.go(9 occurrences)operation/user/notification.go(6 occurrences)operation/actions/workflow_runs.go(4 occurrences)operation/repo/repo.go,branch.go,commit.go(6 occurrences)operation/search/search.go(2 occurrences)Adjusted
ok-based default patterns (e.g.,page/limitdefaults) to use zero-value checks (if page == 0 { page = 1 }) sinceto.Float64returns(float64, error)instead of(float64, bool).How to reproduce
Using Claude Code (or any MCP client that serializes numbers as strings):
Testing
go build ./...passes with zero errorslist_issue_comments,get_pull_request_by_index, andmerge_pull_request— all number parameters now work correctlyHey @dmikushin thanks for fixing this!!