Skip to content

Preserve decimal precision in MCP tool arguments - #420

Closed
sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/mcp-decimal-input-precision-20261004
Closed

sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/mcp-decimal-input-precision-20261004

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Fixes #419.

Enable USE_BIG_DECIMAL_FOR_FLOATS on the private mapper used by BetaMcp. Decimal and exponent-form arguments then reach the MCP client without rounding, overflow to infinity, or underflow to zero.

Integral parsing remains unchanged. Decimal values inside the outgoing CallToolRequest map are now BigDecimal rather than Double; they continue to serialize as JSON numbers. Public method signatures and result conversion are unchanged.

Nine regression cases check precise decimals, values beyond Double's exponent range, nested lists/objects, a large integer control, strings/booleans/null/empty objects, numeric serialization and malformed-input rejection before invoking the client.

Validation

  • New regressions on unchanged main: 6 failed, 3 passed.
  • Complete anthropic-java-mcp test module: 36 passed, none skipped.
  • MCP module formatKotlin, detektMain, detektTest and lintKotlin tasks passed.
  • git diff --check passed.
./gradlew :anthropic-java-mcp:test \
  :anthropic-java-mcp:detektMain :anthropic-java-mcp:detektTest \
  :anthropic-java-mcp:lintKotlin --max-workers=1 --no-parallel

Tested on macOS arm64 with JDK 21 and the repository's locked dependencies. The MCP client is mocked at its request boundary; live MCP transport and the full multi-module SDK suite were not run. Existing Gradle/JVM warnings remain. No dependency or workflow changes.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner October 4, 2026 21:41
@sylvesterkaczmarek

Copy link
Copy Markdown
Author

The complete MCP module tests pass locally (36 tests), along with its formatting and detekt checks. Could a maintainer approve the pending CI workflow?

@tomer-ant

Copy link
Copy Markdown
Contributor

Closing along with #419. The reasoning is in #419 (comment).

@tomer-ant tomer-ant closed this Oct 14, 2026
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.

MCP tool input conversion rounds decimals and overflows or underflows exponents

2 participants