Skip to content

feat: add idiomatic sync client support and advanced builder options#67

Open
stenalpjolly wants to merge 2 commits into
googleapis:mainfrom
stenalpjolly:stenalpjolly_issue-6-idiomatic-sync
Open

feat: add idiomatic sync client support and advanced builder options#67
stenalpjolly wants to merge 2 commits into
googleapis:mainfrom
stenalpjolly:stenalpjolly_issue-6-idiomatic-sync

Conversation

@stenalpjolly

@stenalpjolly stenalpjolly commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements a thread-safe, protocol-agnostic synchronous wrapper client (McpToolboxSyncClient) that delegates blocking operations to the asynchronous client core. Introduces advanced configuration parameters on the client builder (connectTimeout, requestTimeout, logger), allowing users to fully customize connection handshakes, request timeouts, and telemetry logging, while maintaining strict architectural decoupling between the core client and transport layers.

Expectation & Implementation

  • Expectation: Users should have an idiomatic, blocking client for synchronous execution contexts (e.g., simple scripts or blocking server frameworks), and should be able to configure connection/request timeouts and custom loggers.
  • Implementation:
    • Created McpToolboxSyncClient and its default implementation HttpMcpToolboxSyncClient.
    • Added buildSync(), connectTimeout(), requestTimeout(), and logger() to McpToolboxClient.Builder and implemented them in McpToolboxClientBuilder.
    • Advanced parameters set on the builder are delegated directly to the protocol-agnostic HttpMcpTransport constructor, preserving a clean separation of concerns.
    • Handshake requests (initialize and notifications/initialized) are isolated from tool-specific overrides by applying clientHeaders + Authorization overrides, preventing tool-level headers from leaking into client handshakes.
    • Protocol range validation allows any status code in the 2xx range (e.g., 202 Accepted) to support flexible downstream servers.

Acceptance criteria

  • All remote CI build, lint, checkstyle, and JUnit tests must pass.
  • Line coverage on the new sync client (HttpMcpToolboxSyncClient.java) and newly modified classes must be verified to be 100.00%.
  • Sync client must correctly unwrap CompletionException / CancellationException and surface protocol-specific exceptions (McpToolboxException, IllegalArgumentException) directly to the caller.

Test cases

  • McpToolboxSyncClientTest.java: Added exhaustive unit tests ensuring 100.00% line coverage of all sync delegation methods and exception-translating branches.
  • McpToolboxClientBuilderTest.java: Added testMcpTransportExceptionConstructors to verify all constructors and status code getters on McpTransportException.
  • HttpMcpTransportTest.java: Added testInvokeTool_WithRequestTimeout to verify client-level HTTP request timeout limits propagation.
  • ToolTest.java: Verified recursive deep-copying of list-type parameter defaults inside Tool.java.
  • Total Tests: Staged and verified all 139 unit and integration tests locally, passing with 100% success.
  • 100% Line Coverage: Achieved perfect 100.00% line coverage on all modified/new files (HttpMcpToolboxSyncClient.java, McpToolboxSyncClient.java, McpTransportException.java, McpProtocolException.java, McpToolboxException.java, ToolExecutionException.java).

Breaking changes

None. All new methods and records are fully backward-compatible.

@stenalpjolly stenalpjolly requested a review from a team as a code owner June 17, 2026 14:02
@stenalpjolly stenalpjolly force-pushed the stenalpjolly_issue-6-idiomatic-sync branch 3 times, most recently from ec18fe5 to 7b0c143 Compare June 25, 2026 10:51
@stenalpjolly stenalpjolly force-pushed the stenalpjolly_issue-6-idiomatic-sync branch 5 times, most recently from e451965 to 1115da6 Compare June 25, 2026 14:47
@stenalpjolly stenalpjolly force-pushed the stenalpjolly_issue-6-idiomatic-sync branch from 1115da6 to 985b161 Compare June 25, 2026 15:12
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.

1 participant