From 4c0079515408b413985bd8dcb88acf2bec03bb0a Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Tue, 11 Feb 2025 00:01:51 -0500 Subject: [PATCH] Minor updates to client-starter/starter-default-client and starter-webflux-client --- .../client-starter/starter-default-client/README.md | 11 ++++++++--- .../src/main/resources/application.properties | 3 +++ .../client-starter/starter-webflux-client/README.md | 9 +++++++-- .../src/main/resources/application.properties | 2 ++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/model-context-protocol/client-starter/starter-default-client/README.md b/model-context-protocol/client-starter/starter-default-client/README.md index f35741a..f83f10b 100644 --- a/model-context-protocol/client-starter/starter-default-client/README.md +++ b/model-context-protocol/client-starter/starter-default-client/README.md @@ -6,16 +6,20 @@ Follow the [MCP Client Boot Starter](https://docs.spring.io/spring-ai/reference/ ## Overview -The project uses Spring Boot and Spring AI to create a command-line application that: +The project uses Spring Boot and Spring AI to create a command-line application that demonstrates MCP server integration. The application: - Connects to MCP servers using STDIO and/or SSE (HttpClient-based) transports - Integrates with Spring AI's chat capabilities - Demonstrates tool execution through MCP servers +- Takes a user-defined question via the `-Dai.user.input` command-line property, which is mapped to a Spring `@Value` annotation in the code + +For example, running the application with `-Dai.user.input="Does Spring AI support MCP?"` will inject this question into the application through Spring's property injection, and the application will use it to query the MCP server. ## Prerequisites - Java 17 or later - Maven 3.6+ -- Anthropic API key (for Claude AI model) +- Anthropic API key (Claude) (Get one at https://docs.anthropic.com/en/docs/initial-setup) +- Brave Search API key (Get one at https://brave.com/search/api/) ## Dependencies @@ -107,7 +111,7 @@ The application demonstrates a simple command-line interaction with an AI model 1. The application starts and configures multiple MCP Clients (one for each provided STDIO or SSE connection configuration) 2. It builds a ChatClient with the configured MCP tools -3. Sends a predefined question (set vi the `ai.user.input` property) to the AI model +3. Sends a predefined question (set via the `ai.user.input` property) to the AI model 4. Displays the AI's response 5. Automatically closes the application @@ -116,6 +120,7 @@ The application demonstrates a simple command-line interaction with an AI model 1. Set the required environment variable: ```bash export ANTHROPIC_API_KEY=your-api-key + export BRAVE_API_KEY='your-brave-api-key-here' ``` 2. Build the application: diff --git a/model-context-protocol/client-starter/starter-default-client/src/main/resources/application.properties b/model-context-protocol/client-starter/starter-default-client/src/main/resources/application.properties index 4c20483..d3b267e 100644 --- a/model-context-protocol/client-starter/starter-default-client/src/main/resources/application.properties +++ b/model-context-protocol/client-starter/starter-default-client/src/main/resources/application.properties @@ -11,4 +11,7 @@ spring.ai.mcp.client.stdio.connections.brave-search.args=-y,@modelcontextprotoco # spring.ai.mcp.client.stdio.connections.brave-search.env.FOO=BAAR +logging.level.io.modelcontextprotocol.client=WARN +logging.level.io.modelcontextprotocol.spec=WARN + ai.user.input=What tools are available? \ No newline at end of file diff --git a/model-context-protocol/client-starter/starter-webflux-client/README.md b/model-context-protocol/client-starter/starter-webflux-client/README.md index 8594d13..7c423a4 100644 --- a/model-context-protocol/client-starter/starter-webflux-client/README.md +++ b/model-context-protocol/client-starter/starter-webflux-client/README.md @@ -6,16 +6,20 @@ Follow the [MCP Client Boot Starter](https://docs.spring.io/spring-ai/reference/ ## Overview -The project uses Spring Boot and Spring AI to create a command-line application that: +The project uses Spring Boot and Spring AI to create a command-line application that demonstrates MCP server integration with WebFlux. The application: - Connects to MCP servers using STDIO and/or SSE (WebFlux-based) transports - Integrates with Spring AI's chat capabilities - Demonstrates tool execution through MCP servers +- Takes a user-defined question via the `-Dai.user.input` command-line property, which is mapped to a Spring `@Value` annotation in the code + +For example, running the application with `-Dai.user.input="Does Spring AI support MCP?"` will inject this question into the application through Spring's property injection, and the application will use it to query the MCP server using WebFlux's reactive programming model. ## Prerequisites - Java 17 or later - Maven 3.6+ -- Anthropic API key (for Claude AI model) +- Anthropic API key (Claude) (Get one at https://docs.anthropic.com/en/docs/initial-setup) +- Brave Search API key (Get one at https://brave.com/search/api/) ## Dependencies @@ -116,6 +120,7 @@ The application demonstrates a simple command-line interaction with an AI model 1. Set the required environment variable: ```bash export ANTHROPIC_API_KEY=your-api-key + export BRAVE_API_KEY='your-brave-api-key-here' ``` 2. Build the application: diff --git a/model-context-protocol/client-starter/starter-webflux-client/src/main/resources/application.properties b/model-context-protocol/client-starter/starter-webflux-client/src/main/resources/application.properties index 4c20483..007a113 100644 --- a/model-context-protocol/client-starter/starter-webflux-client/src/main/resources/application.properties +++ b/model-context-protocol/client-starter/starter-webflux-client/src/main/resources/application.properties @@ -10,5 +10,7 @@ spring.ai.mcp.client.stdio.connections.brave-search.command=npx spring.ai.mcp.client.stdio.connections.brave-search.args=-y,@modelcontextprotocol/server-brave-search # spring.ai.mcp.client.stdio.connections.brave-search.env.FOO=BAAR +logging.level.io.modelcontextprotocol.client=WARN +logging.level.io.modelcontextprotocol.spec=WARN ai.user.input=What tools are available? \ No newline at end of file