본문으로 건너뛰기
cccskills
무료GitHub에 공개

mcp-server

Use when exposing Spring Boot 4 application capabilities through Model Context Protocol tools, resources, or prompts. Covers Spring AI 2.0 MCP annotations, transport selection, schemas, errors, security, and the standalone MCP Java SDK 2.x.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(6)

  • SKILL.md5.0 KB
  • agents/openai.yaml186 B
  • examples/bad-order-tools.java232 B
  • examples/good-order-tools.java356 B
  • examples/OrderMcpTools.java1.4 KB
  • templates/mcp.json494 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

MCP Server - Spring AI 2.0 and Java SDK 2.x

Prefer Spring AI's MCP server starters and native annotations in Spring Boot applications. Use the standalone SDK only when Spring integration is intentionally not required.

Dependencies

Let the Spring AI BOM manage every Spring AI and MCP transitive dependency. Do not override its MCP SDK version independently.

<!-- 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 an application that uses the raw SDK without Spring AI, use the current 2.x release and follow its 2.0 migration guide. MCP Java SDK 2.0 tracks the 2025-11-25 protocol and prefers Streamable HTTP; SSE transports are deprecated.

<dependency>
    <groupId>io.modelcontextprotocol.sdk</groupId>
    <artifactId>mcp</artifactId>
    <version>2.0.0</version>
</dependency>

Native Spring AI MCP tools

Use @McpTool and @McpToolParam for server capabilities. @Tool is Spring AI's model tool-calling API; it is not the native MCP server annotation.

@Component
final class OrderMcpTools {
    private final OrderService orderService;

    OrderMcpTools(OrderService orderService) {
        this.orderService = orderService;
    }

    @McpTool(
        name = "get_order",
        description = "Get an order by UUID with line items and status history",
        generateOutputSchema = true,
        annotations = @McpTool.McpAnnotations(
            readOnlyHint = true,
            destructiveHint = false,
            idempotentHint = true))
    OrderResponse getOrder(
            @McpToolParam(description = "Order UUID", required = true) String orderId) {
        return OrderResponse.from(orderService.findById(UUID.fromString(orderId)));
    }
}
  • Return DTOs or records, not persistence entities.
  • Set tool hints accurately; clients must still treat them as untrusted metadata.
  • Use stable, specific descriptions because the model uses them to select tools.
  • Align return types with server mode: synchronous methods for SYNC, reactive types for ASYNC.
  • For expected failures, return a stable structured result. Do not expose stack traces or secrets.
  • Use MCP SDK builders such as CallToolResult.builder(); legacy result constructors were removed.

Transport configuration

spring:
  main:
    banner-mode: "off"
  ai:
    mcp:
      server:
        name: order-service-mcp
        version: 1.0.0
        type: SYNC
        stdio: true
        annotation-scanner:
          enabled: true

For a remote server, select the MVC or WebFlux starter and set spring.ai.mcp.server.protocol=STREAMABLE or STATELESS. Use SSE only for compatibility with an older client. A stdio server must keep stdout free of banners, logs, and System.out output because stdout carries JSON-RPC frames.

Security and operations

  • Authenticate and authorize remote MCP endpoints like any other privileged application API.
  • Validate tool arguments and apply domain authorization inside every capability.
  • Keep destructive tools narrow and require explicit business preconditions.
  • Bound execution time, result size, pagination, and downstream fan-out.
  • Log tool name, outcome, duration, and authenticated actor without recording secrets or full data.
  • Test initialization, discovery, invalid arguments, authorization, cancellation, and shutdown with a real MCP client.

Examples

  • See examples/OrderMcpTools.java, examples/good-order-tools.java, and examples/bad-order-tools.java.

Official sources

Gotchas

  • Agent uses @Tool for native server registration - use @McpTool and @McpToolParam.
  • Agent overrides the MCP SDK under a Spring AI starter - let the Spring AI BOM manage it.
  • Agent uses removed new CallToolResult(...) constructors - use CallToolResult.builder().
  • Agent configures SSE for a new remote server - prefer Streamable HTTP.
  • Agent logs to stdout in stdio mode - route logs to stderr or a file and disable the banner.
  • Agent mixes synchronous methods with an asynchronous server - the annotation scanner filters mismatched methods.
  • Agent exposes entities or unbounded collections - return bounded DTO contracts.
  • Agent trusts tool hints as authorization - enforce authorization in application code.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when adding Spring AI-specific model observations, token usage, latency, externally configured cost attribution, advisor telemetry, or protected prompt and completion logging. Use production-observability for general service metrics, health, logs, and OTLP setup.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3192026년 10월 17일 업데이트

Use when versioning Spring MVC or WebFlux APIs in Spring Boot 4 / Spring Framework 7. Covers built-in mapping versions, request version resolution, defaults, supported versions, and deprecation headers.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3192026년 10월 17일 업데이트

Use when versioning Spring MVC or WebFlux APIs in Spring Boot 3 / Spring Framework 6. Covers explicit URL, header, and media-type strategies, compatibility rules, and deprecation handling.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3192026년 10월 17일 업데이트

Use when introducing or correcting grouped Spring Boot configuration, typed property binding, validation, profiles or secret injection. Do not rewrite unrelated single-value configuration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3192026년 10월 17일 업데이트

Use when packaging a Spring Boot 3 application as an OCI image or GraalVM native executable. Covers buildpacks, layered images, JVM containers, AOT hints, probes, security, and verification.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3192026년 10월 17일 업데이트

Use when packaging Spring Boot 4 as an OCI image, JVM container, AOT application, or GraalVM native executable. Covers buildpacks, layers, runtime hints, probes, security, and verification.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3192026년 10월 17일 업데이트

rrezartprebreza의 스킬 모두 보기

이 스킬의 문제 신고