add mcp filesystem demo
This commit is contained in:
@@ -25,7 +25,6 @@ or even create an new table:
|
||||
|
||||
- Natural language querying of SQLite databases
|
||||
- Interactive chat mode for dynamic database interactions
|
||||
- Predefined question mode for automated database analysis
|
||||
- Seamless integration with OpenAI's language models
|
||||
- Built on Spring AI and Model Context Protocol
|
||||
|
||||
@@ -49,7 +48,7 @@ or even create an new table:
|
||||
2. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/spring-projects/spring-ai-examples.git
|
||||
cd model-context-protocol/sqlite
|
||||
cd model-context-protocol/sqlite/chatbot
|
||||
```
|
||||
|
||||
3. Set up your OpenAI API key:
|
||||
|
||||
@@ -7,7 +7,6 @@ It uses the [SQLite MCP-Server](https://github.com/modelcontextprotocol/servers/
|
||||
## Features
|
||||
|
||||
- Natural language querying of SQLite databases
|
||||
- Interactive chat mode for dynamic database interactions
|
||||
- Predefined question mode for automated database analysis
|
||||
- Seamless integration with OpenAI's language models
|
||||
- Built on Spring AI and Model Context Protocol
|
||||
@@ -32,7 +31,7 @@ It uses the [SQLite MCP-Server](https://github.com/modelcontextprotocol/servers/
|
||||
2. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/spring-projects/spring-ai-examples.git
|
||||
cd model-context-protocol/sqlite
|
||||
cd model-context-protocol/sqlite/simple
|
||||
```
|
||||
|
||||
3. Set up your OpenAI API key:
|
||||
@@ -70,12 +69,15 @@ The bean definitions are described below, starting with the `ChatClient`
|
||||
@Bean
|
||||
@Profile("!chat")
|
||||
public CommandLineRunner predefinedQuestions(ChatClient.Builder chatClientBuilder,
|
||||
McpFunctionCallback[] functionCallbacks,
|
||||
List<McpFunctionCallback> functionCallbacks,
|
||||
ConfigurableApplicationContext context) {
|
||||
return args -> {
|
||||
var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks)
|
||||
var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0]))
|
||||
.build();
|
||||
runPredefinedQuestions(chatClient, context);
|
||||
// Run Predefined Questions
|
||||
System.out.println(chatClient.prompt(
|
||||
"Can you connect to my SQLite database and tell me what products are available, and their prices?").call().content());
|
||||
// ...
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -3,13 +3,10 @@ package org.springframework.ai.mcp.samples.sqlite;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
|
||||
import org.springframework.ai.chat.memory.InMemoryChatMemory;
|
||||
import org.springframework.ai.mcp.client.McpClient;
|
||||
import org.springframework.ai.mcp.client.McpSyncClient;
|
||||
import org.springframework.ai.mcp.client.stdio.ServerParameters;
|
||||
@@ -20,7 +17,6 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
@@ -30,7 +26,6 @@ public class Application {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Profile("!chat")
|
||||
public CommandLineRunner predefinedQuestions(ChatClient.Builder chatClientBuilder,
|
||||
List<McpFunctionCallback> functionCallbacks, ConfigurableApplicationContext context) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user