Skip to content

refactor: deprecate tool pre and post processing hooks to align with cross-SDK architecture - #89

Open
stenalpjolly wants to merge 1 commit into
googleapis:mainfrom
stenalpjolly:stenalpjolly/stenalpjolly_deprecate-pre-post-processors
Open

stenalpjolly wants to merge 1 commit into
googleapis:mainfrom
stenalpjolly:stenalpjolly/stenalpjolly_deprecate-pre-post-processors

Conversation

@stenalpjolly

Copy link
Copy Markdown
Contributor

Summary

This pull request marks the tool pre- and post-processing execution hook interfaces (ToolPreProcessor, ToolPostProcessor), builder methods (McpToolboxClient.Builder.preProcessor, postProcessor), tool registration methods (Tool.addPreProcessor, addPostProcessor), and the 5-argument McpToolboxClientImpl constructor as @Deprecated to align the Java SDK with the cross-language MCP Toolbox SDK architecture (such as Python PR #539) while preserving full v1.0.0 semantic versioning backward compatibility.

Expectation & Implementation

  • Expectation:
    • Across the official MCP Toolbox SDK ecosystem (Python, Go, JS/TS), client-side tool execution hooks have been removed or omitted in favor of orchestration framework callbacks (such as Google ADK, LangChain4j, or Spring AI advisors/interceptors) to avoid duplicating interception pipelines and to keep the core SDK lightweight.
    • Because mcp-toolbox-sdk-java v1.0.0 was released with PR feat: add pre & post processing hooks for tools #58's classes and methods in the public API, hard deletion would break SemVer compatibility. Marking these APIs as @Deprecated guides users toward framework-level callbacks while maintaining 100% binary and source compatibility for 1.x callers.
  • Implementation:
    • Annotated ToolPreProcessor and ToolPostProcessor with @Deprecated and @deprecated Javadoc tags.
    • Annotated McpToolboxClient.Builder.preProcessor(ToolPreProcessor) and postProcessor(ToolPostProcessor) (and their implementations in McpToolboxClientBuilder) with @Deprecated.
    • Annotated Tool.addPreProcessor(ToolPreProcessor) and Tool.addPostProcessor(ToolPostProcessor) with @Deprecated.
    • Annotated the 5-argument constructor McpToolboxClientImpl(Transport, Map, CredentialsProvider, List<ToolPreProcessor>, List<ToolPostProcessor>) with @Deprecated and un-deprecated the 3-argument constructor McpToolboxClientImpl(Transport, Map, CredentialsProvider) so callers instantiating McpToolboxClientImpl without deprecated hooks have a clean, non-deprecated constructor.
    • Added @SuppressWarnings("deprecation") to internal classes and unit test methods that exercise deprecated hook functionality so the build compiles with zero deprecation warnings.

Test cases

  • Verified all existing unit tests in ToolTest, McpToolboxClientBuilderTest, and McpToolboxClientImplTest continue to pass and validate deprecated hook execution paths for backward compatibility.
  • Executed mvn com.spotify.fmt:fmt-maven-plugin:check javadoc:javadoc checkstyle:check test under JDK 17.
  • Confirmed 130 passing unit tests with 0 failures, 0 Checkstyle violations, 0 Javadoc errors, and 100.00% instruction/branch coverage on modified classes (Tool, McpToolboxClientBuilder, McpToolboxClientImpl).

Acceptance criteria

  • ToolPreProcessor, ToolPostProcessor, and corresponding builder/tool registration methods are annotated with @Deprecated and documented with @deprecated Javadocs.
  • McpToolboxClientImpl(Transport, Map, CredentialsProvider) is un-deprecated as the clean constructor when pre/post processors are omitted.
  • Zero Checkstyle violations (checkstyle:check) and zero formatting deviations (fmt-maven-plugin:check).
  • All 130 unit tests pass with 100% coverage on modified classes.

Breaking changes

None. All deprecated methods and interfaces remain fully functional for 1.x backward compatibility.

TAG=agy
CONV=8a6d2e06-1e32-45cb-84cc-9ffe9dfd9e98

@stenalpjolly
stenalpjolly requested a review from a team as a code owner September 16, 2026 09:27
@stenalpjolly

Copy link
Copy Markdown
Contributor Author

/gcbrun

@anubhav756 anubhav756 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation for orchestration pre and post processing to match the other SDKs, here https://mcp-toolbox.dev/documentation/configuration/pre-post-processing/

* @param headers Default HTTP headers.
* @param credentialsProvider Provider for credentials.
*/
@Deprecated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this deprecation?

* @param credentialsProvider Provider for credentials.
* @param preProcessors List of pre-processors.
* @param postProcessors List of post-processors.
* @deprecated Use {@link #McpToolboxClientImpl(Transport, Map, CredentialsProvider)} instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we not remove the deprecation from this constructor? I am a bit confused about whether we want to deprecate this or not.

*
* @param processor The pre-processor to add.
* @return The tool instance.
* @deprecated Use orchestration framework callbacks instead of tool-level pre-processors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this written the other way around?

*
* @param processor The post-processor to add.
* @return A new tool instance with the post-processor added.
* @deprecated Use orchestration framework callbacks instead of tool-level post-processors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, is this written the other way around?

* A functional interface for pre-processing tool inputs before invocation.
*
* @deprecated Tool execution hooks are deprecated in the core SDK to align with cross-SDK
* architecture. Use orchestration framework callbacks (e.g., ADK, LangChain4j, or Spring AI)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: Once we create the pre/post processing doc, can we link that here?

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.

2 participants