temporal-spring-ai: discover MCP clients by type, not by bean name#2859
Open
donald-pinckney wants to merge 3 commits intomasterfrom
Open
temporal-spring-ai: discover MCP clients by type, not by bean name#2859donald-pinckney wants to merge 3 commits intomasterfrom
donald-pinckney wants to merge 3 commits intomasterfrom
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
McpPlugin.getMcpClients() now calls ApplicationContext.getBeansOfType( McpSyncClient.class) instead of looking up the hard-coded bean name "mcpSyncClients". The unchecked cast is removed; discovered bean names are logged for easier debugging. Tests: McpPluginTest exercises three cases via Mockito — - two McpSyncClient beans discovered by type both reach McpClientActivityImpl; - zero beans leaves the worker queued for deferred registration, and afterSingletonsInstantiated handles "still no beans" cleanly; - beans that appear between initializeWorker and afterSingletonsInstantiated get picked up on the deferred attempt. build.gradle: spring-ai-mcp added as a testImplementation so tests can mock McpSyncClient directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Planning scratchpad — not part of the shipped artifact. Removed before merge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What was changed
McpPlugin.getMcpClients()now callsApplicationContext.getBeansOfType(McpSyncClient.class)instead of looking up the hard-coded bean name"mcpSyncClients". The unchecked cast from the old(List<McpSyncClient>) someObjectpath is gone; discovered bean names are logged alongside the count for easier debugging.New
McpPluginTestcovers three cases via Mockito:McpSyncClientbeans discovered by type both reachMcpClientActivityImpl.afterSingletonsInstantiatedhandles "still no beans" without crashing.initializeWorkerandafterSingletonsInstantiatedare picked up on the deferred attempt.build.gradlegainsspring-ai-mcpas atestImplementationso the tests can referenceMcpSyncClientdirectly for mocking. The main-scope dep stayscompileOnly; nothing changes for users who don't use MCP.Why?
The old bean-name lookup broke silently whenever Spring AI changed the name its MCP auto-configuration used (e.g. if
mcpSyncClientsever got renamed, or if sync-vs-async support got refactored). It also ignored user-definedMcpSyncClientbeans declared outside Spring AI's auto-configuration. Type-based discovery is more robust, works with arbitrary user configuration, and removes an unchecked cast that could have misbehaved at runtime if someone had registered a differently-typedListbean at that name.