Skip to content

Commit e393ebc

Browse files
authored
docs: improve Java SDK documentation and examples (modelcontextprotocol#145)
- Fix typos and update links in quickstart guides - Update artifact names and configuration properties - Add detailed configuration examples and advanced features - Enhance Java SDK client/server documentation - Update architecture diagrams and descriptions - Improve code examples with better comments - Update Spring Boot version requirements Signed-off-by: Christian Tzolov <[email protected]>
1 parent ccfc60f commit e393ebc

File tree

4 files changed

+188
-135
lines changed

4 files changed

+188
-135
lines changed

quickstart/client.mdx

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,12 @@ If you see:
404404
<Tab title="Java">
405405

406406
<Note>
407-
This is a quickstart demo based on Spring AI MCP auto-configuraiton and boot starters.
408-
To learn how to create sync and async McpClients programatically consult the [Java SDK Client guid](TODO: add URL)
407+
This is a quickstart demo based on Spring AI MCP auto-configuration and boot starters.
408+
To learn how to create sync and async MCP Clients manually, consult the [Java SDK Client](/sdk/java/mcp-client) documentation
409409
</Note>
410410

411411
This example demonstrates how to build an interactive chatbot that combines Spring AI's Model Context Protocol (MCP) with the [Brave Search MCP Server](https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search). The application creates a conversational interface powered by Anthropic's Claude AI model that can perform internet searches through Brave Search, enabling natural language interactions with real-time web data.
412-
[You can find the complete code for this tutorial here.](https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/brave-chatbot)
412+
[You can find the complete code for this tutorial here.](https://github.com/spring-projects/spring-ai-examples/tree/main/model-context-protocol/web-search/brave-chatbot)
413413

414414
## System Requirements
415415

@@ -447,9 +447,9 @@ Before starting, ensure your system meets these requirements:
447447
```
448448

449449
5. Run the application using Maven:
450-
```bash
451-
./mvnw spring-boot:run
452-
```
450+
```bash
451+
./mvnw spring-boot:run
452+
```
453453

454454
<Warning>
455455
Make sure you keep your `ANTHROPIC_API_KEY` and `BRAVE_API_KEY` keys secure!
@@ -466,24 +466,35 @@ The application integrates Spring AI with the Brave Search MCP server through se
466466
```xml
467467
<dependency>
468468
<groupId>org.springframework.ai</groupId>
469-
<artifactId>spring-ai-mcp-spring-boot-starter</artifactId>
469+
<artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId>
470470
</dependency>
471471
<dependency>
472472
<groupId>org.springframework.ai</groupId>
473473
<artifactId>spring-ai-anthropic-spring-boot-starter</artifactId>
474474
</dependency>
475475
```
476476

477-
2. Application properties (application.properties):
478-
```properties
479-
spring.ai.mcp.client.stdio.enabled=true
480-
spring.ai.mcp.client.stdio.servers-configuration=classpath:/mcp-servers-config.json
481-
spring.ai.anthropic.api-key=${ANTHROPIC_API_KEY}
477+
2. Application properties (application.yml):
478+
```yml
479+
spring:
480+
ai:
481+
mcp:
482+
client:
483+
enabled: true
484+
name: brave-search-client
485+
version: 1.0.0
486+
type: SYNC
487+
request-timeout: 20s
488+
stdio:
489+
root-change-notification: true
490+
servers-configuration: classpath:/mcp-servers-config.json
491+
anthropic:
492+
api-key: ${ANTHROPIC_API_KEY}
482493
```
483494
484-
This acivates the `spring-ai-mcp-spring-boot-starter` to create one or more `McpClient`s based on the provided server configuration.
495+
This activates the `spring-ai-mcp-client-spring-boot-starter` to create one or more `McpClient`s based on the provided server configuration.
485496

486-
3. MCP Server Configuration (mcp-servers-config.json):
497+
3. MCP Server Configuration (`mcp-servers-config.json`):
487498
```json
488499
{
489500
"mcpServers": {
@@ -513,6 +524,53 @@ var chatClient = chatClientBuilder
513524
.build();
514525
```
515526

527+
Key features:
528+
- Uses Claude AI model for natural language understanding
529+
- Integrates Brave Search through MCP for real-time web search capabilities
530+
- Maintains conversation memory using InMemoryChatMemory
531+
- Runs as an interactive command-line application
532+
533+
### Build and run
534+
535+
```bash
536+
./mvnw clean install
537+
java -jar ./target/ai-mcp-brave-chatbot-0.0.1-SNAPSHOT.jar
538+
```
539+
540+
or
541+
542+
```bash
543+
./mvnw spring-boot:run
544+
```
545+
546+
The application will start an interactive chat session where you can ask questions. The chatbot will use Brave Search when it needs to find information from the internet to answer your queries.
547+
548+
The chatbot can:
549+
- Answer questions using its built-in knowledge
550+
- Perform web searches when needed using Brave Search
551+
- Remember context from previous messages in the conversation
552+
- Combine information from multiple sources to provide comprehensive answers
553+
554+
### Advanced Configuration
555+
556+
The MCP client supports additional configuration options:
557+
558+
- Client customization through `McpSyncClientCustomizer` or `McpAsyncClientCustomizer`
559+
- Multiple clients with multiple transport types: `STDIO` and `SSE` (Server-Sent Events)
560+
- Integration with Spring AI's tool execution framework
561+
- Automatic client initialization and lifecycle management
562+
563+
For WebFlux-based applications, you can use the WebFlux starter instead:
564+
565+
```xml
566+
<dependency>
567+
<groupId>org.springframework.ai</groupId>
568+
<artifactId>spring-ai-mcp-client-webflux-spring-boot-starter</artifactId>
569+
</dependency>
570+
```
571+
572+
This provides similar functionality but uses a WebFlux-based SSE transport implementation, recommended for production deployments.
573+
516574
</Tab>
517575

518576
</Tabs>

0 commit comments

Comments
 (0)