Skip to content

Commit 07688d5

Browse files
markpollacktzolov
authored andcommitted
docs: Improve MCP documentation and add getting started guide
- Fix grammar and formatting issues across MCP documentation - Standardize transport naming to "Streamable-HTTP" throughout - Add comprehensive "Getting Started with MCP" guide emphasizing annotation-based development - Include video tutorials and complete tutorial resources - Add navigation entry for new getting started guide Signed-off-by: Mark Pollack <[email protected]>
1 parent 0c8b6dc commit 07688d5

File tree

7 files changed

+215
-30
lines changed

7 files changed

+215
-30
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/nav.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
*** xref:api/mcp/mcp-server-boot-starter-docs.adoc[MCP Server Boot Starters]
8686
**** xref:api/mcp/mcp-stdio-sse-server-boot-starter-docs.adoc[STDIO and SSE MCP Servers]
8787
**** xref:api/mcp/mcp-streamable-http-server-boot-starter-docs.adoc[Streamable-HTTP MCP Servers]
88-
**** xref:api/mcp/mcp-stateless-server-boot-starter-docs.adoc[Stateless MCP Servers]
88+
**** xref:api/mcp/mcp-stateless-server-boot-starter-docs.adoc[Stateless Streamable-HTTP MCP Servers]
8989
// *** xref:api/mcp/mcp-helpers.adoc[MCP Utilities]
9090
*** xref:api/mcp/mcp-annotations-overview.adoc[MCP Annotations]
9191
**** xref:api/mcp/mcp-annotations-client.adoc[Client Annotations]
@@ -129,6 +129,7 @@
129129

130130
* Guides
131131
** https://github.com/spring-ai-community/awesome-spring-ai[Awesome Spring AI]
132+
** xref:guides/getting-started-mcp.adoc[Getting Started with MCP]
132133
** xref:api/chat/prompt-engineering-patterns.adoc[]
133134
** xref:api/effective-agents.adoc[Building Effective Agents]
134135
** xref:api/cloud-bindings.adoc[Deploying to the Cloud]

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-annotations-overview.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
The Spring AI MCP Annotations module provides annotation-based method handling for link:https://github.com/modelcontextprotocol/spec[Model Context Protocol (MCP)] servers and clients in Java.
44
It simplifies the creation and registration of MCP server methods and client handlers through a clean, declarative approach using Java annotations.
55

6-
7-
The MCP Annotations enables developers to easily create and register methods for handling MCP operations using simple annotations.
8-
It provides a clean, declarative approach to implementing MCP server and client functionality, reducing boilerplate code and improving maintainability.
6+
The MCP Annotations enable developers to create and register MCP operation handlers using declarative annotations.
7+
This approach simplifies implementing MCP server and client functionality by reducing boilerplate code and improving maintainability.
98

109
This library builds on top of the link:https://github.com/modelcontextprotocol/sdk-java[MCP Java SDK] to provide a higher-level, annotation-based programming model for implementing MCP servers and clients.
1110

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-client-boot-starter-docs.adoc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The MCP Client Boot Starter provides:
2626
</dependency>
2727
----
2828

29-
The standard starter connects simultaneously to one or more MCP servers over `STDIO` (in-process), `SSE`, `Streamable Http` and `Stateless Streamable Http` transports.
29+
The standard starter connects simultaneously to one or more MCP servers over `STDIO` (in-process), `SSE`, `Streamable-HTTP` and `Stateless Streamable-HTTP` transports.
3030
The SSE and Streamable-Http transports use the JDK HttpClient-based transport implementation.
3131
Each connection to an MCP server creates a new MCP client instance.
3232
You can choose either `SYNC` or `ASYNC` MCP clients (note: you cannot mix sync and async clients).
@@ -181,18 +181,18 @@ The Claude Desktop format looks like this:
181181
}
182182
----
183183

184-
=== Streamable Http Transport Properties
184+
=== Streamable-HTTP Transport Properties
185185

186186
Used for connecting to Streamable-HTTP and Stateless Streamable-HTTP MCP servers.
187187

188-
Properties for Streamable Http transport are prefixed with `spring.ai.mcp.client.streamable-http`:
188+
Properties for Streamable-HTTP transport are prefixed with `spring.ai.mcp.client.streamable-http`:
189189

190190
[cols="3,4,3"]
191191
|===
192192
|Property |Description | Default Value
193193

194194
|`connections`
195-
|Map of named Streamable Http connection configurations
195+
|Map of named Streamable-HTTP connection configurations
196196
|-
197197

198198
|`connections.[name].url`
@@ -325,10 +325,10 @@ public class CustomMcpSyncClientCustomizer implements McpSyncClientCustomizer {
325325
});
326326
327327
// Sets a custom elicitation handler for processing elicitation requests.
328-
spec.elicitation((ElicitRequest request) -> {
328+
spec.elicitation((ElicitRequest request) -> {
329329
// handle elicitation
330-
return new ElicitResult(ElicitResult.Action.ACCEPT, Map.of("message", request.message()));
331-
});
330+
return new ElicitResult(ElicitResult.Action.ACCEPT, Map.of("message", request.message()));
331+
});
332332
333333
// Adds a consumer to be notified when progress notifications are received.
334334
spec.progressConsumer((ProgressNotification progress) -> {
@@ -384,8 +384,8 @@ The MCP client auto-configuration automatically detects and applies any customiz
384384
The auto-configuration supports multiple transport types:
385385

386386
* Standard I/O (Stdio) (activated by the `spring-ai-starter-mcp-client` and `spring-ai-starter-mcp-client-webflux`)
387-
* (HttpClient) HTTP/SSE and StreamableHTTP (activated by the `spring-ai-starter-mcp-client`)
388-
* (WebFlux) HTTP/SSE and StreamableHTTP (activated by the `spring-ai-starter-mcp-client-webflux`)
387+
* (HttpClient) HTTP/SSE and Streamable-HTTP (activated by the `spring-ai-starter-mcp-client`)
388+
* (WebFlux) HTTP/SSE and Streamable-HTTP (activated by the `spring-ai-starter-mcp-client-webflux`)
389389

390390
=== Tool Filtering
391391

@@ -592,8 +592,7 @@ If no custom converter bean is provided, the default converter is used automatic
592592
The MCP ToolCallback auto-configuration is enabled by default, but can be disabled with the `spring.ai.mcp.client.toolcallback.enabled=false` property.
593593

594594
When disabled, no `ToolCallbackProvider` bean is created from the available MCP tools.
595-
If you need a fine grained control for selecting the which MCP tools to use, consider using the xref:/api/mcp/mcp-client-boot-starter-docs.adoc#_tool_filtering[Tool Filtering].
596-
595+
bsafdsa
597596
== MCP Client Annotations
598597

599598
The MCP Client Boot Starter automatically detects and registers annotated methods for handling various MCP client operations:

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-overview.adoc

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,50 @@
11
= Model Context Protocol (MCP)
22

3-
The link:https://modelcontextprotocol.org/docs/concepts/architecture[Model Context Protocol] (MCP) is a standardized protocol that enables AI models to interact with external tools and resources in a structured way.
3+
TIP: **New to MCP?** Start with our xref:guides/getting-started-mcp.adoc[Getting Started with MCP] guide for a quick introduction and hands-on examples.
4+
5+
The link:https://modelcontextprotocol.org/docs/concepts/architecture[Model Context Protocol] (MCP) is a standardized protocol that enables AI models to interact with external tools and resources in a structured way.
6+
Think of it as a bridge between your AI models and the real world - allowing them to access databases, APIs, file systems, and other external services through a consistent interface.
47
It supports multiple transport mechanisms to provide flexibility across different environments.
58

69
The link:https://modelcontextprotocol.io/sdk/java/mcp-overview[MCP Java SDK] provides a Java implementation of the Model Context Protocol, enabling standardized interaction with AI models and tools through both synchronous and asynchronous communication patterns.
710

8-
Spring AI extends the MCP Java SDK with Spring Boot integration, providing both xref:api/mcp/mcp-client-boot-starter-docs.adoc[Client] and xref:api/mcp/mcp-server-boot-starter-docs.adoc[Server] starters and xref:api/mcp/mcp-annotations-overview.adoc[MCP Annotations] for simplified development.
11+
Spring AI embraces MCP with comprehensive support through dedicated Boot Starters and MCP Java Annotations, making it easier than ever to build sophisticated AI-powered applications that can seamlessly connect to external systems.
12+
This means Spring developers can participate in both sides of the MCP ecosystem - building AI applications that consume MCP servers and creating MCP servers that expose Spring-based services to the wider AI community.
913
Bootstrap your AI applications with MCP support using link:https://start.spring.io[Spring Initializer].
1014

1115
== MCP Java SDK Architecture
1216

1317
TIP: This section provides an overview for the link:https://modelcontextprotocol.io/sdk/java/mcp-overview[MCP Java SDK architecture].
1418
For the Spring AI MCP integration, refer to the xref:#_spring_ai_mcp_integration[Spring AI MCP Boot Starters] documentation.
1519

16-
The Java MCP implementation follows a three-layer architecture:
20+
The Java MCP implementation follows a three-layer architecture that separates concerns for maintainability and flexibility:
1721

18-
|===
19-
| |
20-
^a| image::mcp/mcp-stack.svg[MCP Stack Architecture]
21-
a| * *Client/Server Layer*: The McpClient handles client-side operations while the McpServer manages server-side protocol operations. Both utilize McpSession for communication management.
22-
* *Session Layer (McpSession)*: Manages communication patterns and state through the McpClientSession and McpServerSession implementations.
23-
* *Transport Layer (McpTransport)*: Handles JSON-RPC message serialization and deserialization with support for multiple transport implementations.
24-
|===
22+
.MCP Stack Architecture
23+
image::mcp/mcp-stack.svg[MCP Stack Architecture, align=center]
24+
25+
=== Client/Server Layer (Top)
26+
27+
The top layer handles the main application logic and protocol operations:
28+
29+
* *McpClient* - Manages client-side operations and server connections
30+
* *McpServer* - Handles server-side protocol operations and client requests
31+
* Both components utilize the session layer below for communication management
32+
33+
=== Session Layer (Middle)
34+
35+
The middle layer manages communication patterns and maintains connection state:
36+
37+
* *McpSession* - Core session management interface
38+
* *McpClientSession* - Client-specific session implementation
39+
* *McpServerSession* - Server-specific session implementation
40+
41+
=== Transport Layer (Bottom)
42+
43+
The bottom layer handles the actual message transport and serialization:
44+
45+
* *McpTransport* - Manages JSON-RPC message serialization and deserialization
46+
* Supports multiple transport implementations (STDIO, HTTP/SSE, Streamable-HTTP, etc.)
47+
* Provides the foundation for all higher-level communication
2548

2649
|===
2750
| link:https://modelcontextprotocol.io/sdk/java/mcp-client[MCP Client] |
@@ -122,8 +145,8 @@ Key features include:
122145
* xref:api/mcp/mcp-annotations-server.adoc[Server Annotations]: `@McpTool`, `@McpResource`, `@McpPrompt`, `@McpComplete`
123146
* xref:api/mcp/mcp-annotations-client.adoc[Client Annotations]: `@McpLogging`, `@McpSampling`, `@McpElicitation`, `@McpProgress`
124147
* xref:api/mcp/mcp-annotations-special-params.adoc[Special Parameters]: `McpSyncServerExchange`, `McpAsyncServerExchange`, `McpTransportContext`, `McpMeta`
125-
* **Automatic Discovery**: Annotation scanning with configurable package inclusion/exclusion
126-
* **Spring Boot Integration**: Seamless integration with MCP Boot Starters
148+
* *Automatic Discovery*: Annotation scanning with configurable package inclusion/exclusion
149+
* *Spring Boot Integration*: Seamless integration with MCP Boot Starters
127150

128151
== Additional Resources
129152

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-server-boot-starter-docs.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ They are ideal for microservices architectures and cloud-native deployments. To
7272

7373
== Sync/Async Server API Options
7474

75-
The MCP Server API supports imperative (e.g. synchronous) and reactive (e.g. asynchronous) programming models.
75+
The MCP Server API supports imperative (i.e. synchronous) and reactive (e.g. asynchronous) programming models.
7676

7777
* **Synchronous Server** - The default server type implemented using `McpSyncServer`.
7878
It is designed for straightforward request-response patterns in your applications.

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/mcp/mcp-stateless-server-boot-starter-docs.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
== Stateless MCP Servers
2+
== Stateless Streamable-HTTP MCP Servers
33

4-
Stateless MCP servers are designed for simplified deployments where session state is not maintained between requests.
4+
Stateless Streamable-HTTP MCP servers are designed for simplified deployments where session state is not maintained between requests.
55
These servers are ideal for microservices architectures and cloud-native deployments.
66

77
TIP: Set the `spring.ai.mcp.server.protocol=STATELESS` property
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
= Getting Started with Model Context Protocol (MCP)
2+
3+
The Model Context Protocol (MCP) standardizes how AI applications interact with external tools and resources.
4+
5+
Spring joined the MCP ecosystem early as a key contributor, helping to develop and maintain the link:https://github.com/modelcontextprotocol/java-sdk[official MCP Java SDK] that serves as the foundation for Java-based MCP implementations. Building on this contribution, Spring AI provides comprehensive MCP support through Boot Starters and annotations, making it easy to build both MCP servers and clients.
6+
7+
== Introduction Video
8+
9+
**link:https://www.youtube.com/watch?v=FLpS7OfD5-s[Introduction to Model Context Protocol (MCP) - YouTube]**
10+
11+
Start here for an introductory overview of the Model Context Protocol, explaining core concepts and architecture.
12+
13+
== Complete Tutorial and Source Code
14+
15+
**📖 Blog Tutorial:** link:https://spring.io/blog/2025/09/16/connect-your-ai-to-everything-spring-ais-mcp-boot-starters[Connect Your AI to Everything: Spring AI's MCP Boot Starters]
16+
17+
**💻 Complete Source Code:** link:https://github.com/tzolov/spring-ai-mcp-blogpost[MCP Weather Example Repository]
18+
19+
The tutorial provides comprehensive coverage of MCP development with Spring AI, including production-ready examples, advanced features, and deployment patterns. All code examples below are taken from this tutorial.
20+
21+
== Quick Start
22+
23+
The fastest way to get started is with Spring AI's annotation-based approach. The following examples are from the blog tutorial:
24+
25+
=== Simple MCP Server
26+
27+
[source,java]
28+
----
29+
@Service
30+
public class WeatherService {
31+
32+
@McpTool(description = "Get current temperature for a location")
33+
public String getTemperature(
34+
@McpToolParam(description = "City name", required = true) String city) {
35+
return String.format("Current temperature in %s: 22°C", city);
36+
}
37+
}
38+
----
39+
40+
Add the dependency and configure:
41+
42+
[source,xml]
43+
----
44+
<dependency>
45+
<groupId>org.springframework.ai</groupId>
46+
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
47+
</dependency>
48+
----
49+
50+
[source,properties]
51+
----
52+
spring.ai.mcp.server.protocol=STREAMABLE
53+
----
54+
55+
=== Simple MCP Client
56+
57+
[source,java]
58+
----
59+
@Bean
60+
public CommandLineRunner demo(ChatClient chatClient, ToolCallbackProvider mcpTools) {
61+
return args -> {
62+
String response = chatClient
63+
.prompt("What's the weather like in Paris?")
64+
.toolCallbacks(mcpTools)
65+
.call()
66+
.content();
67+
System.out.println(response);
68+
};
69+
}
70+
----
71+
72+
Configure the client connection:
73+
74+
[source,yaml]
75+
----
76+
spring:
77+
ai:
78+
mcp:
79+
client:
80+
streamable-http:
81+
connections:
82+
weather-server:
83+
url: http://localhost:8080
84+
----
85+
86+
== Learning Resources
87+
88+
=== Implementation Video
89+
90+
**link:https://www.youtube.com/watch?v=hmEVUtulHTI[Spring AI Model Context Protocol (MCP) Integration - YouTube]**
91+
92+
A comprehensive video walkthrough of Spring AI's MCP integration, covering both server and client implementations.
93+
94+
== Additional Examples Repository
95+
96+
Beyond the tutorial examples, the link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol[Spring AI Examples] repository contains numerous MCP implementations.
97+
98+
=== Recommended Starting Points
99+
100+
*Annotation-based examples* (recommended for best developer experience):
101+
102+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/mcp-annotations-server[MCP Annotations Server] - Comprehensive annotation patterns
103+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/mcp-annotations/mcp-annotations-server[Complete Annotations Example] - All annotation features
104+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/sampling/annotations/mcp-sampling-server-annotations[Sampling with Annotations] - Advanced bidirectional AI
105+
106+
=== By Use Case
107+
108+
**Weather Services:**
109+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webflux-server[WebFlux Weather Server]
110+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/weather/starter-webmvc-oauth2-server[OAuth2 Secured Weather Server]
111+
112+
**Data Integration:**
113+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/sqlite/chatbot[SQLite AI Chatbot]
114+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/filesystem[Filesystem Access Server]
115+
116+
**Web Integration:**
117+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/web-search/brave-chatbot[Brave Search Chatbot]
118+
119+
**Client Examples:**
120+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/client-starter/starter-default-client[Basic MCP Client]
121+
* link:https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/mcp-annotations/mcp-annotations-client[Annotations Client]
122+
123+
== Key Concepts
124+
125+
**MCP Servers** expose capabilities (tools, resources, prompts) to AI applications.
126+
**MCP Clients** connect AI applications to MCP servers.
127+
128+
**Transport Options:**
129+
* *STDIO* - Desktop applications, IDE integrations
130+
* *Streamable-HTTP* - Production deployments, microservices
131+
* *SSE* - Real-time web applications
132+
* *Stateless* - Serverless environments
133+
134+
**Why Annotations?**
135+
* Declarative approach - focus on business logic
136+
* Automatic JSON schema generation
137+
* Type-safe parameter handling
138+
* Spring Boot auto-configuration
139+
* Minimal boilerplate code
140+
141+
== Community Resources
142+
143+
* link:https://github.com/spring-ai-community/awesome-spring-ai[Awesome Spring AI] - Community examples and resources
144+
* link:https://modelcontextprotocol.org/[Official MCP Specification]
145+
* link:https://github.com/modelcontextprotocol/java-sdk[Official MCP Java SDK] - Java SDK developed by the Spring team
146+
* link:https://modelcontextprotocol.io/sdk/java/mcp-overview[MCP Java SDK Documentation]
147+
148+
== Reference Documentation
149+
150+
* xref:api/mcp/mcp-overview.adoc[MCP Overview and Architecture]
151+
* xref:api/mcp/mcp-annotations-overview.adoc[MCP Annotations Guide]
152+
* xref:api/mcp/mcp-server-boot-starter-docs.adoc[Server Boot Starters]
153+
* xref:api/mcp/mcp-client-boot-starter-docs.adoc[Client Boot Starters]
154+
155+
== Next Steps
156+
157+
1. Read the complete blog tutorial linked above
158+
2. Clone and explore the tutorial source code repository
159+
3. Watch the video tutorial for a visual walkthrough
160+
4. Try the annotation-based examples
161+
5. Explore the additional examples repository
162+
6. Read the reference documentation for advanced features
163+
7. Join the community and share your implementations

0 commit comments

Comments
 (0)