remove sample app module, bump version to 0.1.0-SNAPSHOT
This commit is contained in:
parent
6df87e2170
commit
7bec6efd37
4 changed files with 2 additions and 185 deletions
5
pom.xml
5
pom.xml
|
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
<groupId>org.springframework.experimental</groupId>
|
<groupId>org.springframework.experimental</groupId>
|
||||||
<artifactId>spring-ai-mcp</artifactId>
|
<artifactId>spring-ai-mcp</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<url>https://github.com/spring-projects-experimental/spring-ai-mcp</url>
|
<url>https://github.com/spring-projects-experimental/spring-ai-mcp</url>
|
||||||
|
|
||||||
<name>Spring AI MCP</name>
|
<name>Spring AI MCP</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Spring AI Integration for MCP</description>
|
||||||
|
|
||||||
|
|
||||||
<organization>
|
<organization>
|
||||||
|
|
@ -93,7 +93,6 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>spring-ai-mcp-core</module>
|
<module>spring-ai-mcp-core</module>
|
||||||
<module>spring-ai-mcp-spring</module>
|
<module>spring-ai-mcp-spring</module>
|
||||||
<module>spring-ai-mcp-spring-boot</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.springframework.experimental</groupId>
|
|
||||||
<artifactId>spring-ai-mcp</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>spring-ai-mcp-spring-boot</artifactId>
|
|
||||||
<name>Spring AI MCP Spring Boot</name>
|
|
||||||
<description>Spring AI MCP Spring Boot Integration</description>
|
|
||||||
|
|
||||||
<url>https://github.com/spring-projects-experimental/spring-ai-mcp</url>
|
|
||||||
<scm>
|
|
||||||
<url>https://github.com/spring-projects-experimental/spring-ai-mcp</url>
|
|
||||||
<connection>git://github.com/spring-projects-experimental/spring-ai-mcp.git</connection>
|
|
||||||
<developerConnection>git@github.com:spring-projects-experimental/spring-ai-mcp.git</developerConnection>
|
|
||||||
</scm>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<spring-boot.version>3.3.6</spring-boot.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.ai</groupId>
|
|
||||||
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.experimental</groupId>
|
|
||||||
<artifactId>spring-ai-mcp-spring</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
package org.springframework.ai.mcp.spring.boot;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.springframework.ai.mcp.client.McpClient;
|
|
||||||
import org.springframework.ai.mcp.client.McpSyncClient;
|
|
||||||
import org.springframework.ai.mcp.client.stdio.ServerParameters;
|
|
||||||
import org.springframework.ai.mcp.client.stdio.StdioServerTransport;
|
|
||||||
import org.springframework.ai.mcp.spring.McpFunctionCallback;
|
|
||||||
|
|
||||||
import org.springframework.ai.chat.client.ChatClient;
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class McpApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(McpApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CommandLineRunner test(ChatClient.Builder chatClientBuilder, List<McpFunctionCallback> functionCallbacks) {
|
|
||||||
|
|
||||||
return args -> {
|
|
||||||
|
|
||||||
var chatClient = chatClientBuilder.defaultFunctions(functionCallbacks.toArray(new McpFunctionCallback[0]))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
System.out.println(
|
|
||||||
"Can you connect to my SQLite database and tell me what products are available, and their prices?");
|
|
||||||
|
|
||||||
var response = chatClient.prompt(
|
|
||||||
"Can you connect to my SQLite database and tell me what products are available, and their prices?")
|
|
||||||
.call().content();
|
|
||||||
|
|
||||||
System.out.println(response);
|
|
||||||
|
|
||||||
System.out.println("\nWhat's the average price of all products in the database?");
|
|
||||||
|
|
||||||
response = chatClient.prompt(
|
|
||||||
"What's the average price of all products in the database?")
|
|
||||||
.call().content();
|
|
||||||
|
|
||||||
System.out.println(response);
|
|
||||||
|
|
||||||
System.out.println("\nCan you analyze the price distribution and suggest any pricing optimizations?");
|
|
||||||
|
|
||||||
response = chatClient.prompt(
|
|
||||||
"Can you analyze the price distribution and suggest any pricing optimizations?")
|
|
||||||
.call().content();
|
|
||||||
|
|
||||||
System.out.println(response);
|
|
||||||
|
|
||||||
System.out.println("\nCould you help me design and create a new table for storing customer orders?");
|
|
||||||
|
|
||||||
response = chatClient.prompt(
|
|
||||||
"Could you help me design and create a new table for storing customer orders?")
|
|
||||||
.call().content();
|
|
||||||
|
|
||||||
System.out.println(response);
|
|
||||||
|
|
||||||
// var response = chatClient.prompt("What is the content of the test.txt
|
|
||||||
// file?").call().content();
|
|
||||||
|
|
||||||
// System.out.println(response);
|
|
||||||
|
|
||||||
// response = chatClient.prompt(
|
|
||||||
// "Please summarize the content of the test.txt file, covert the result in
|
|
||||||
// markdown format and store it into test.md")
|
|
||||||
// .call()
|
|
||||||
// .content();
|
|
||||||
// System.out.println("Summary:" + response);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public List<McpFunctionCallback> functionCallbacks(McpSyncClient mcpClient) {
|
|
||||||
|
|
||||||
return mcpClient.listTools(null)
|
|
||||||
.tools()
|
|
||||||
.stream()
|
|
||||||
.map(tool -> new McpFunctionCallback(mcpClient, tool))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(destroyMethod = "close")
|
|
||||||
public McpSyncClient mcpClient() {
|
|
||||||
|
|
||||||
// var stdioParams = ServerParameters.builder("npx")
|
|
||||||
// .args("-y", "@modelcontextprotocol/server-filesystem",
|
|
||||||
// "/Users/christiantzolov/Dev/projects/demo/mcp-server/dir")
|
|
||||||
// .build();
|
|
||||||
|
|
||||||
var stdioParams = ServerParameters.builder("uvx")
|
|
||||||
.args("mcp-server-sqlite", "--db-path",
|
|
||||||
"/Users/christiantzolov/test.db")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
McpSyncClient mcpClient = null;
|
|
||||||
try {
|
|
||||||
mcpClient = McpClient.sync(new StdioServerTransport(stdioParams),
|
|
||||||
Duration.ofSeconds(10), new ObjectMapper());
|
|
||||||
|
|
||||||
var init = mcpClient.initialize();
|
|
||||||
|
|
||||||
System.out.println("MCP Initialized: " + init);
|
|
||||||
|
|
||||||
return mcpClient;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
spring.application.name=mcp
|
|
||||||
spring.main.web-application-type=none
|
|
||||||
|
|
||||||
spring.ai.openai.api-key=${OPENAI_API_KEY}
|
|
||||||
Loading…
Reference in a new issue