Class McpChannelInitializer

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
dev.tachyonmcp.core.transport.netty.McpChannelInitializer
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

@Sharable public class McpChannelInitializer extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
Assembles the Netty pipeline for each new MCP channel: validation handlers (endpoint, origin, protocol version, accept header, stateless guard), InteractionHandler, HTTP aggregation, idle timeout, the initialization-phase handler (McpInitializationHandler), and the LifecyclePipelineCoordinator.

In stateless mode, StatelessValidatorHandler is added to reject session-related headers and DELETE methods before they reach protocol handlers.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default max aggregated request body. 64 KB was too small for schemas + tool results.
  • Constructor Summary

    Constructors
    Constructor
    Description
    McpChannelInitializer(String endpointPath, boolean stateless, ServerEngine server, Duration readerIdleTimeout, Duration writerIdleTimeout, int maxContentLength, io.netty.channel.group.ChannelGroup childChannels, @Nullable io.netty.handler.codec.http.cors.CorsConfig corsConfig, @Nullable Consumer<io.netty.channel.ChannelPipeline> pipelineCustomizer)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    initChannel(io.netty.channel.socket.SocketChannel ch)
     

    Methods inherited from class io.netty.channel.ChannelInitializer

    channelRegistered, exceptionCaught, handlerAdded, handlerRemoved

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MAX_CONTENT_LENGTH

      public static final int DEFAULT_MAX_CONTENT_LENGTH
      Default max aggregated request body. 64 KB was too small for schemas + tool results.
      See Also:
  • Constructor Details

    • McpChannelInitializer

      public McpChannelInitializer(String endpointPath, boolean stateless, ServerEngine server, Duration readerIdleTimeout, Duration writerIdleTimeout, int maxContentLength, io.netty.channel.group.ChannelGroup childChannels, @Nullable io.netty.handler.codec.http.cors.CorsConfig corsConfig, @Nullable Consumer<io.netty.channel.ChannelPipeline> pipelineCustomizer)
  • Method Details

    • initChannel

      protected void initChannel(io.netty.channel.socket.SocketChannel ch)
      Specified by:
      initChannel in class io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>