协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
mcp-server【开发与工程】Use when exposing Spring Boot 3 application capabilities through Model Context Protocol tools, resources, or prompts. Covers Spring AI 1.x tool callback registration, transports, schemas, errors, security, and standalone MCP Java SDK compatibility.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Prefer the Spring AI MCP server starters in a Spring Boot application. Let the Spring AI BOM manage its MCP SDK dependency; do not force the standalone SDK version into a starter-based application.
<!-- Pick exactly one transport starter. -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server</artifactId>
</dependency>
<!-- Remote MVC: spring-ai-starter-mcp-server-webmvc -->
<!-- Remote reactive: spring-ai-starter-mcp-server-webflux -->
For a raw SDK application without Spring AI, use the current MCP Java SDK 2.x release and follow its migration guide. Do not assume raw SDK examples match the version managed by Spring AI 1.x.
<dependency>
<groupId>io.modelcontextprotocol.sdk</groupId>
<artifactId>mcp</artifactId>
<version>2.0.0</version>
</dependency>
Spring AI 1.x commonly exposes model @Tool methods through an explicit
MethodToolCallbackProvider. Keep this callback conversion path separate from native MCP
annotations used by Spring AI 2.0.
@Configuration
class McpToolsConfiguration {
@Bean
ToolCallbackProvider orderTools(OrderMcpTools tools) {
return MethodToolCallbackProvider.builder()
.toolObjects(tools)
.build();
}
}
@Component
final class OrderMcpTools {
private final OrderService orderService;
OrderMcpTools(OrderService orderService) {
this.orderService = orderService;
}
@Tool(description = "Get an order by UUID with line items and status history")
OrderResponse getOrder(
@ToolParam(description = "Order UUID") String orderId) {
return OrderResponse.from(orderService.findById(UUID.fromString(orderId)));
}
}
CallToolResult.builder(); old constructors were removed.spring:
main:
banner-mode: "off"
ai:
mcp:
server:
name: order-service-mcp
version: 1.0.0
type: SYNC
stdio: true
Use stdio when a local client launches the jar. Use the matching MVC or WebFlux starter and Streamable HTTP for a remote server when supported by the selected Spring AI 1.x release. Keep stdout clean in stdio mode because it carries JSON-RPC frames.
examples/OrderMcpTools.java, examples/good-order-tools.java, and examples/bad-order-tools.java.new CallToolResult(...) constructors in raw SDK code - use builders.