spring-projects / spring-projects/spring-ai
MCP server does not work with custom server.servlet.context-path
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Environment
Spring Boot Version:
<spring-boot.version>3.5.3</spring-boot.version>
Dependency:
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
<version>1.0.0</version>
</dependency>
Configuration
spring.ai.mcp.server.type=sync
spring.ai.mcp.server.name=mcp-server-aigc-tools
spring.ai.mcp.server.version=1.0.0
With this configuration, I can successfully connect to the MCP service using a third-party MCP tool at:
http://localhost:9000/sse
Problem
When I add the following configuration:
server.servlet.context-path=/hsrcm/hsrcm-aigc-tool/v
I expect the MCP endpoint to be:
http://localhost:9000/hsrcm/hsrcm-aigc-tool/v/sse
However, I cannot connect to this URL no matter what I try.
The third-party tools I am using are Trae and CherryStudio, and neither of them can connect successfully.
Expected Behavior
The MCP service should be accessible at the new path with the configured context:
http://localhost:9000/hsrcm/hsrcm-aigc-tool/v/sse
Actual Behavior
Connection fails when using the new path.
Question
Could you please provide the correct way to configure MCP with a custom server.servlet.context-path?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with spring-ai-starter-mcp-server-webmvc 1.0.0, the listed MCP properties, and server.servlet.context-path set to /hsrcm/hsrcm-aigc-tool/v. Compare connections to /sse and /hsrcm/hsrcm-aigc-tool/v/sse using Trae or CherryStudio. Done means the MCP service accepts connections at the configured path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100