Skip to content

Commit cc3d86d

Browse files
committed
upgrade spring-ai to version 2.0.0
1 parent df1c2ba commit cc3d86d

4 files changed

Lines changed: 19 additions & 37 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<spring-security-oauth2-authorization-server.version>2.0.0-M2
6868
</spring-security-oauth2-authorization-server.version>
6969
<scalar.version>0.5.55</scalar.version>
70-
<spring-ai.version>1.1.2</spring-ai.version>
71-
<mcp-sdk.version>0.17.0</mcp-sdk.version>
70+
<spring-ai.version>2.0.0</spring-ai.version>
71+
<mcp-sdk.version>2.0.0</mcp-sdk.version>
7272
<skipPublishing>false</skipPublishing>
7373
<skip.npm>true</skip.npm>
7474
<frontend-maven-plugin.version>1.15.1</frontend-maven-plugin.version>

springdoc-openapi-starter-common-mcp/src/main/java/org/springdoc/ai/configuration/SpringDocAiAutoConfiguration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ McpNativeToolAuditAspect mcpNativeToolAuditAspect() {
7979
}
8080

8181
/**
82-
* Registers the audit aspect for Spring AI Community {@code @McpTool}-annotated
83-
* methods. Only active when the {@code org.springaicommunity.mcp.annotation.McpTool}
84-
* class is on the classpath.
82+
* Registers the audit aspect for Spring AI {@code @McpTool}-annotated methods. Only
83+
* active when the {@code org.springframework.ai.mcp.annotation.McpTool} class is on the
84+
* classpath.
8585
* @return the audit aspect
8686
*/
8787
@Bean
8888
@ConditionalOnMissingBean
89-
@ConditionalOnClass(name = "org.springaicommunity.mcp.annotation.McpTool")
89+
@ConditionalOnClass(name = "org.springframework.ai.mcp.annotation.McpTool")
9090
McpCommunityToolAuditAspect mcpCommunityToolAuditAspect() {
9191
return new McpCommunityToolAuditAspect();
9292
}

springdoc-openapi-starter-common-mcp/src/main/java/org/springdoc/ai/dashboard/McpSyncServerDashboardToolSource.java

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,7 @@ public McpToolExecutionResponse executeTool(String toolName, String arguments, M
120120
long start = System.currentTimeMillis();
121121
try {
122122
Map<String, Object> argsMap = parseArguments(arguments);
123-
CallToolResult result;
124-
if (spec.callHandler() != null) {
125-
result = spec.callHandler().apply(null, new CallToolRequest(toolName, argsMap));
126-
}
127-
else {
128-
result = spec.call().apply(null, argsMap);
129-
}
123+
CallToolResult result = spec.callHandler().apply(null, new CallToolRequest(toolName, argsMap));
130124
long duration = System.currentTimeMillis() - start;
131125
String resultText = extractResultText(result);
132126
boolean isError = Boolean.TRUE.equals(result.isError());
@@ -139,27 +133,16 @@ public McpToolExecutionResponse executeTool(String toolName, String arguments, M
139133
}
140134

141135
/**
142-
* Converts McpSchema.JsonSchema to a JSON string.
136+
* Converts the tool input schema map to a JSON string.
143137
* @param inputSchema the input schema
144138
* @return JSON string representation
145139
*/
146-
private String convertInputSchema(McpSchema.JsonSchema inputSchema) {
147-
if (inputSchema == null) {
140+
private String convertInputSchema(Map<String, Object> inputSchema) {
141+
if (inputSchema == null || inputSchema.isEmpty()) {
148142
return "{}";
149143
}
150144
try {
151-
Map<String, Object> schemaMap = new HashMap<>();
152-
schemaMap.put("type", inputSchema.type());
153-
if (inputSchema.properties() != null) {
154-
schemaMap.put("properties", inputSchema.properties());
155-
}
156-
if (inputSchema.required() != null) {
157-
schemaMap.put("required", inputSchema.required());
158-
}
159-
if (inputSchema.additionalProperties() != null) {
160-
schemaMap.put("additionalProperties", inputSchema.additionalProperties());
161-
}
162-
return OBJECT_MAPPER.writeValueAsString(schemaMap);
145+
return OBJECT_MAPPER.writeValueAsString(inputSchema);
163146
}
164147
catch (JsonProcessingException ex) {
165148
return "{}";
@@ -207,7 +190,7 @@ private Map<String, Type> scanToolReturnTypes(ApplicationContext applicationCont
207190
Map<String, Type> returnTypes = new HashMap<>();
208191
try {
209192
Class<? extends Annotation> mcpToolAnnotation = (Class<? extends Annotation>) Class
210-
.forName("org.springaicommunity.mcp.annotation.McpTool");
193+
.forName("org.springframework.ai.mcp.annotation.McpTool");
211194
Method nameMethod = mcpToolAnnotation.getMethod("name");
212195
for (String beanName : applicationContext.getBeanDefinitionNames()) {
213196
try {

springdoc-openapi-starter-common-mcp/src/main/java/org/springdoc/ai/mcp/McpCommunityToolAuditAspect.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,25 @@
3535

3636
/**
3737
* AOP aspect that writes a structured JSON audit event (via {@link McpAuditLogger}) each
38-
* time an {@code @McpTool}-annotated method from the Spring AI Community library
39-
* ({@code org.springaicommunity.mcp.annotation.McpTool}) is invoked.
38+
* time an {@code @McpTool}-annotated method from Spring AI
39+
* ({@code org.springframework.ai.mcp.annotation.McpTool}) is invoked.
4040
*
4141
* <p>
42-
* This aspect is only registered when {@code org.springaicommunity.mcp.annotation.McpTool}
42+
* This aspect is only registered when {@code org.springframework.ai.mcp.annotation.McpTool}
4343
* is on the classpath (see
4444
* {@link org.springdoc.ai.configuration.SpringDocAiAutoConfiguration}). The annotation
4545
* class is referenced by fully-qualified name in the pointcut expression to avoid a
46-
* compile-time dependency on the springaicommunity library.
46+
* compile-time dependency on the Spring AI MCP annotations library.
4747
*
4848
* @author bnasslahsen
4949
*/
5050
@Aspect
5151
public class McpCommunityToolAuditAspect {
5252

5353
/**
54-
* Fully-qualified name of the {@code @McpTool} annotation from the Spring AI
55-
* Community library.
54+
* Fully-qualified name of the {@code @McpTool} annotation from Spring AI.
5655
*/
57-
private static final String MCP_TOOL_ANNOTATION = "org.springaicommunity.mcp.annotation.McpTool";
56+
private static final String MCP_TOOL_ANNOTATION = "org.springframework.ai.mcp.annotation.McpTool";
5857

5958
/**
6059
* Intercepts any bean method annotated with {@code @McpTool} and emits a JSON audit
@@ -63,7 +62,7 @@ public class McpCommunityToolAuditAspect {
6362
* @return the method's return value
6463
* @throws Throwable if the intercepted method throws
6564
*/
66-
@Around("@annotation(org.springaicommunity.mcp.annotation.McpTool)")
65+
@Around("@annotation(org.springframework.ai.mcp.annotation.McpTool)")
6766
public Object audit(ProceedingJoinPoint pjp) throws Throwable {
6867
String toolName = extractToolName(pjp);
6968
long startNanos = System.nanoTime();

0 commit comments

Comments
 (0)