Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/google/cloud/mcp/McpToolboxClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,19 @@ interface Builder {
*
* @param preProcessor The pre-processor to add.
* @return The builder instance.
* @deprecated Use orchestration framework callbacks instead of client-level pre-processors.
*/
@Deprecated
Builder preProcessor(ToolPreProcessor preProcessor);

/**
* Adds a global post-processor that will be applied to all tools loaded by this client.
*
* @param postProcessor The post-processor to add.
* @return The builder instance.
* @deprecated Use orchestration framework callbacks instead of client-level post-processors.
*/
@Deprecated
Builder postProcessor(ToolPostProcessor postProcessor);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.CompletableFuture;

/** Implementation of the {@link McpToolboxClient.Builder} interface. */
@SuppressWarnings("deprecation")
public final class McpToolboxClientBuilder implements McpToolboxClient.Builder {
private String baseUrl;
private String apiKey;
Expand Down Expand Up @@ -70,6 +71,7 @@ public McpToolboxClient.Builder credentialsProvider(CredentialsProvider credenti
return this;
}

@Deprecated
@Override
public McpToolboxClient.Builder preProcessor(ToolPreProcessor preProcessor) {
if (preProcessor != null) {
Expand All @@ -78,6 +80,7 @@ public McpToolboxClient.Builder preProcessor(ToolPreProcessor preProcessor) {
return this;
}

@Deprecated
@Override
public McpToolboxClient.Builder postProcessor(ToolPostProcessor postProcessor) {
if (postProcessor != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.logging.Logger;

/** Default implementation using Java 11 HttpClient. */
@SuppressWarnings("deprecation")
public final class McpToolboxClientImpl implements McpToolboxClient {

/** Logger for logging messages. */
Expand Down Expand Up @@ -78,10 +79,9 @@ public McpToolboxClientImpl(final Transport clientTransport) {
* Constructs a new McpToolboxClientImpl.
*
* @param transport The underlying MCP transport layer.
* @param headers Fallback headers for deprecated constructor compatibility.
* @param credentialsProvider Fallback provider for deprecated constructor compatibility.
* @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?

public McpToolboxClientImpl(
Transport transport, Map<String, String> headers, CredentialsProvider credentialsProvider) {
this(transport, headers, credentialsProvider, null, null);
Expand Down Expand Up @@ -161,14 +161,17 @@ private static CredentialsProvider apiKeyToProvider(final String apiKey) {
}

/**
* Primary constructor for McpToolboxClientImpl.
* Constructs a new McpToolboxClientImpl with pre- and post-processors.
*
* @param transport The underlying MCP transport layer.
* @param headers Default HTTP headers.
* @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.

* Pre- and post-processors are deprecated in favor of orchestration framework callbacks.
*/
@Deprecated
public McpToolboxClientImpl(
Transport transport,
Map<String, String> headers,
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/google/cloud/mcp/tool/Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Represents a loaded tool ready to be invoked. Handles parameter binding, authentication token
* resolution, and input validation.
*/
@SuppressWarnings("deprecation")
public class Tool {
private final String name;
private final ToolDefinition definition;
Expand Down Expand Up @@ -183,7 +184,9 @@ private static ToolDefinition pruneParameter(
*
* @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?

*/
@Deprecated
public Tool addPreProcessor(final ToolPreProcessor processor) {
List<ToolPreProcessor> newPre = new ArrayList<>(this.preProcessors);
newPre.add(processor);
Expand All @@ -202,7 +205,9 @@ public Tool addPreProcessor(final ToolPreProcessor processor) {
*
* @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?

*/
@Deprecated
public Tool addPostProcessor(final ToolPostProcessor processor) {
List<ToolPostProcessor> newPost = new ArrayList<>(this.postProcessors);
newPost.add(processor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@

import java.util.concurrent.CompletableFuture;

/** A functional interface for post-processing tool results after invocation. */
/**
* A functional interface for post-processing tool results after 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)
* for post-invocation interception.
*/
@Deprecated
@FunctionalInterface
public interface ToolPostProcessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/** A functional interface for pre-processing tool inputs before invocation. */
/**
* 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?

* for pre-invocation interception.
*/
@Deprecated
@FunctionalInterface
public interface ToolPreProcessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void testCustomHttpClientAndExecutor() {
}

@Test
@SuppressWarnings("deprecation")
void testProcessorsConfiguration() {
ToolPreProcessor pre = (name, args) -> CompletableFuture.completedFuture(args);
ToolPostProcessor post = (name, result) -> CompletableFuture.completedFuture(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void testEnsureInitialized_withNotificationSerializationFailure() throws Excepti
assertTrue(ex.getCause().getMessage().contains("Simulated notification serialization failure"));
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "deprecation"})
@Test
void testClientPrePostProcessorsPropagation() throws Exception {
Transport mockTransport = mock(Transport.class);
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/google/cloud/mcp/tool/ToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void testToolDefinitionHints() {
}

@Test
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "deprecation"})
void testExecute_withPreAndPostProcessors_modifiesArgsAndResult() throws Exception {
// Arrange
Map<String, Object> initialArgs = new HashMap<>();
Expand Down Expand Up @@ -343,6 +343,7 @@ void testExecute_withPreAndPostProcessors_modifiesArgsAndResult() throws Excepti
}

@Test
@SuppressWarnings("deprecation")
void testExecute_preProcessorException_failsFutureWithoutInvokingClient() {
// Arrange
Map<String, Object> initialArgs = new HashMap<>();
Expand Down
Loading