move the brave client starters under the web-search folder

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
Christian Tzolov
2025-02-10 11:40:37 +01:00
parent 3ae5f5d45d
commit cf529d6940
21 changed files with 49 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ This example demonstrates how to build an interactive chatbot that combines Spri
2. Clone the repository:
```bash
git clone https://github.com/spring-projects/spring-ai-examples.git
cd model-context-protocol/brave-chatbot
cd model-context-protocol/web-search/brave-chatbot
```
3. Set up your API keys:
@@ -57,7 +57,7 @@ The application integrates Spring AI with the Brave Search MCP server through se
```xml
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mcp-spring-boot-starter</artifactId>
<artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
@@ -65,11 +65,22 @@ The application integrates Spring AI with the Brave Search MCP server through se
</dependency>
```
2. Application properties (application.properties):
```properties
spring.ai.mcp.client.stdio.enabled=true
spring.ai.mcp.client.stdio.servers-configuration=classpath:/mcp-servers-config.json
spring.ai.anthropic.api-key=${ANTHROPIC_API_KEY}
2. Application properties (application.yml):
```yaml
spring:
ai:
mcp:
client:
enabled: true
name: brave-search-client
version: 1.0.0
type: SYNC # or ASYNC for reactive applications
request-timeout: 20s
stdio:
root-change-notification: true
servers-configuration: classpath:/mcp-servers-config.json
anthropic:
api-key: ${ANTHROPIC_API_KEY}
```
3. MCP Server Configuration (mcp-servers-config.json):
@@ -90,6 +101,15 @@ spring.ai.anthropic.api-key=${ANTHROPIC_API_KEY}
}
```
### Client Types
The MCP client supports two types of implementations:
- **Synchronous (default)**: Uses blocking operations, suitable for traditional request-response patterns
- **Asynchronous**: Uses non-blocking operations, suitable for reactive applications
You can switch between these types using the `spring.ai.mcp.client.type` property (SYNC or ASYNC).
### Chat Implementation
The chatbot is implemented using Spring AI's ChatClient with MCP tool integration:
@@ -113,3 +133,23 @@ The chatbot can:
- Perform web searches when needed using Brave Search
- Remember context from previous messages in the conversation
- Combine information from multiple sources to provide comprehensive answers
### Advanced Configuration
The MCP client supports additional configuration options:
- Client customization through `McpSyncClientCustomizer` or `McpAsyncClientCustomizer`
- Multiple transport types: STDIO and SSE (Server-Sent Events)
- Integration with Spring AI's tool execution framework
- Automatic client initialization and lifecycle management
For WebFlux-based applications, you can use the WebFlux starter instead:
```xml
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mcp-client-webflux-spring-boot-starter</artifactId>
</dependency>
```
This provides similar functionality but uses a WebFlux-based SSE transport implementation, recommended for production deployments.

View File

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 250 KiB

View File

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 250 KiB

View File

@@ -27,8 +27,8 @@
<module>model-context-protocol/filesystem</module>
<module>model-context-protocol/brave</module>
<module>model-context-protocol/brave-starter</module>
<module>model-context-protocol/brave-chatbot</module>
<module>model-context-protocol/web-search/brave-starter</module>
<module>model-context-protocol/web-search/brave-chatbot</module>
<module>model-context-protocol/book-library/manual-webmvc-server</module>
<module>model-context-protocol/book-library/manual-webflux-server</module>