Skip to content

Issue 4055 #4069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Issue 4055 #4069

wants to merge 1 commit into from

Conversation

wilocu
Copy link
Contributor

@wilocu wilocu commented Aug 7, 2025

#4055

I believe the issue occurs because MCP server beans aren't created when Spring Boot lazy initialization is enabled, causing NPE when accessing MCP
endpoints.

Changes

  • Added @Lazy(false) to force eager initialization of MCP server beans
  • Added tests to verify lazy initialization compatibility

This seems to resolve the reported issue while maintaining existing functionality.

Test plan

  • Added lazy initialization tests
  • Verified existing tests still pass
  • Confirmed fix appears to resolve the NPE

3 files were modified:

  1. McpServerAutoConfiguration.java - Added @lazy(false) annotations to force eager initialization
  2. McpServerAutoConfigurationIT.java - Added lazy initialization tests
  3. McpWebMvcServerAutoConfigurationIT.java - Added WebMvc transport compatibility test

Signed-off-by: Mattia Pasetto [email protected]

I am still pretty new to contributions, please double check and let me know of any errors.

The issue occurred because MCP server beans (McpSyncServer/McpAsyncServer) were not
being created when Spring Boot lazy initialization was enabled. This caused:
- Missing tool registration logs
- Null sessionFactory in transport providers
- NPE when accessing MCP endpoints (/sse, /mcp/message)

Changes:
- Added @lazy(false) to McpSyncServer and McpAsyncServer beans to force eager initialization
- Added comprehensive tests for lazy initialization compatibility
- Verified existing functionality remains unchanged

The fix ensures MCP servers work correctly regardless of lazy initialization settings,
maintaining backward compatibility while resolving the reported issue.

Signed-off-by: Mattia Pasetto <[email protected]>
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