Title: Bug: MCP clients sending numeric parameters as strings causes "Expected number, received string" validation errors · Issue #2044 · github/github-mcp-server · GitHub
Open Graph Title: Bug: MCP clients sending numeric parameters as strings causes "Expected number, received string" validation errors · Issue #2044 · github/github-mcp-server
X Title: Bug: MCP clients sending numeric parameters as strings causes "Expected number, received string" validation errors · Issue #2044 · github/github-mcp-server
Description: Description Some MCP clients (including Claude Desktop) send numeric tool arguments as JSON strings instead of numbers. For example, when calling pull_request_read with pullNumber, the client sends "5812" (string) instead of 5812 (number...
Open Graph Description: Description Some MCP clients (including Claude Desktop) send numeric tool arguments as JSON strings instead of numbers. For example, when calling pull_request_read with pullNumber, the client sends...
X Description: Description Some MCP clients (including Claude Desktop) send numeric tool arguments as JSON strings instead of numbers. For example, when calling pull_request_read with pullNumber, the client sends...
Opengraph URL: https://github.com/github/github-mcp-server/issues/2044
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: MCP clients sending numeric parameters as strings causes \"Expected number, received string\" validation errors","articleBody":"## Description\n\nSome MCP clients (including Claude Desktop) send numeric tool arguments as JSON strings instead of numbers. For example, when calling `pull_request_read` with `pullNumber`, the client sends `\"5812\"` (string) instead of `5812` (number). This causes JSON schema validation to fail with:\n\n```\nExpected number, received string\n```\n\nThe tool never executes because the MCP SDK's schema validation rejects the request before it reaches the handler.\n\n## Steps to Reproduce\n\n1. Use an MCP client that sends numeric parameters as strings (e.g., Claude Desktop)\n2. Call any tool that has a numeric parameter, such as `pull_request_read` with `pullNumber`\n3. The client sends: `{\"pullNumber\": \"5812\", \"owner\": \"...\", \"repo\": \"...\", \"method\": \"get\"}`\n4. Validation fails with `Expected number, received string` for `pullNumber`\n\n## Expected Behavior\n\nThe server should accept both `5812` (number) and `\"5812\"` (string) for numeric parameters, since MCP clients may serialize integers as strings. The `mapstructure.Decode` call in the handler already handles type coercion from `float64`/`string` to `int32`, but the request is rejected at the JSON schema validation layer before reaching the handler.\n\n## Root Cause Analysis\n\nThe JSON schema for numeric parameters is defined with `\"type\": \"number\"`:\n\n```go\n// pkg/github/pullrequests.go:52-55\n\"pullNumber\": {\n Type: \"number\",\n Description: \"Pull request number\",\n},\n```\n\nThe MCP SDK validates incoming arguments against this schema **before** the handler runs. When a client sends `\"5812\"` (string), the schema validator rejects it because `\"number\"` type does not accept strings.\n\n## Affected Parameters\n\nThis affects all `int32` parameters decoded via `mapstructure.Decode` across multiple tools:\n\n| File | Parameter | Struct Field |\n|------|-----------|-------------|\n| `pullrequests.go:1450` | `pullNumber` | `PullNumber int32` |\n| `pullrequests.go:1843` | `pullNumber` | `PullNumber int32` |\n| `pullrequests.go:1847` | `line` | `Line *int32` |\n| `pullrequests.go:1849` | `startLine` | `StartLine *int32` |\n| `discussions.go:314` | `discussionNumber` | `DiscussionNumber int32` |\n| `discussions.go:418` | `discussionNumber` | `DiscussionNumber int32` |\n| `issues.go:1805` | `issue_number` | `IssueNumber int32` |\n\n## Possible Solutions\n\n1. **Use `oneOf` or custom schema**: Define numeric parameters to accept both `\"number\"` and `\"string\"` types in the JSON schema, e.g., using `oneOf: [{type: \"number\"}, {type: \"string\", pattern: \"^\\\\d+$\"}]`\n\n2. **Pre-validation coercion**: Add a middleware or wrapper that coerces string-encoded numbers to actual numbers in the arguments map before schema validation runs\n\n3. **SDK-level fix**: If the MCP Go SDK supports custom validators or coercion hooks, configure the server to be lenient with numeric string inputs\n\n4. **Use `\"string\"` type with pattern**: Define these parameters as strings with a numeric pattern, and parse them in the handler (though this changes the API contract)\n\n## Environment\n\n- MCP Server: github-mcp-server (latest main)\n- MCP Client: Claude Desktop (but likely affects other clients too)\n- SDK: `github.com/modelcontextprotocol/go-sdk`","author":{"url":"https://github.com/yashhzd","@type":"Person","name":"yashhzd"},"datePublished":"2026-02-18T20:29:42Z","url":"https://github.com/github/github-mcp-server/issues/2044"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bfb7203f-a74d-762c-acd3-eaf537f51072 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B962:2BB917:6E7911:968122:6B068696 |
| html-safe-nonce | a41769fcc77fe41bfdfea405aade5d58d4b627468248d6f1ba43e50a39155f94 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTYyOjJCQjkxNzo2RTc5MTE6OTY4MTIyOjZCMDY4Njk2IiwidmlzaXRvcl9pZCI6IjM1MzU2NzU5MjA5MTQ3NDQ5ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 95a1f87602367631ba7410aeaa9eee991caca20253e6052cc097faf8696352a7 |
| hovercard-subject-tag | issue:3959653689 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/github-mcp-server/2044/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1ff5faeeb406817f71080d510238ab3b535e04a78452082a24b70640f0e88acd/github/github-mcp-server/issues/2044 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1ff5faeeb406817f71080d510238ab3b535e04a78452082a24b70640f0e88acd/github/github-mcp-server/issues/2044 |
| og:image:alt | Description Some MCP clients (including Claude Desktop) send numeric tool arguments as JSON strings instead of numbers. For example, when calling pull_request_read with pullNumber, the client sends... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yashhzd |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| turbo-cache-control | no-preview |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width