一、对应配置

MCP服务端配置文件:

spring:
  ai:
    mcp:
      server:
        stdio: true
        name: image-search-mcp-server
        type: SYNC
        version: 1.0.0


  #stdio
  main:
    web-application-type: none
    banner-mode: off
logging:
  pattern:
    console: ""

MCP客户端配置文件:

spring:
  ai:
    openai:
      api-key: "apply for an API key"
      base-url: https://api.openai.com/v1
      chat:
        options:
          model: qwen3-max
          temperature: 0.8
          max-tokens: 500
    mcp:
      client:
#        sse:
#          connections:
#            server1:
#              url: http://localhost:8181
        stdio:
          servers-configuration: classpath:/mcp-servers.json
        type: sync
{
  "mcpServers": {
    "image-search-mcp-server": {
      "command": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Djava.version=17",
        "-jar",
        "/Users/k13726/IdeaProjects/Spring_AI_Demo/spring_ai_mcp_demo/target/spring_ai_mcp_demo-0.0.1-SNAPSHOT.jar"
      ],
      "env": {}
    }
  }
}

"command": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java",为指定启动服务端jar包的java版本,因本地有多个java版本。

配置为stdio类型

Cherry Studio中STDIO模式配置
在这里插入图片描述

调用测试

在这里插入图片描述
注:服务端代码实现请看Spring AI 实现 MCP 服务

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐