Documentation
¶
Overview ¶
Package http provides a Streamable HTTP implementation of the MCP transport.
This package implements the Transport interface using Streamable HTTP, following the MCP 2025-03-26 specification. It supports streaming HTTP responses, session management, OAuth authentication, and proper content negotiation.
Index ¶
- Constants
- type HTTPHeaderFunc
- type Option
- type SessionInfo
- type Transport
- func (t *Transport) GetAddr() string
- func (t *Transport) GetFullAPIPath() string
- func (t *Transport) GetFullMCPEndpoint() string
- func (t *Transport) Initialize() error
- func (t *Transport) Receive() ([]byte, error)
- func (t *Transport) Send(message []byte) error
- func (t *Transport) SetAPIPath(path string) *Transport
- func (t *Transport) SetClientMode(isClient bool) *Transport
- func (t *Transport) SetMCPEndpoint(path string) *Transport
- func (t *Transport) SetPathPrefix(prefix string) *Transport
- func (t *Transport) Start() error
- func (t *Transport) Stop() error
Constants ¶
const DefaultMCPEndpoint = "/mcp"
DefaultMCPEndpoint is the default MCP endpoint path
const DefaultShutdownTimeout = 10 * time.Second
DefaultShutdownTimeout is the default timeout for graceful shutdown
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPHeaderFunc ¶ added in v1.6.0
HTTPHeaderFunc is a function type for generating dynamic headers
type Option ¶ added in v1.6.0
type Option func(*Transport)
Option is a function that configures a Transport
func WithHTTPClient ¶ added in v1.6.0
WithHTTPClient returns an option that sets a custom HTTP client
func WithHeaders ¶ added in v1.6.0
WithHeaders returns an option that sets additional HTTP headers
func WithMCPEndpoint ¶ added in v1.6.0
WithMCPEndpoint returns an option that sets the MCP endpoint path
func WithPathPrefix ¶ added in v1.6.0
WithPathPrefix returns an option that sets the path prefix for all endpoints
func WithTimeout ¶ added in v1.6.0
WithTimeout returns an option that sets the HTTP timeout
type SessionInfo ¶ added in v1.6.0
SessionInfo holds information about an active session
type Transport ¶
type Transport struct {
transport.BaseTransport
// contains filtered or unexported fields
}
Transport implements the transport.Transport interface for Streamable HTTP
func NewClientTransport ¶ added in v1.6.0
NewClientTransport creates a new Streamable HTTP transport configured for client mode
func NewServerTransport ¶ added in v1.6.0
NewServerTransport creates a new Streamable HTTP transport configured for server mode
func NewTransport ¶
NewTransport creates a new Streamable HTTP transport
func (*Transport) GetFullAPIPath ¶ added in v1.2.1
GetFullAPIPath returns the complete path for the MCP endpoint (compatibility alias)
func (*Transport) GetFullMCPEndpoint ¶ added in v1.6.0
GetFullMCPEndpoint returns the complete path for the MCP endpoint
func (*Transport) Initialize ¶
Initialize initializes the transport
func (*Transport) SetAPIPath ¶ added in v1.2.1
SetAPIPath sets the path for the MCP endpoint (compatibility alias)
func (*Transport) SetClientMode ¶ added in v1.6.0
SetClientMode sets the transport to client mode
func (*Transport) SetMCPEndpoint ¶ added in v1.6.0
SetMCPEndpoint sets the path for the MCP endpoint
func (*Transport) SetPathPrefix ¶ added in v1.2.1
SetPathPrefix sets a prefix for all endpoint paths