chassis

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 19 Imported by: 0

README

chassis — unified HTTP + MCP server on one port

chassis multiplexes HTTP/1.1, HTTP/2, HTTP/3 and MCP-over-QUIC on a single port using TLS ALPN negotiation.

TCP :4433 ─── TLS ────► HTTP/1.1 + HTTP/2

UDP :4433 ─── QUIC ──┬─ ALPN "h3"          ──► HTTP/3  (same handler)
                      └─ ALPN "mcp-quic-v1" ──► MCP JSON-RPC

HTTP/2 responses include an Alt-Svc header advertising HTTP/3 availability.

Quick start

srv, _ := chassis.New(chassis.Config{
    Addr:      ":4433",
    Handler:   mux,
    MCPServer: mcpServer,
    TLS:       chassis.DevelopmentTLSConfig(),
})
go srv.Start(ctx)
defer srv.Stop(context.Background())

TLS modes

Function Use case
DevelopmentTLSConfig() Self-signed ECDSA P-256, 1-year expiry
ProductionTLSConfig(cert, key) Load certs from PEM files

Both configurations include ALPN protocols ["h3", "mcp-quic-v1"].

Exported API

Symbol Description
Server Unified TCP + QUIC server
Config Addr, TLS, Handler, MCPServer, Logger
New(cfg) Create server
Start(ctx) Launch listeners (blocks)
Stop(ctx) Graceful shutdown
DevelopmentTLSConfig() Self-signed dev certificate
ProductionTLSConfig(cert, key) Production certificate
GenerateSelfSignedCert() ECDSA P-256 certificate

Documentation

Overview

Package chassis provides a unified server exposing HTTP and MCP on the same port.

Two listeners on the same port:

  • TCP → HTTP/1.1 + HTTP/2 (TLS) — curl-friendly REST API + static files
  • UDP → QUIC with ALPN demux: "h3" → HTTP/3 (same handler as TCP) "mcp-quic-v1" → MCP JSON-RPC over QUIC stream

The HTTP responses include an Alt-Svc header advertising HTTP/3, so HTTP/2 clients that support it can upgrade transparently.

In development mode, a self-signed ECDSA P-256 cert is generated automatically. In production, supply cert/key files via config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DevelopmentTLSConfig

func DevelopmentTLSConfig() (*tls.Config, error)

DevelopmentTLSConfig generates a self-signed TLS config with dual ALPN: "h3" for HTTP/3 and the MCP protocol for MCP over QUIC.

func GenerateSelfSignedCert

func GenerateSelfSignedCert() (tls.Certificate, error)

GenerateSelfSignedCert generates an ECDSA P-256 self-signed cert for development. NOT for production — use Let's Encrypt or a real CA.

func ProductionTLSConfig

func ProductionTLSConfig(certFile, keyFile string) (*tls.Config, error)

ProductionTLSConfig loads cert/key from files with dual ALPN.

Types

type Config

type Config struct {
	Addr      string       // Listen address (e.g. ":8080") — TCP + UDP same port
	TLS       *tls.Config  // nil = auto-generate self-signed
	CertFile  string       // production cert path
	KeyFile   string       // production key path
	Handler   http.Handler // HTTP handler (mux with API + static)
	MCPServer *mcp.Server  // MCP server (nil = MCP disabled)
	Logger    *slog.Logger

	// MCPHandlerOpts are passed to mcpquic.NewHandler.
	MCPHandlerOpts []mcpquic.HandlerOption
}

Config holds configuration for the chassis server.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the unified chassis. It runs: - HTTP/1.1+HTTP/2 on TCP (curl-friendly, API first) - HTTP/3 + MCP-over-QUIC on UDP (same port, ALPN demux)

func New

func New(cfg Config) (*Server, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start launches both TCP and UDP listeners. TCP serves HTTP/1.1+HTTP/2 (TLS). UDP serves QUIC (HTTP/3 + MCP).

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down both TCP and QUIC listeners.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL