From 7bec6efd375f68c0a76ff6c146fdbf51a88b2c95 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Tue, 10 Dec 2024 23:40:17 -0500 Subject: [PATCH] remove sample app module, bump version to 0.1.0-SNAPSHOT --- pom.xml | 5 +- spring-ai-mcp-spring-boot/pom.xml | 59 --------- .../ai/mcp/spring/boot/McpApplication.java | 119 ------------------ .../src/main/resources/application.properties | 4 - 4 files changed, 2 insertions(+), 185 deletions(-) delete mode 100644 spring-ai-mcp-spring-boot/pom.xml delete mode 100644 spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java delete mode 100644 spring-ai-mcp-spring-boot/src/main/resources/application.properties diff --git a/pom.xml b/pom.xml index 372a154..05236a7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ org.springframework.experimental spring-ai-mcp - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT pom https://github.com/spring-projects-experimental/spring-ai-mcp Spring AI MCP - Demo project for Spring Boot + Spring AI Integration for MCP @@ -93,7 +93,6 @@ spring-ai-mcp-core spring-ai-mcp-spring - spring-ai-mcp-spring-boot diff --git a/spring-ai-mcp-spring-boot/pom.xml b/spring-ai-mcp-spring-boot/pom.xml deleted file mode 100644 index 13086bb..0000000 --- a/spring-ai-mcp-spring-boot/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - - org.springframework.experimental - spring-ai-mcp - 0.0.1-SNAPSHOT - - spring-ai-mcp-spring-boot - Spring AI MCP Spring Boot - Spring AI MCP Spring Boot Integration - - https://github.com/spring-projects-experimental/spring-ai-mcp - - https://github.com/spring-projects-experimental/spring-ai-mcp - git://github.com/spring-projects-experimental/spring-ai-mcp.git - git@github.com:spring-projects-experimental/spring-ai-mcp.git - - - - 3.3.6 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.ai - spring-ai-openai-spring-boot-starter - - - org.springframework.experimental - spring-ai-mcp-spring - ${project.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - - \ No newline at end of file diff --git a/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java b/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java deleted file mode 100644 index b7a2758..0000000 --- a/spring-ai-mcp-spring-boot/src/main/java/org/springframework/ai/mcp/spring/boot/McpApplication.java +++ /dev/null @@ -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 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 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); - } - } - -} diff --git a/spring-ai-mcp-spring-boot/src/main/resources/application.properties b/spring-ai-mcp-spring-boot/src/main/resources/application.properties deleted file mode 100644 index 863de4f..0000000 --- a/spring-ai-mcp-spring-boot/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -spring.application.name=mcp -spring.main.web-application-type=none - -spring.ai.openai.api-key=${OPENAI_API_KEY} \ No newline at end of file