server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package server provides MCP transport serving (stdio/http/both) and the Transport type shared across acidsailor MCP servers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilServer        = errors.New("nil mcp server")
	ErrInvalidTransport = errors.New("invalid transport")
	ErrInvalidAddr      = errors.New("invalid server address")
	ErrServe            = errors.New("serve")
	ErrShutdown         = errors.New("shutdown")
)

Sentinels for server failures, wrapped with detail at the entry point.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option configures a Server.

func WithAddr

func WithAddr(addr string) Option

WithAddr sets the HTTP listen address (default ":8080"). Ignored for the stdio transport.

func WithReadHeaderTimeout

func WithReadHeaderTimeout(d time.Duration) Option

WithReadHeaderTimeout sets the HTTP server's read-header timeout (default 30s).

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) Option

WithShutdownTimeout sets the HTTP graceful-shutdown timeout (default 30s).

func WithTransport

func WithTransport(t Transport) Option

WithTransport sets the transport (default Stdio).

type Server

type Server struct {
	MCP *mcp.Server // escape hatch to the underlying server
	// contains filtered or unexported fields
}

Server serves an mcp.Server over the configured transport(s).

func New

func New(mcpServer *mcp.Server, opts ...Option) *Server

New builds a Server wrapping mcpServer. Defaults: addr ":8080", Stdio transport, both timeouts 30s.

func (*Server) ListenAndServe

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

ListenAndServe validates config, serves on the configured transport(s), blocks until ctx is cancelled, then runs graceful shutdown.

type Transport

type Transport string

Transport selects the MCP transport mechanism.

const (
	Stdio Transport = "stdio" // stdin/stdout
	HTTP  Transport = "http"  // streamable HTTP
	Both  Transport = "both"  // stdio + HTTP concurrently
)

Supported transports.

func ParseTransport

func ParseTransport(s string) (Transport, error)

ParseTransport parses s into a Transport, wrapping ErrInvalidTransport for an unsupported value.

func (*Transport) UnmarshalText

func (t *Transport) UnmarshalText(b []byte) error

UnmarshalText lets text-based config loaders (env, flag, json) parse a Transport.

Jump to

Keyboard shortcuts

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