-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Add annotation-based configuration support for MCP clients and servers #4245
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
Conversation
bfbe2f2
to
6944cf5
Compare
7e4304f
to
9373ec7
Compare
…servers - Introduce module for declarative MCP configuration - Create new mcp-annotations-spring module - Add annotation scanners to auto-discover MCP annotated beans and methods - Support MCP annotations: @mcptool, @McpResource, @McpPrompt, @McpComplete for servers - Support MCP annotations: @McpLogging, @McpSampling, @McpElicitation, @McpProgress for clients - Implement customizers to automatically register annotated specifications - Introduce McpAsyncAnnotationCustomizer and McpSyncAnnotationCustomizer for annotation-driven client configuration - Add Spring-aware annotation providers for both sync and async MCP operations - Include comprehensive integration tests for annotation-based MCP configuration - Update all MCP starter dependencies to include the new annotations module - Update BOM and parent POM to include mcp-annotations dependency version management - Include comprehensive integration test StreamableMcpAnnotationsIT demonstrating annotation usage - Move McpAsyncAnnotationCustomizer and McpSyncAnnotationCustomizer to annotations package - Add support for tool, resource, and prompt list changed notifications - New AsyncToolListChangedSpecification, AsyncResourceListChangedSpecification, AsyncPromptListChangedSpecification - New SyncToolListChangedSpecification, SyncResourceListChangedSpecification, SyncPromptListChangedSpecification - Wire list changed specifications in MCP client auto-configuration - Enhance annotation customizers with validation and logging - Prevent duplicate elicitation and sampling specs per client with proper error handling - Add comprehensive logging for all registered MCP client specifications - Track registered specifications per client using ConcurrentHashMap - Add unit test suite - Complete test coverage for McpSyncAnnotationCustomizer - Test duplicate validation, case-insensitive matching, and error scenarios - Update documentation with breaking changes - MCP client annotations now require mandatory clientId parameter - Update all examples to include clientId in annotation usage - Add configuration examples showing clientId mapping to connection names Signed-off-by: Christian Tzolov <[email protected]>
…style improvements - Change MCP annotation client specification from single clientId to clients array - Update @McpLogging, @McpSampling, @McpElicitation, @McpProgress annotations - Modify McpAsyncAnnotationCustomizer and McpSyncAnnotationCustomizer to iterate over client arrays - Update corresponding test cases to use new clients array format - Apply consistent code formatting and style improvements - Reorganize imports and add missing blank lines between import groups - Add 'this.' prefix for field access consistency - Move inner classes to bottom of files following Java conventions - Update method parameter access patterns - Clean up documentation - Remove redundant @param entries in Javadoc - Add missing newlines at end of files - Update .gitignore to exclude /contributing directory This change enables MCP annotations to target multiple clients simultaneously while maintaining backward compatibility through array support. Signed-off-by: Christian Tzolov <[email protected]>
8363130
to
3c69651
Compare
Signed-off-by: Christian Tzolov <[email protected]>
Signed-off-by: Christian Tzolov <[email protected]>
}); | ||
}); | ||
|
||
if (!CollectionUtils.isEmpty(this.syncResourceListChangedSpecifications)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the 'if' clause (and the one below) indented to be part of line 145 if statement? i think not, but i'll just highlight it here due to the async nature of the where we are and fix later as this is a big PR and I don't want to make a change without checking on this first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the async version doesn't have this, so i'll fix.
merged in 534c6af |
This enhancement simplifies MCP setup by allowing developers to use annotations instead of manual bean configuration, improving developer experience and reducing boilerplate code.