transport

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransportHTTP           = "http"
	TransportStreamableHTTP = "streamable-http"
	TransportSSE            = "sse"
	TransportStdio          = "stdio"
)

Variables

View Source
var (
	// GlobalTraceEnabled controls whether HTTP/SSE frame tracing is enabled
	// This can be set by CLI flags or other callers
	GlobalTraceEnabled = false
)

Functions

func CreateHTTPClient

func CreateHTTPClient(cfg *HTTPTransportConfig) (*client.Client, error)

CreateHTTPClient creates a new MCP client using HTTP transport

func CreateSSEClient

func CreateSSEClient(cfg *HTTPTransportConfig) (*client.Client, error)

CreateSSEClient creates a new MCP client using SSE transport

func DetermineTransportType

func DetermineTransportType(serverConfig *config.ServerConfig) string

DetermineTransportType determines the transport type based on URL and config

func IsEndpointDeprecatedError

func IsEndpointDeprecatedError(err error) bool

IsEndpointDeprecatedError checks if an error indicates a deprecated endpoint (HTTP 410)

func TagConnectionContext

func TagConnectionContext(ctx context.Context, source ConnectionSource) context.Context

TagConnectionContext tags a context with the connection source

Types

type ConnectionSource

type ConnectionSource string

ConnectionSource identifies the origin of a connection

const (
	// ConnectionSourceTCP identifies connections from TCP listener (browsers, remote clients)
	ConnectionSourceTCP ConnectionSource = "tcp"
	// ConnectionSourceTray identifies connections from tray via Unix socket or named pipe
	ConnectionSourceTray ConnectionSource = "tray"
)

func GetConnectionSource

func GetConnectionSource(ctx context.Context) ConnectionSource

GetConnectionSource retrieves the connection source from context

type ErrEndpointDeprecated

type ErrEndpointDeprecated struct {
	URL            string `json:"url"`
	Message        string `json:"message"`
	MigrationGuide string `json:"migration_guide,omitempty"`
	NewEndpoint    string `json:"new_endpoint,omitempty"`
}

ErrEndpointDeprecated represents a 410 Gone response indicating the endpoint has been deprecated

func NewEndpointDeprecatedError

func NewEndpointDeprecatedError(url, message, migrationGuide, newEndpoint string) *ErrEndpointDeprecated

NewEndpointDeprecatedError creates a new ErrEndpointDeprecated from response details

func (*ErrEndpointDeprecated) Error

func (e *ErrEndpointDeprecated) Error() string

type HTTPError

type HTTPError struct {
	StatusCode int               `json:"status_code"`
	Headers    map[string]string `json:"headers"`
	Body       string            `json:"body"`
	Method     string            `json:"method"`
	URL        string            `json:"url"`
	Err        error             `json:"-"` // Original error
}

HTTPError represents detailed HTTP error information for debugging

func NewHTTPError

func NewHTTPError(statusCode int, body, method, url string, headers map[string]string, originalErr error) *HTTPError

EnhancedHTTPError creates an HTTPError with full context

func (*HTTPError) Error

func (e *HTTPError) Error() string

type HTTPResponseDetails

type HTTPResponseDetails struct {
	StatusCode int               `json:"status_code"`
	Headers    map[string]string `json:"headers"`
	Body       string            `json:"body"`
	URL        string            `json:"url"`
	Method     string            `json:"method"`
}

HTTPResponseDetails captures detailed HTTP response information for debugging

type HTTPTransportConfig

type HTTPTransportConfig struct {
	URL          string
	Headers      map[string]string
	OAuthConfig  *client.OAuthConfig
	UseOAuth     bool
	TraceEnabled bool // Enable detailed HTTP/SSE frame tracing
}

HTTPTransportConfig holds configuration for HTTP transport

func CreateHTTPTransportConfig

func CreateHTTPTransportConfig(serverConfig *config.ServerConfig, oauthConfig *client.OAuthConfig) *HTTPTransportConfig

CreateHTTPTransportConfig creates an HTTP transport config from server config

type JSONRPCError

type JSONRPCError struct {
	Code      int         `json:"code"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data,omitempty"`
	HTTPError *HTTPError  `json:"http_error,omitempty"`
}

JSONRPCError represents JSON-RPC specific error information

func NewJSONRPCError

func NewJSONRPCError(code int, message string, data interface{}, httpErr *HTTPError) *JSONRPCError

NewJSONRPCError creates a JSONRPCError with optional HTTP context

func (*JSONRPCError) Error

func (e *JSONRPCError) Error() string

type LoggingTransport

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

LoggingTransport wraps http.RoundTripper to log all HTTP traffic including SSE frames

func NewLoggingTransport

func NewLoggingTransport(base http.RoundTripper, logger *zap.Logger) *LoggingTransport

NewLoggingTransport creates a new logging HTTP transport

func (*LoggingTransport) RoundTrip

func (t *LoggingTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper with comprehensive logging

Jump to

Keyboard shortcuts

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