Class SpringExampleApplication
java.lang.Object
org.apache.juneau.examples.mcp.spring.SpringExampleApplication
A minimal Spring Boot application that serves
SpringExampleMcpServer on embedded Tomcat.
Run main and the MCP endpoint is available at http://localhost:8080/mcp
(default Spring Boot port). Point ExampleClient at
that URL, or drive it with any MCP client. The three @Bean methods are the entire integration:
- the
GreetingServicethe MCP tool resolves via Spring DI; - the
SpringExampleMcpServerservlet itself; and - a
ServletRegistrationBeanmounting it at/*(so the MCP operation lands at/mcp).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe Spring-managed service injected into the MCPgreettool.static voidBoots the application.org.springframework.boot.web.servlet.ServletRegistrationBean<SpringExampleMcpServer>Mounts the MCP servlet on the embedded container.The MCP servlet bean (constructed by Spring so it participates in the application context).
-
Constructor Details
-
SpringExampleApplication
public SpringExampleApplication()
-
-
Method Details
-
greetingService
The Spring-managed service injected into the MCPgreettool.- Returns:
- A new
GreetingService.
-
springExampleMcpServer
The MCP servlet bean (constructed by Spring so it participates in the application context).- Returns:
- A new
SpringExampleMcpServer.
-
mcpServletRegistration
@Bean public org.springframework.boot.web.servlet.ServletRegistrationBean<SpringExampleMcpServer> mcpServletRegistration(SpringExampleMcpServer servlet) Mounts the MCP servlet on the embedded container.- Parameters:
servlet- The MCP servlet bean.- Returns:
- The registration mapping the servlet at
/*.
-
main
Boots the application.- Parameters:
args- Standard Spring Boot arguments.
-