Overview
The MCP Annotations project provides annotation-based method handling for Model Context Protocol (MCP) servers in Java. It simplifies the creation and registration of MCP server methods through a clean, declarative approach using Java annotations.Features
Annotation-based
Simplifies creation and registration of MCP methods
Sync & Async
Support for both synchronous and asynchronous operations
Stateful & Stateless
Full server exchange or lightweight transport context
Auto Schema Generation
Automatic JSON schema generation from method signatures
Dynamic Schemas
Handle dynamic schemas at runtime via CallToolRequest
Type Safe
Full Java type safety with comprehensive validation
Key Components
Server Annotations
@McpTool
@McpTool
Annotates methods that implement MCP tools with automatic JSON schema generation
@McpResource
@McpResource
Annotates methods that provide access to resources via URI templates
@McpPrompt
@McpPrompt
Annotates methods that generate prompt messages
@McpComplete
@McpComplete
Annotates methods that provide completion functionality for prompts or URI templates
Client Annotations
@McpLogging
@McpLogging
Handle logging message notifications from MCP servers
@McpSampling
@McpSampling
Handle sampling requests from MCP servers
@McpProgress
@McpProgress
Handle progress notifications for long-running operations
@McpElicitation
@McpElicitation
Handle elicitation requests to gather additional information from users
Quick Start
Installation
Simple Tool Example
Create MCP Server
Spring AI MCP Integration
For a complete out-of-the-box experience with Spring Boot, Spring AI provides full MCP support with auto-configurations.Getting Started with MCP
Official Spring AI MCP quick start guide
MCP Annotations Overview
Complete Spring AI MCP Annotations documentation
Server Annotations
Server-side annotation reference
MCP Annotations Example
Official Spring AI example project
Requirements
- Java 17 or higher
- Reactor Core (for async operations)
- MCP Java SDK 0.13.0-SNAPSHOT or higher