From a4314dbbdefa806e923d1fd18016a7469804e0e2 Mon Sep 17 00:00:00 2001 From: ageer <ageerle@163.com> Date: 星期一, 14 四月 2025 23:10:17 +0800 Subject: [PATCH] feat: mcp测试版 --- ruoyi-extend/call-mcp-server/src/main/resources/templates/index.html | 148 ++++++++++ ruoyi-extend/ruoyi-mcp-server/src/main/resources/application.yml | 332 ----------------------- ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/cofing/McpClientCfg.java | 22 + ruoyi-extend/call-mcp-server/src/main/resources/mcp-server.json | 20 + ruoyi-extend/call-mcp-server/pom.xml | 83 +++++ ruoyi-extend/ruoyi-mcp-server/src/main/java/org/ruoyi/mcp/service/McpCustomService.java | 11 ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/CallMcpServerApplication.java | 13 ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/IndexController.java | 21 + /dev/null | 10 ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/ChatController.java | 74 +++++ ruoyi-extend/call-mcp-server/src/main/resources/mcp-server-bak.json | 40 ++ ruoyi-extend/call-mcp-server/src/main/resources/application.yaml | 16 + ruoyi-extend/ruoyi-mcp-server/pom.xml | 20 13 files changed, 455 insertions(+), 355 deletions(-) diff --git a/ruoyi-extend/call-mcp-server/pom.xml b/ruoyi-extend/call-mcp-server/pom.xml new file mode 100644 index 0000000..3f06181 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/pom.xml @@ -0,0 +1,83 @@ +<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 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.ruoyi</groupId> + <artifactId>ruoyi-ai</artifactId> + <version>1.0.0</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <artifactId>call-mcp-server</artifactId> + <name>Archetype - call-mcp-server</name> + <url>http://maven.apache.org</url> + + <properties> + <java.version>17</java.version> + </properties> + + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.ai</groupId> + <artifactId>spring-ai-bom</artifactId> + <version>1.0.0-M6</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + + + <dependency> + <groupId>org.springframework.ai</groupId> + <artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId> + <version>1.0.0-M6</version> + </dependency> + + <dependency> + <groupId>org.springframework.ai</groupId> + <artifactId>spring-ai-openai-spring-boot-starter</artifactId> + </dependency> + + + <dependency> + <groupId>org.springframework.ai</groupId> + <artifactId>spring-ai-mcp</artifactId> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> diff --git a/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/CallMcpServerApplication.java b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/CallMcpServerApplication.java new file mode 100644 index 0000000..213df75 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/CallMcpServerApplication.java @@ -0,0 +1,13 @@ +package org.ruoyi.rocket.callmcpserver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CallMcpServerApplication { + + public static void main(String[] args) { + SpringApplication.run(CallMcpServerApplication.class, args); + } + +} diff --git a/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/cofing/McpClientCfg.java b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/cofing/McpClientCfg.java new file mode 100644 index 0000000..2693689 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/cofing/McpClientCfg.java @@ -0,0 +1,22 @@ +package org.ruoyi.rocket.callmcpserver.cofing; + +import io.modelcontextprotocol.client.McpClient; +import org.springframework.ai.mcp.customizer.McpSyncClientCustomizer; +import org.springframework.context.annotation.Configuration; + +import java.time.Duration; + + +/** + * @author ageer + */ +@Configuration +public class McpClientCfg implements McpSyncClientCustomizer { + + + @Override + public void customize(String name, McpClient.SyncSpec spec) { + // do nothing + spec.requestTimeout(Duration.ofSeconds(30)); + } +} diff --git a/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/ChatController.java b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/ChatController.java new file mode 100644 index 0000000..27c837e --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/ChatController.java @@ -0,0 +1,74 @@ +package org.ruoyi.rocket.callmcpserver.view; + +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.ai.chat.client.ChatClient; +import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor; +import org.springframework.ai.chat.memory.ChatMemory; +import org.springframework.ai.chat.memory.InMemoryChatMemory; +import org.springframework.ai.chat.model.ChatResponse; +import org.springframework.ai.openai.OpenAiChatOptions; +import org.springframework.ai.tool.ToolCallbackProvider; +import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Flux; + + +/** + * @author jianzhang + * 2025/03/18/涓嬪崍8:00 + */ +@RestController +@RequestMapping("/dashscope/chat-client") +public class ChatController { + + private final ChatClient chatClient; + + private final ChatMemory chatMemory = new InMemoryChatMemory(); + + public ChatController(ChatClient.Builder chatClientBuilder,ToolCallbackProvider tools) { + this.chatClient = chatClientBuilder + .defaultTools(tools) + .defaultOptions( + OpenAiChatOptions.builder().model("gpt-4o-mini").build()) + .build(); + } + + @RequestMapping(value = "/generate_stream", method = RequestMethod.GET) + public Flux<ChatResponse> generateStream(HttpServletResponse response, @RequestParam("id") String id, @RequestParam("prompt") String prompt) { + response.setCharacterEncoding("UTF-8"); + var messageChatMemoryAdvisor = new MessageChatMemoryAdvisor(chatMemory, id, 10); + + + Flux<ChatResponse> chatResponseFlux = this.chatClient.prompt(prompt) + .advisors(messageChatMemoryAdvisor) + .stream() + .chatResponse(); + + Flux<String> content = this.chatClient.prompt(prompt) + .advisors(messageChatMemoryAdvisor) + .stream() + .content(); + + content.subscribe( + content1 -> System.out.println("chatResponse"+content1) + ); + return chatResponseFlux; + + + } + + + @GetMapping("/advisor/chat/{id}/{prompt}") + public Flux<String> advisorChat( + HttpServletResponse response, + @PathVariable String id, + @PathVariable String prompt) { + + response.setCharacterEncoding("UTF-8"); + var messageChatMemoryAdvisor = new MessageChatMemoryAdvisor(chatMemory, id, 10); + return this.chatClient.prompt(prompt) + .advisors(messageChatMemoryAdvisor).stream().content(); + } + + + +} diff --git a/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/IndexController.java b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/IndexController.java new file mode 100644 index 0000000..ed03e33 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/java/org/ruoyi/rocket/callmcpserver/view/IndexController.java @@ -0,0 +1,21 @@ +package org.ruoyi.rocket.callmcpserver.view; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * @author jianzhang + * 2025/03/18/涓嬪崍8:00 + */ +@Controller +public class IndexController { + + @GetMapping("/") + public String chat(Model model) { + //model.addAttribute("name", "User"); + // 杩斿洖瑙嗗浘鍚嶇О锛屽搴� templates/index.html + return "index"; + } + +} diff --git a/ruoyi-extend/call-mcp-server/src/main/resources/application.yaml b/ruoyi-extend/call-mcp-server/src/main/resources/application.yaml new file mode 100644 index 0000000..f4b4577 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/resources/application.yaml @@ -0,0 +1,16 @@ +server: + port: 9999 +spring: + ai: + openai: + api-key: sk-xXe1WMPjhlVb1aiI1b4c6c8934D8463f9e4b67Ed8718B772 + base-url: https://api.pandarobot.chat/ + mcp: + client: + enabled: true + name: call-mcp-server + sse: + connections: + server1: + url: http://127.0.0.1:6040 + diff --git a/ruoyi-extend/call-mcp-server/src/main/resources/mcp-server-bak.json b/ruoyi-extend/call-mcp-server/src/main/resources/mcp-server-bak.json new file mode 100644 index 0000000..842d695 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/resources/mcp-server-bak.json @@ -0,0 +1,40 @@ +{ + "mcpServers": { + "fileSystem": { + "command": "D:\\software\\nodeJs\\npx.cmd", + "args": [ + "-y", + "@modelcontextprotocol/server-filesystem", + "D:\\software\\sqlite" + ] + }, + "sqlLite": { + "command": "D:\\Program Files\\python3.12.3\\Scripts\\uvx.exe", + "args": [ + "mcp-server-sqlite", + "--db-path", + "D:\\work-space-study\\spring-ai-mcp-demo\\mcp-client\\src\\main\\resources\\test.db" + ] + }, + "fetch": { + "command": "D:\\Program Files\\python3.12.3\\Scripts\\uvx.exe", + "args": [ + "mcp-server-fetch" + ] + }, + "baidu-map": { + "command": "D:\\Program Files\\python3.12.3\\Scripts\\uvx.exe", + "args": [ + "run", + "--with", + "mcp[cli]", + "mcp", + "run", + "D:\\work-space-python\\python-baidu-map\\baidu_map_mcp_server\\map.py" + ], + "env": { + "BAIDU_MAPS_API_KEY": "{鐧惧害鍦板浘API-KEY}" + } + } + } +} \ No newline at end of file diff --git a/ruoyi-extend/call-mcp-server/src/main/resources/mcp-server.json b/ruoyi-extend/call-mcp-server/src/main/resources/mcp-server.json new file mode 100644 index 0000000..a639d15 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/resources/mcp-server.json @@ -0,0 +1,20 @@ +{ + "mcpServers": { + "fileSystem": { + "command": "D:\\software\\nodeJs\\npx.cmd", + "args": [ + "-y", + "@modelcontextprotocol/server-filesystem", + "D:\\software\\sqlite" + ] + }, + "sqlLite": { + "command": "D:\\Program Files\\python3.12.3\\Scripts\\uvx.exe", + "args": [ + "mcp-server-sqlite", + "--db-path", + "D:\\work-space-study\\spring-ai-mcp-demo\\mcp-client\\src\\main\\resources\\test.db" + ] + } + } +} diff --git a/ruoyi-extend/call-mcp-server/src/main/resources/templates/index.html b/ruoyi-extend/call-mcp-server/src/main/resources/templates/index.html new file mode 100644 index 0000000..be98e85 --- /dev/null +++ b/ruoyi-extend/call-mcp-server/src/main/resources/templates/index.html @@ -0,0 +1,148 @@ +<!DOCTYPE html> +<html lang="zh-CN"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>AI 瀵硅瘽鍔╂墜</title> + <script src="https://cdn.tailwindcss.com"></script> +</head> +<body class="bg-gray-100 min-h-screen"> +<div class="container mx-auto p-4 max-w-3xl"> + <!-- 鏍囬 --> + <div class="text-center mb-8"> + <h1 class="text-3xl font-bold text-gray-800">AI 瀵硅瘽鍔╂墜</h1> + <p class="text-gray-600 mt-2">鍩轰簬 Spring AI 鐨勬祦寮忓璇濈郴缁� By AhuCodingBeast</p> + </div> + + <!-- 鑱婂ぉ瀹瑰櫒 --> + <div id="chat-container" class="bg-white rounded-xl shadow-lg p-4 mb-4 h-[500px] overflow-y-auto space-y-4"> + <!-- 鍒濆娆㈣繋娑堟伅 --> + <div class="ai-message flex items-start gap-3"> + <div class="bg-green-100 p-3 rounded-lg max-w-[85%]"> + <span class="text-gray-800">鎮ㄥソ锛佹垜鏄疉I鍔╂墜锛屾湁浠�涔堝彲浠ュ府鎮紵</span> + </div> + </div> + </div> + + <!-- 杈撳叆鍖哄煙 --> + <div class="flex gap-2"> + <input type="text" id="message-input" + class="flex-1 border border-gray-300 rounded-xl px-4 py-3 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="杈撳叆鎮ㄧ殑闂..."> + <button id="send-button" + class="bg-blue-500 text-white px-6 py-3 rounded-xl hover:bg-blue-600 transition-colors flex items-center"> + <span>鍙戦��</span> + <svg id="loading-spinner" class="hidden w-4 h-4 ml-2 animate-spin" fill="none" viewBox="0 0 24 24"> + <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> + <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path> + </svg> + </button> + </div> +</div> + +<script> + const chatContainer = document.getElementById('chat-container'); + const messageInput = document.getElementById('message-input'); + const sendButton = document.getElementById('send-button'); + const loadingSpinner = document.getElementById('loading-spinner'); + + // 鍙戦�佹秷鎭鐞� + function handleSend() { + const message = messageInput.value.trim(); + if (!message) return; + + // 娣诲姞鐢ㄦ埛娑堟伅 + addMessage(message, 'user'); + messageInput.value = ''; + + // 鏋勫缓API URL + const apiUrl = new URL('http://localhost:9999/dashscope/chat-client/generate_stream'); + apiUrl.searchParams.append('id', '01'); + apiUrl.searchParams.append('prompt', message); + + // 鏄剧ず鍔犺浇鐘舵�� + sendButton.disabled = true; + loadingSpinner.classList.remove('hidden'); + + // 鍒涘缓EventSource杩炴帴 + const eventSource = new EventSource(apiUrl); + let aiMessageElement = null; + + eventSource.onmessage = (event) => { + try { + const data = JSON.parse(event.data); + console.log(data); + const content = data.result?.output?.text || ''; + const finishReason = data.result?.metadata?.finishReason; + + // 鍒涘缓娑堟伅瀹瑰櫒锛堝鏋滀笉瀛樺湪锛� + if (!aiMessageElement) { + aiMessageElement = addMessage('', 'ai'); + } + + // 杩藉姞鍐呭 + if (content) { + aiMessageElement.querySelector('.message-content').textContent += content; + autoScroll(); + } + + // 澶勭悊缁撴潫 + if (finishReason === 'STOP') { + eventSource.close(); + sendButton.disabled = false; + loadingSpinner.classList.add('hidden'); + } + } catch (error) { + console.error('瑙f瀽閿欒:', error); + } + }; + + eventSource.onerror = (error) => { + console.error('杩炴帴閿欒:', error); + eventSource.close(); + sendButton.disabled = false; + loadingSpinner.classList.add('hidden'); + addMessage('瀵硅瘽杩炴帴寮傚父锛岃閲嶈瘯', 'ai', true); + }; + } + + // 娣诲姞娑堟伅鍒板鍣� + function addMessage(content, type, isError = false) { + const messageDiv = document.createElement('div'); + messageDiv.className = `${type}-message flex items-start gap-3`; + + const bubble = document.createElement('div'); + bubble.className = `p-3 rounded-lg max-w-[85%] ${ + type === 'user' + ? 'bg-blue-500 text-white ml-auto' + : `bg-green-100 ${isError ? 'text-red-500' : 'text-gray-800'}` + }`; + + const contentSpan = document.createElement('span'); + contentSpan.className = 'message-content'; + contentSpan.textContent = content; + + bubble.appendChild(contentSpan); + messageDiv.appendChild(bubble); + chatContainer.appendChild(messageDiv); + + autoScroll(); + return bubble; + } + + // 鑷姩婊氬姩鍒板簳閮� + function autoScroll() { + chatContainer.scrollTop = chatContainer.scrollHeight; + } + + // 浜嬩欢鐩戝惉 + sendButton.addEventListener('click', handleSend); + messageInput.addEventListener('keypress', (e) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + handleSend(); + } + }); +</script> +</body> +</html> \ No newline at end of file diff --git a/ruoyi-extend/ruoyi-mcp-server/pom.xml b/ruoyi-extend/ruoyi-mcp-server/pom.xml index 63ff2bc..d35402c 100644 --- a/ruoyi-extend/ruoyi-mcp-server/pom.xml +++ b/ruoyi-extend/ruoyi-mcp-server/pom.xml @@ -49,16 +49,16 @@ <artifactId>spring-ai-mcp</artifactId> </dependency> - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-system-api</artifactId> - <exclusions> - <exclusion> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-translation</artifactId> - </exclusion> - </exclusions> - </dependency> +<!-- <dependency>--> +<!-- <groupId>org.ruoyi</groupId>--> +<!-- <artifactId>ruoyi-system-api</artifactId>--> +<!-- <exclusions>--> +<!-- <exclusion>--> +<!-- <groupId>org.ruoyi</groupId>--> +<!-- <artifactId>ruoyi-common-translation</artifactId>--> +<!-- </exclusion>--> +<!-- </exclusions>--> +<!-- </dependency>--> </dependencies> </project> diff --git a/ruoyi-extend/ruoyi-mcp-server/src/main/java/org/ruoyi/mcp/service/McpCustomService.java b/ruoyi-extend/ruoyi-mcp-server/src/main/java/org/ruoyi/mcp/service/McpCustomService.java index 5757dc8..1e69376 100644 --- a/ruoyi-extend/ruoyi-mcp-server/src/main/java/org/ruoyi/mcp/service/McpCustomService.java +++ b/ruoyi-extend/ruoyi-mcp-server/src/main/java/org/ruoyi/mcp/service/McpCustomService.java @@ -1,8 +1,5 @@ package org.ruoyi.mcp.service; -import lombok.RequiredArgsConstructor; -import org.ruoyi.system.domain.vo.SysUserVo; -import org.ruoyi.system.mapper.SysUserMapper; import org.springframework.ai.tool.annotation.Tool; import org.springframework.stereotype.Service; @@ -10,18 +7,14 @@ * @author ageer */ @Service -@RequiredArgsConstructor public class McpCustomService { - private final SysUserMapper userMapper; - - public record User(String userName, Double userBalance) { + public record User(String userName, String userBalance) { } @Tool(description = "鏍规嵁鐢ㄦ埛鍚嶇О鏌ヨ鐢ㄦ埛淇℃伅") public User getUserBalance(String username) { - SysUserVo sysUserVo = userMapper.selectUserByUserName(username); - return new User(sysUserVo.getUserName(),sysUserVo.getUserBalance()); + return new User("admin","99.99"); } } diff --git a/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application-dev.yml b/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application-dev.yml deleted file mode 100644 index dbdc1f3..0000000 --- a/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application-dev.yml +++ /dev/null @@ -1,97 +0,0 @@ ---- # 鐩戞帶涓績閰嶇疆 -spring.boot.admin.client: - # 澧炲姞瀹㈡埛绔紑鍏� - enabled: false - url: http://localhost:9090/admin - instance: - service-host-type: IP - username: ruoyi - password: 123456 - ---- # 鏁版嵁婧愰厤缃� -spring: - datasource: - type: com.zaxxer.hikari.HikariDataSource - # 鍔ㄦ�佹暟鎹簮鏂囨。 https://www.kancloud.cn/tracy5546/dynamic-datasource/content - dynamic: - # 鎬ц兘鍒嗘瀽鎻掍欢(鏈夋�ц兘鎹熻�� 涓嶅缓璁敓浜х幆澧冧娇鐢�) - p6spy: true - # 璁剧疆榛樿鐨勬暟鎹簮鎴栬�呮暟鎹簮缁�,榛樿鍊煎嵆涓� master - primary: master - # 涓ユ牸妯″紡 鍖归厤涓嶅埌鏁版嵁婧愬垯鎶ラ敊 - strict: true - datasource: - # 涓诲簱鏁版嵁婧� - master: - type: ${spring.datasource.type} - driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://43.139.70.230:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true - username: ry-vue - password: xx - - hikari: - # 鏈�澶ц繛鎺ユ睜鏁伴噺 - maxPoolSize: 20 - # 鏈�灏忕┖闂茬嚎绋嬫暟閲� - minIdle: 10 - # 閰嶇疆鑾峰彇杩炴帴绛夊緟瓒呮椂鐨勬椂闂� - connectionTimeout: 30000 - # 鏍¢獙瓒呮椂鏃堕棿 - validationTimeout: 5000 - # 绌洪棽杩炴帴瀛樻椿鏈�澶ф椂闂达紝榛樿10鍒嗛挓 - idleTimeout: 600000 - # 姝ゅ睘鎬ф帶鍒舵睜涓繛鎺ョ殑鏈�闀跨敓鍛藉懆鏈燂紝鍊�0琛ㄧず鏃犻檺鐢熷懡鍛ㄦ湡锛岄粯璁�30鍒嗛挓 - maxLifetime: 1800000 - # 杩炴帴娴嬭瘯query锛堥厤缃娴嬭繛鎺ユ槸鍚︽湁鏁堬級 - connectionTestQuery: SELECT 1 - # 澶氫箙妫�鏌ヤ竴娆¤繛鎺ョ殑娲绘�� - keepaliveTime: 30000 - ---- # redis 鍗曟満閰嶇疆(鍗曟満涓庨泦缇ゅ彧鑳藉紑鍚竴涓彟涓�涓渶瑕佹敞閲婃帀) -spring.data: - redis: - # 鍦板潃 - host: 127.0.0.1 - # 绔彛锛岄粯璁や负6379 - port: 6379 - # 鏁版嵁搴撶储寮� - database: 0 - # 瀵嗙爜(濡傛病鏈夊瘑鐮佽娉ㄩ噴鎺�) - # password: 123456 - # 杩炴帴瓒呮椂鏃堕棿 - timeout: 10S - -redisson: - # redis key鍓嶇紑 - keyPrefix: - # 绾跨▼姹犳暟閲� - threads: 4 - # Netty绾跨▼姹犳暟閲� - nettyThreads: 8 - # 鍗曡妭鐐归厤缃� - singleServerConfig: - # 瀹㈡埛绔悕绉� - clientName: ${ruoyi.name} - # 鏈�灏忕┖闂茶繛鎺ユ暟 - connectionMinimumIdleSize: 8 - # 杩炴帴姹犲ぇ灏� - connectionPoolSize: 32 - # 杩炴帴绌洪棽瓒呮椂锛屽崟浣嶏細姣 - idleConnectionTimeout: 10000 - # 鍛戒护绛夊緟瓒呮椂锛屽崟浣嶏細姣 - timeout: 3000 - # 鍙戝竷鍜岃闃呰繛鎺ユ睜澶у皬 - subscriptionConnectionPoolSize: 50 - ---- # sms 鐭俊 -sms: - enabled: false - # 闃块噷浜� dysmsapi.aliyuncs.com - # 鑵捐浜� sms.tencentcloudapi.com - endpoint: "dysmsapi.aliyuncs.com" - accessKeyId: xxxxxxx - accessKeySecret: xxxxxx - signName: 娴嬭瘯 - # 鑵捐涓撶敤 - sdkAppId: - diff --git a/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application-mcp.yml b/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application-mcp.yml deleted file mode 100644 index 57f9979..0000000 --- a/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application-mcp.yml +++ /dev/null @@ -1,10 +0,0 @@ -spring: - application: - name: mcp-server - ai: - mcp: - server: - name: webmvc-mcp-server - version: 1.0.0 - type: SYNC - sse-message-endpoint: /mcp/messages diff --git a/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application.yml b/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application.yml index 7bad7a5..82b2bdd 100644 --- a/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application.yml +++ b/ruoyi-extend/ruoyi-mcp-server/src/main/resources/application.yml @@ -1,332 +1,12 @@ - -# 椤圭洰鐩稿叧閰嶇疆 -ruoyi: - # 鍚嶇О - name: "ruoyi" - # 鐗堟湰 - version: ${revision} - # 鐗堟潈骞翠唤 - copyrightYear: 2025 - # 瀹炰緥婕旂ず寮�鍏� - demoEnabled: true - # 鑾峰彇ip鍦板潃寮�鍏� - addressEnabled: false - -captcha: - enable: false - # 椤甸潰 <鍙傛暟璁剧疆> 鍙紑鍚叧闂� 楠岃瘉鐮佹牎楠� - # 楠岃瘉鐮佺被鍨� math 鏁扮粍璁$畻 char 瀛楃楠岃瘉 - type: MATH - # line 绾挎骞叉壈 circle 鍦嗗湀骞叉壈 shear 鎵洸骞叉壈 - category: CIRCLE - # 鏁板瓧楠岃瘉鐮佷綅鏁� - numberLength: 1 - # 瀛楃楠岃瘉鐮侀暱搴� - charLength: 4 - -# 寮�鍙戠幆澧冮厤缃� server: - # 鏈嶅姟鍣ㄧ殑HTTP绔彛锛岄粯璁や负8080 port: 6040 - servlet: - # 搴旂敤鐨勮闂矾寰� - context-path: / - # undertow 閰嶇疆 - undertow: - # HTTP post鍐呭鐨勬渶澶уぇ灏忋�傚綋鍊间负-1鏃讹紝榛樿鍊间负澶у皬鏄棤闄愮殑 - max-http-post-size: -1 - # 浠ヤ笅鐨勯厤缃細褰卞搷buffer,杩欎簺buffer浼氱敤浜庢湇鍔″櫒杩炴帴鐨処O鎿嶄綔,鏈夌偣绫讳技netty鐨勬睜鍖栧唴瀛樼鐞� - # 姣忓潡buffer鐨勭┖闂村ぇ灏�,瓒婂皬鐨勭┖闂磋鍒╃敤瓒婂厖鍒� - buffer-size: 512 - # 鏄惁鍒嗛厤鐨勭洿鎺ュ唴瀛� - direct-buffers: true - threads: - # 璁剧疆IO绾跨▼鏁�, 瀹冧富瑕佹墽琛岄潪闃诲鐨勪换鍔�,瀹冧滑浼氳礋璐e涓繛鎺�, 榛樿璁剧疆姣忎釜CPU鏍稿績涓�涓嚎绋� - io: 8 - # 闃诲浠诲姟绾跨▼姹�, 褰撴墽琛岀被浼約ervlet璇锋眰闃诲鎿嶄綔, undertow浼氫粠杩欎釜绾跨▼姹犱腑鍙栧緱绾跨▼,瀹冪殑鍊艰缃彇鍐充簬绯荤粺鐨勮礋杞� - worker: 256 -# 鐢ㄦ埛閰嶇疆 -user: - password: - # 瀵嗙爜鏈�澶ч敊璇鏁� - maxRetryCount: 5 - # 瀵嗙爜閿佸畾鏃堕棿锛堥粯璁�10鍒嗛挓锛� - lockTime: 10 - -# Spring閰嶇疆 spring: application: - name: ${ruoyi.name} - # 璧勬簮淇℃伅 - messages: - # 鍥介檯鍖栬祫婧愭枃浠惰矾寰� - basename: i18n/messages - profiles: - active: @profiles.active@ - # 鏂囦欢涓婁紶 - servlet: - multipart: - # 鍗曚釜鏂囦欢澶у皬 - max-file-size: 50MB - # 璁剧疆鎬讳笂浼犵殑鏂囦欢澶у皬 - max-request-size: 200MB - mvc: - format: - date-time: yyyy-MM-dd HH:mm:ss - jackson: - # 鏃ユ湡鏍煎紡鍖� - date-format: yyyy-MM-dd HH:mm:ss - serialization: - # 鏍煎紡鍖栬緭鍑� - indent_output: false - # 蹇界暐鏃犳硶杞崲鐨勫璞� - fail_on_empty_beans: false - deserialization: - # 鍏佽瀵硅薄蹇界暐json涓笉瀛樺湪鐨勫睘鎬� - fail_on_unknown_properties: false - -# Sa-Token閰嶇疆 -sa-token: - # token鍚嶇О (鍚屾椂涔熸槸cookie鍚嶇О) - token-name: Authorization - # token鏈夋晥鏈� 璁句负7澶� (蹇呭畾杩囨湡) 鍗曚綅: 绉� - timeout: 604800 - # token涓存椂鏈夋晥鏈� (鎸囧畾鏃堕棿鏃犳搷浣滃氨杩囨湡) 鍗曚綅: 绉� - activity-timeout: 604800 - # 鏄惁鍏佽鍚屼竴璐﹀彿骞跺彂鐧诲綍 (涓簍rue鏃跺厑璁镐竴璧风櫥褰�, 涓篺alse鏃舵柊鐧诲綍鎸ゆ帀鏃х櫥褰�) - is-concurrent: true - # 鍦ㄥ浜虹櫥褰曞悓涓�璐﹀彿鏃讹紝鏄惁鍏辩敤涓�涓猼oken (涓簍rue鏃舵墍鏈夌櫥褰曞叡鐢ㄤ竴涓猼oken, 涓篺alse鏃舵瘡娆$櫥褰曟柊寤轰竴涓猼oken) - is-share: false - # 鏄惁灏濊瘯浠巋eader閲岃鍙杢oken - is-read-header: true - # 鏄惁灏濊瘯浠巆ookie閲岃鍙杢oken - is-read-cookie: false - # token鍓嶇紑 - token-prefix: "Bearer" - # jwt绉橀挜 - jwt-secret-key: abcdefghijklmnopqrstuvwxyz - -# security閰嶇疆 -security: - # 鎺掗櫎璺緞 - excludes: - # 鏀粯鍥炶皟 - - /pay/returnUrl - - /pay/notifyUrl - # 涓婁紶鏂囦欢 - - /resource/oss/upload - # 閲嶇疆瀵嗙爜 - - /auth/reset/password - # 鑱婂ぉ鎺ュ彛 - - /chat - # 闈欐�佽祫婧� - - /*.html - - /**/*.html - - /**/*.css - - /**/*.js - # 鍏叡璺緞 - - /favicon.ico - - /error - # swagger 鏂囨。閰嶇疆 - - /*/api-docs - - /*/api-docs/** - # actuator 鐩戞帶閰嶇疆 - - /actuator - - /actuator/** -# 澶氱鎴烽厤缃� -tenant: - # 鏄惁寮�鍚� - enable: false - # 鎺掗櫎琛� - excludes: - - sys_menu - - sys_tenant - - sys_tenant_package - - sys_role_dept - - sys_role_menu - - sys_user_post - - sys_user_role - -# MyBatisPlus閰嶇疆 -# https://baomidou.com/config/ -mybatis-plus: - # 涓嶆敮鎸佸鍖�, 濡傛湁闇�瑕佸彲鍦ㄦ敞瑙i厤缃� 鎴� 鎻愬崌鎵寘绛夌骇 - # 渚嬪 com.**.**.mapper - mapperPackage: org.ruoyi.**.mapper - # 瀵瑰簲鐨� XML 鏂囦欢浣嶇疆 - mapperLocations: classpath*:mapper/**/*Mapper.xml - # 瀹炰綋鎵弿锛屽涓猵ackage鐢ㄩ�楀彿鎴栬�呭垎鍙峰垎闅� - typeAliasesPackage: org.ruoyi.**.domain - # 鍚姩鏃舵槸鍚︽鏌� MyBatis XML 鏂囦欢鐨勫瓨鍦紝榛樿涓嶆鏌� - checkConfigLocation: false - configuration: - # 鑷姩椹煎嘲鍛藉悕瑙勫垯锛坈amel case锛夋槧灏� - mapUnderscoreToCamelCase: true - # MyBatis 鑷姩鏄犲皠绛栫暐 - # NONE锛氫笉鍚敤 PARTIAL锛氬彧瀵归潪宓屽 resultMap 鑷姩鏄犲皠 FULL锛氬鎵�鏈� resultMap 鑷姩鏄犲皠 - autoMappingBehavior: FULL - # MyBatis 鑷姩鏄犲皠鏃舵湭鐭ュ垪鎴栨湭鐭ュ睘鎬у鐞嗙瓥 - # NONE锛氫笉鍋氬鐞� WARNING锛氭墦鍗扮浉鍏宠鍛� FAILING锛氭姏鍑哄紓甯稿拰璇︾粏淇℃伅 - autoMappingUnknownColumnBehavior: NONE - # 鏇磋缁嗙殑鏃ュ織杈撳嚭 浼氭湁鎬ц兘鎹熻�� org.apache.ibatis.logging.stdout.StdOutImpl - # 鍏抽棴鏃ュ織璁板綍 (鍙崟绾娇鐢� p6spy 鍒嗘瀽) org.apache.ibatis.logging.nologging.NoLoggingImpl - # 榛樿鏃ュ織杈撳嚭 org.apache.ibatis.logging.slf4j.Slf4jImpl - logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl - global-config: - # 鏄惁鎵撳嵃 Logo banner - banner: true - dbConfig: - # 涓婚敭绫诲瀷 - # AUTO 鑷 NONE 绌� INPUT 鐢ㄦ埛杈撳叆 ASSIGN_ID 闆姳 ASSIGN_UUID 鍞竴 UUID - idType: ASSIGN_ID - # 閫昏緫宸插垹闄ゅ�� - logicDeleteValue: 2 - # 閫昏緫鏈垹闄ゅ�� - logicNotDeleteValue: 0 - # 瀛楁楠岃瘉绛栫暐涔� insert,鍦� insert 鐨勬椂鍊欑殑瀛楁楠岃瘉绛栫暐 - # IGNORED 蹇界暐 NOT_NULL 闈濶ULL NOT_EMPTY 闈炵┖ DEFAULT 榛樿 NEVER 涓嶅姞鍏� SQL - insertStrategy: NOT_NULL - # 瀛楁楠岃瘉绛栫暐涔� update,鍦� update 鐨勬椂鍊欑殑瀛楁楠岃瘉绛栫暐 - updateStrategy: NOT_NULL - # 瀛楁楠岃瘉绛栫暐涔� select,鍦� select 鐨勬椂鍊欑殑瀛楁楠岃瘉绛栫暐鏃� wrapper 鏍规嵁鍐呴儴 entity 鐢熸垚鐨� where 鏉′欢 - where-strategy: NOT_NULL - -# 鏁版嵁鍔犲瘑 -mybatis-encryptor: - # 鏄惁寮�鍚姞瀵� - enable: false - # 榛樿鍔犲瘑绠楁硶 - algorithm: BASE64 - # 缂栫爜鏂瑰紡 BASE64/HEX銆傞粯璁ASE64 - encode: BASE64 - # 瀹夊叏绉橀挜 瀵圭О绠楁硶鐨勭閽� 濡傦細AES锛孲M4 - password: - # 鍏閽� 闈炲绉扮畻娉曠殑鍏閽� 濡傦細SM2锛孯SA - publicKey: - privateKey: - -# Swagger閰嶇疆 -swagger: - info: - # 鏍囬 - title: '鏍囬锛�${ruoyi.name}澶氱鎴风鐞嗙郴缁焈鎺ュ彛鏂囨。' - # 鎻忚堪 - description: '鎻忚堪锛氱敤浜庣鐞嗛泦鍥㈡棗涓嬪叕鍙哥殑浜哄憳淇℃伅,鍏蜂綋鍖呮嫭XXX,XXX妯″潡...' - # 鐗堟湰 - version: '鐗堟湰鍙�: ${ruoyi.version}' - # 浣滆�呬俊鎭� - contact: - name: ageerle - email: ageerle@163.com - url: https://gitee.com/ageerle/ruoyi-ai - components: - # 閴存潈鏂瑰紡閰嶇疆 - security-schemes: - apiKey: - type: APIKEY - in: HEADER - name: ${sa-token.token-name} - -springdoc: - api-docs: - # 鏄惁寮�鍚帴鍙f枃妗� - enabled: true - swagger-ui: - # 鎸佷箙鍖栬璇佹暟鎹� - persistAuthorization: true - #杩欓噷瀹氫箟浜嗕袱涓垎缁勶紝鍙畾涔夊涓紝涔熷彲浠ヤ笉瀹氫箟 - group-configs: - - group: 1.婕旂ず妯″潡 - packages-to-scan: org.ruoyi.demo - - group: 2.閫氱敤妯″潡 - packages-to-scan: org.ruoyi.web - - group: 3.绯荤粺妯″潡 - packages-to-scan: org.ruoyi.system - - group: 4.浠g爜鐢熸垚妯″潡 - packages-to-scan: org.ruoyi.generator - -# 闃叉XSS鏀诲嚮 -xss: - # 杩囨护寮�鍏� - enabled: true - # 鎺掗櫎閾炬帴锛堝涓敤閫楀彿鍒嗛殧锛� - excludes: /system/notice - # 鍖归厤閾炬帴 - urlPatterns: /system/*,/monitor/*,/tool/* - -# 鍏ㄥ眬绾跨▼姹犵浉鍏抽厤缃� -thread-pool: - # 鏄惁寮�鍚嚎绋嬫睜 - enabled: false - # 闃熷垪鏈�澶ч暱搴� - queueCapacity: 128 - # 绾跨▼姹犵淮鎶ょ嚎绋嬫墍鍏佽鐨勭┖闂叉椂闂� - keepAliveSeconds: 300 - ---- # 鍒嗗竷寮忛攣 lock4j 鍏ㄥ眬閰嶇疆 -lock4j: - # 鑾峰彇鍒嗗竷寮忛攣瓒呮椂鏃堕棿锛岄粯璁や负 3000 姣 - acquire-timeout: 3000 - # 鍒嗗竷寮忛攣鐨勮秴鏃舵椂闂达紝榛樿涓� 30 绉� - expire: 30000 - ---- # Actuator 鐩戞帶绔偣鐨勯厤缃」 -management: - endpoints: - web: - exposure: - include: '*' - endpoint: - health: - show-details: ALWAYS - logfile: - external-file: ./logs/sys-console.log - -# websocket -websocket: - enabled: true - # 璺緞 - path: '/resource/websocket' - # 璁剧疆璁块棶婧愬湴鍧� - allowedOrigins: '*' - -# 寰俊灏忕▼搴忛厤缃俊鎭� -wx: - miniapp: - configs: - - appid: # 浣犵殑appid - secret: # 浣犵殑secret - token: #寰俊灏忕▼搴忔秷鎭湇鍔″櫒閰嶇疆鐨則oken - aesKey: #寰俊灏忕▼搴忔秷鎭湇鍔″櫒閰嶇疆鐨凟ncodingAESKey - msgDataFormat: JSON - - # 浼佷笟寰俊搴旂敤 -wechat: - cp: - corpId: - appConfigs: - - agentId: - secret: '' - token: '' - aesKey: '' - -spring: + name: mcp-server ai: - openai: - api-key: sk-xX - base-url: https://api.pandarobot.chat - ollama: - base-url: http://localhost:11434 - init: - pull-model-strategy: always - timeout: 60s - max-retries: 1 mcp: - client: - enabled: true - name: call-mcp-server - sse: - connections: - server1: - url: http://127.0.0.1:8080 - + server: + name: webmvc-mcp-server + version: 1.0.0 + type: SYNC + sse-message-endpoint: /mcp/messages -- Gitblit v1.9.3