feat: introduce SDK exception hierarchy and tool parameter copying#81
Open
stenalpjolly wants to merge 1 commit into
Open
feat: introduce SDK exception hierarchy and tool parameter copying#81stenalpjolly wants to merge 1 commit into
stenalpjolly wants to merge 1 commit into
Conversation
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
This pull request introduces the core exception hierarchy for the MCP Toolbox Java SDK (
McpToolboxException,McpProtocolException,McpTransportException, andToolExecutionException) and updatesJsonRpcnamespace structures. Additionally, it enhancesToolexecution to deep-copy default list parameters and properly unwrap execution exceptions intoMcpToolboxException.Expectation & Implementation
McpToolboxExceptionand subclasses) to distinguish between protocol failures (McpProtocolException), transport/HTTP status errors (McpTransportException), and tool invocation/validation failures (ToolExecutionException). Furthermore, default parameters of complex mutable types (such as lists) inTooldefinitions must be deep-copied when injected into arguments to prevent unintended mutations across executions.McpToolboxExceptionbase unchecked exception class.McpProtocolException,McpTransportException(with HTTP status code tracking), andToolExecutionExceptionextendingMcpToolboxException.JsonRpcto encapsulate protocol payload structures cleanly.Toolexecution logic (executeSync) to throwMcpToolboxExceptionwhen unwrapping futures and ensureddeepCopyproperly handlesListalongsideMap.Test cases
McpToolboxClientBuilderTestto verify all constructors ofMcpTransportException,McpToolboxException,McpProtocolException,ToolExecutionException, andMcpException.JsonRpcinstantiation via reflection inHttpMcpTransportTest.mvn clean test jacoco:report), confirming 100% line coverage acrosscom.google.cloud.mcp.exception.*and all existing tests passing.Acceptance criteria
McpToolboxException,McpProtocolException,McpTransportException,ToolExecutionException) are introduced undercom.google.cloud.mcp.exception.Tool.javathrowsMcpToolboxExceptionon synchronous execution failures and supports deep copying ofListdefault values.google-java-formatstandards under JDK 22+.com.google.cloud.mcp.exception.*.Breaking changes
TAG=agy
CONV=5010ae11-556f-4a11-aca4-d964083ca783