Commit 534c6af
feat: Add annotation-based configuration support for MCP clients and 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
refactor: support multiple clients in MCP annotations and apply code 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]>1 parent dc82e5d commit 534c6af
File tree
49 files changed
+6057
-27
lines changed- auto-configurations/mcp
- spring-ai-autoconfigure-mcp-client-common
- src
- main
- java/org/springframework/ai/mcp/client/common/autoconfigure
- annotations
- properties
- resources/META-INF/spring
- test/java/org/springframework/ai/mcp/client/common/autoconfigure/annotations
- spring-ai-autoconfigure-mcp-client-httpclient/src/main/resources/META-INF/spring
- spring-ai-autoconfigure-mcp-client-webflux/src/main/resources/META-INF/spring
- spring-ai-autoconfigure-mcp-server-common
- src/main
- java/org/springframework/ai/mcp/server/common/autoconfigure/annotations
- resources/META-INF/spring
- spring-ai-autoconfigure-mcp-server-webflux
- src/test/java/org/springframework/ai/mcp/server/autoconfigure
- contributing
- mcp/mcp-annotations-spring
- src/main/java/org/springframework/ai/mcp/annotation/spring
- scan
- spring-ai-bom
- spring-ai-docs/src/main/antora/modules/ROOT
- pages/api/mcp
- spring-ai-spring-boot-starters
- spring-ai-starter-mcp-client-webflux
- spring-ai-starter-mcp-client
- spring-ai-starter-mcp-server-webflux
- spring-ai-starter-mcp-server-webmvc
- spring-ai-starter-mcp-server
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
49 files changed
+6057
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
27 | 43 | | |
28 | 44 | | |
29 | 45 | | |
| |||
95 | 111 | | |
96 | 112 | | |
97 | 113 | | |
98 | | - | |
99 | | - | |
100 | 114 | | |
101 | 115 | | |
102 | 116 | | |
| |||
208 | 222 | | |
209 | 223 | | |
210 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
211 | 239 | | |
212 | 240 | | |
213 | 241 | | |
| |||
259 | 287 | | |
260 | 288 | | |
261 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
262 | 302 | | |
263 | 303 | | |
264 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
0 commit comments