I'm trying to create a Java-based MCP server following this tutorial, but I'm getting a "Server disconnected" error when attempting to connect it to Claude Desktop.
/Users/myname/.sdkman/candidates/java/current/bin/java
)spring-ai-starter-mcp-server-webmvc
claude_desktop_config.json
){
"mcpServers": {
"fran-mcp": {
"command": "/Users/myname/.sdkman/candidates/java/current/bin/java",
"args": [
"-jar",
"/Users/myname/IdeaProjects/mcp-server/target/mcp-server-0.0.1-SNAPSHOT.jar"
]
}
}
}
spring.application.name=mcp-server
server.port=8081
spring.ai.mcp.server.name=fran-mcp
spring.main.web-application-type=none
spring.ai.mcp.server.version=0.0.1
# Disable banner and console logging for STDIO transport
spring.main.banner-mode=off
logging.pattern.console=
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
The server appears to start successfully but disconnects immediately after the initialization message:
2025-08-23T20:57:11.518Z [fran-mcp] [info] Server started and connected successfully
2025-08-23T20:57:11.522Z [fran-mcp] [info] Message from client: {"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"claude-ai","version":"0.1.0"}},"jsonrpc":"2.0","id":0}
2025-08-23T20:57:19.192Z [fran-mcp] [info] Server transport closed
2025-08-23T20:57:19.194Z [fran-mcp] [info] Server transport closed unexpectedly, this is likely due to the process exiting early
2025-08-23T20:57:19.194Z [fran-mcp] [error] Server disconnected
Thank you.
Changed the dependency from
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
</dependency>
to
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-server</artifactId>
</dependency>
and it's working now after regenerating the jar and restarting Claude Desktop.