feat: introduce ServerHttpHeaderValidator replacing ServerTransportSecurityValidator

Same feature set as ServerTransportSecurityValidator but uses a lazy
"header accessor" function to read header values instead of extracting
all headers into a map. Matches more closely what modern frameworks and
JDK APIs do.

Fixes #870

Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
Neeraj Bhatt 2026-09-07 14:21:21 +02:00 • committed by Daniel Garnier-Moiroux
commit 5be2fa0688

View file

@ -209,7 +209,7 @@ class ServerTransportSecurityIntegrationTests {
public Sse() {
transport = HttpServletSseServerTransportProvider.builder()
.messageEndpoint("/mcp/message")
.securityValidator(DefaultServerTransportSecurityValidator.builder()
.httpHeaderValidator(DefaultServerTransportSecurityValidator.builder()
.allowedOrigin("http://localhost:*")
.allowedHost("localhost:*")
.build())
@ -242,7 +242,7 @@ class ServerTransportSecurityIntegrationTests {
public StreamableHttp() {
transport = HttpServletStreamableServerTransportProvider.builder()
.securityValidator(DefaultServerTransportSecurityValidator.builder()
.httpHeaderValidator(DefaultServerTransportSecurityValidator.builder()
.allowedOrigin("http://localhost:*")
.allowedHost("localhost:*")
.build())
@ -276,7 +276,7 @@ class ServerTransportSecurityIntegrationTests {
public Stateless() {
transport = HttpServletStatelessServerTransport.builder()
.securityValidator(DefaultServerTransportSecurityValidator.builder()
.httpHeaderValidator(DefaultServerTransportSecurityValidator.builder()
.allowedOrigin("http://localhost:*")
.allowedHost("localhost:*")
.build())