Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description 我用spring ai 实现 mcp server ,如果采用stdio的方式 打成jar包,然后用charry studio 配置,能够正常访问

但是通过spring ai 实现mcp server ,采用sse方式 服务正常启动,但是浏览器死活访问不到sse节点 localhost:8080/sse 通过postman也无法访问(控制台没有任何报错信息)

问题的原因是什么?

Environment pom.xml:

<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-mcp-server-webmvc-spring-boot-starter</artifactId>
  <version>1.0.0-M6</version>
</dependency>

<dependency>
  <groupId>org.springframework.ai</groupId>
  <artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
  <version>1.0.0-M7</version>
</dependency>

Steps to reproduce 项目结构非常简单,服务也是正常启动 Image 但是页面上就是一直无法访问: localhost:8080/sse 通过postman也无法访问

Expected behavior A clear and concise description of what you expected to happen.

Minimal Complete Reproducible example Please provide a failing test or a minimal complete verifiable example that reproduces the issue. Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

Comment From: shirehappy

Image 配置也很简单

就是页面请求不到

Image

Comment From: hymmyh

为什么 1.0.0-M6 和 1.0.0-M7 混用,只用1.0.0-M7不就可以?yml 的配置也没有对齐。

Comment From: shirehappy

为什么 1.0.0-M6 和 1.0.0-M7 混用,只用1.0.0-M7不就可以?yml 的配置也没有对齐。

你好,谢谢答复! 1.版本统一用M6或者M7 ,不混用,还是存在这个问题 2.yml里面,ai.mcp.server不管是从头开始的,还是在spring下面的,也还是存在这个问题。

现在就是服务正常启动,但是启动的日志里面没有类似于tools register success这种,然后页面请求:http://localhost:8080/sse 无法请求到资源

Comment From: fireman-ace

sse use this org.springframework.ai spring-ai-starter-mcp-server-webflux

Comment From: kkxrrh

服务端用这个 org.springframework.ai spring-ai-starter-mcp-server-webmvc 我试了好几遍 webflux 是会 404 没招

Comment From: suxuanning

+1

Comment From: xizihong

I also encountered this issue, for a while I could successfully access /sse, but after that, I could no longer access it during startup, and it reported an error 404

Comment From: rong-zhi-yi

服务端必须用这个,否则会报404,这是个bug

org.springframework.ai spring-ai-starter-mcp-server-webmvc

Comment From: xizihong

I found the cause of the problem, adding the following dependency will not have this issue

      <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
        </dependency>

If this dependency is introduced, this error will occur.

        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-starter-mcp-server-webflux</artifactId>
        </dependency>

Although the official documentation recommends using spring-ai-starter-mcp-server-webflux for sse

Comment From: shirehappy

问题已解决,就是用kkxrrh的方法,pom.xml删除webflux依赖就可以了。

这应该是官方的问题,也不清楚为啥有这个问题,官方还要推荐webflux

Comment From: xulisha123

+1 WTF

Comment From: Ch1ldKing

Springboot Version: 3.1.0 Dependency:

<dependencyManagement>  
    <dependencies>       
        <dependency>          
            <groupId>org.springframework.ai</groupId>  
            <artifactId>spring-ai-bom</artifactId>  
            <version>1.0.0-SNAPSHOT</version>  
            <type>pom</type>  
            <scope>import</scope>  
        </dependency>    
    </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>  
      <groupId>org.springframework.ai</groupId>  
      <artifactId>spring-ai-starter-mcp-server-webflux</artifactId>  
  </dependency>
</dependencies>

本人实测 Webflux 模式也可以用,并且可在 Cherry Studio 中可用,但是必须要在 application.yaml 或者 bootstrap.yaml中加上这样一个配置

I have test it on my own with webflux version of mcp-server dependency, also available for SSE in Cherry Studio. But you must add this property to your springboot application:

spring:
  main:
    web-application-type: reactive

我猜原因是因为 webflux 是响应式的(非阻塞的),而正常情况下是 MVC (阻塞式),因此 webflux 不可用

I guess the reason is that webflux is reactive (ASYNC), while under normal circumstances it is in the MVC style (SYNC), so webflux is not available

不过最终本人采用的还是 spring-ai-starter-mcp-server-webmvc,原因是我发现设置 reactive 后 OpenFeign Client 不可用。这里我猜想 FeignClient 是 MVC 阻塞式的

However, in the end, I still adopted spring-ai-starter-mcp-server-webmvc. The reason is that I found that OpenFeign Client was unavailable after setting reactive. Here I suspect that FeignClient is MVC SYNC.

另外,采用 webmvc 会导致 Springboot-Gateway 转发不可用,因为我的 Springboot-gateway 是 reactive 的。本问题待解决

In addition, adopting webmvc will cause Springboot-Gateway forwarding to be unavailable because my Springboot-gateway is reactive. This problem remains to be solved.

Comment From: litiian

以下配置也可以: spring.ai.mcp.server.enabled=true spring.ai.mcp.server.stdio=false spring.ai.mcp.server.name=webflux-mcp-server spring.ai.mcp.server.version=1.0.0 spring.ai.mcp.server.type=ASYNC spring.ai.mcp.server.instructions=This reactive server provides weather information tools and resources spring.ai.mcp.server.sse-message-endpoint=/mcp/messages spring.ai.mcp.server.sse-endpoint=/sse

spring.ai.mcp.server.base-url=/api/v1

spring.ai.mcp.server.capabilities.tool=true spring.ai.mcp.server.capabilities.resource=true spring.ai.mcp.server.capabilities.prompt=true spring.ai.mcp.server.capabilities.completion=true

pom.xml:

org.springframework.ai spring-ai-bom 1.1.0-SNAPSHOT pom import

<dependencies>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-starter-mcp-server-webflux</artifactId>
    </dependency>
    <dependency>
         <groupId>commons-logging</groupId>
         <artifactId>commons-logging</artifactId>
         <version>1.3.0</version>
    </dependency>
</dependencies>

Comment From: koradji2046

我也遇到这个问题,今天下午突然就不行了

pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.5</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.example</groupId>
    <artifactId>mcp-sampling-weather-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <name>Spring AI MCP Sampling - Weather Server</name>
    <description>Sample Spring Boot application demonstrating MCP client and server sampling usage</description>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>1.0.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.properties

# spring.main.web-application-type=none

# NOTE: You must disable the banner and the console logging 
# to allow the STDIO transport to work !!!
spring.main.banner-mode=off
logging.pattern.console=

#spring.ai.mcp.server.stdio=true

spring.ai.mcp.server.name=mcp-sampling-server
spring.ai.mcp.server.version=0.0.1
spring.ai.mcp.server.request-timeout=30s

logging.file.name=./sampling/mcp-weather-webmvc-server/target/mcp-sampling-server.log