Class McpServerConfig

java.lang.Object
ai.redouble.examples.mcpserver.McpServerConfig

@Configuration public class McpServerConfig extends Object
The MCP endpoint in three beans: the SDK's stateless HTTP servlet mounted at /mcp like any servlet, and an McpToolServer over it.

The server scans the named packages for @MCP tools, turns each caller into a consumer through the resolver, and answers one question through the access policy: may this consumer use this tool. The same answer decides what the consumer sees listed and what it may call, so grants cannot be probed. What a caller receives is the tool as this application declared it - the input schema generated from its input class, the description from its annotation - and everything a caller sends is checked against that schema before the tool runs. Every call runs as a job under the caller's name, recorded like any other work, and a call that outlives setCallTimeout has its whole workflow cancelled.

This example admits every caller as one consumer, local-agent; a real host authenticates the request first, the way it authenticates any request, and records the principal it admitted in the transport's context extractor.

Since:
0.1 (2026-09-28)
Author:
Andrey Santrosyan
  • Constructor Details

    • McpServerConfig

      public McpServerConfig()
  • Method Details

    • nucleoRuntime

      @Bean(destroyMethod="shutdown") public McpServerConfig.NucleoRuntime nucleoRuntime()
      The runtime's lifecycle, wired by hand: a real application puts nucleo-spring-boot-starter on its classpath, which starts the dispatcher with the application and binds credentials from properties. The other examples of this module are plain mains, so the starter stays off its classpath and this bean does the starter's one job here. Beans are destroyed in reverse creation order, so the server below closes before the dispatcher drains.
    • mcpTransport

      @Bean public io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport mcpTransport()
    • mcpServlet

      @Bean public org.springframework.boot.web.servlet.ServletRegistrationBean<io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport> mcpServlet(io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport transport)
    • mcpToolServer

      @Bean(destroyMethod="close") public McpToolServer mcpToolServer(io.modelcontextprotocol.server.transport.HttpServletStatelessServerTransport transport, McpServerConfig.NucleoRuntime runtime)