Sping Ai黑科技!一键接入Mysql MCP,智能查询数据新玩法!

127 阅读1分钟

Mysql MCP 主要提供SQL语句查询数据库的能力,execute_query :支持select查询、show展示、describe描述;get_table_info:获取数据表的详细结构信息;list_tables:列出数据库中的所有数据表。

LLM + Mysql MCP 可以实现智能查询业务数据,达到减少开发成本,快速应对多变的需求的效果,让复杂点击操作交互方式变成聊天方式,更智能化。

应用场景

我想知道用户的基本信息,和角色权限信息。

快速开始

  • • maven 依赖

    org.springframework.ai spring-ai-starter-mcp-client 1.0.0 org.springframework.ai spring-ai-starter-model-openai 1.0.0

• 配置文件

spring.ai.openai.base-url=https://dashscope.aliyuncs.com/compatible-mode/spring.ai.openai.chat.options.model=qwen-maxspring.ai.openai.api-key=${OPEN_API_KEY}spring.ai.mcp.client.stdio.servers-configuration=classpath:/mcp-servers-config.json

• Excel mcp :mcp-servers-config.json

{  "mcpServers":{    "mysql":{      "command":"npx",      "args":["mysql-mcp-server"],      "env":{        "MYSQL_HOST":"127.0.0.1",        "MYSQL_PORT":"3306",        "MYSQL_USER":"root",        "MYSQL_PASSWORD":"123456",        "MYSQL_DB":"ruoyi"      }    }}}

资料下载方式

点击下载