Stateless MCP server: no server customizer (instructions come from properties only)
Repo: spring-projects/spring-ai. Module: spring-ai-autoconfigure-mcp-server-common (McpServerStatelessAutoConfiguration), 2.0.1.
Problem
McpServerAutoConfiguration applies an optional McpSyncServerCustomizer / McpAsyncServerCustomizer to the server builder. McpServerStatelessAutoConfiguration has no such hook. It sets serverBuilder.instructions(serverProperties.getInstructions()) and builds the server.
So a stateless server's instructions can only be a static property. An app that renders them (from a template, with the environment's app URL, or from a file) has no supported way to set them.
Proposal
McpStatelessSyncServerCustomizer / McpStatelessAsyncServerCustomizer, applied to the builder the same way as the stateful ones.
Our workaround
A static BeanPostProcessor that finds the McpServerProperties bean and calls setInstructions(..) with our rendered text before the stateless server reads it. About 15 lines, and it depends on the auto-configuration reading the properties late.
(issue generated with AI assistance)
Source: spring-projects/spring-ai