transport

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package transport provides the transport layer implementations for the MCP protocol.

This package contains the Transport interface and implementations for different communication methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTransport

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

BaseTransport provides common transport functionality

func (*BaseTransport) GetDebugHandler added in v1.2.2

func (t *BaseTransport) GetDebugHandler() DebugHandler

GetDebugHandler returns the current debug handler

func (*BaseTransport) GetLogger added in v1.3.0

func (t *BaseTransport) GetLogger() *slog.Logger

GetLogger returns the current logger, creating a default one if none is set

func (*BaseTransport) GetProtocolVersion added in v1.5.0

func (t *BaseTransport) GetProtocolVersion() string

GetProtocolVersion returns the current protocol version

func (*BaseTransport) HandleMessage

func (t *BaseTransport) HandleMessage(message []byte) ([]byte, error)

HandleMessage handles an incoming message

func (*BaseTransport) SetDebugHandler added in v1.2.2

func (t *BaseTransport) SetDebugHandler(handler DebugHandler)

SetDebugHandler sets the debug handler

func (*BaseTransport) SetLogger added in v1.3.0

func (t *BaseTransport) SetLogger(logger *slog.Logger)

SetLogger sets the structured logger

func (*BaseTransport) SetMessageHandler

func (t *BaseTransport) SetMessageHandler(handler MessageHandler)

SetMessageHandler sets the message handler

func (*BaseTransport) SetProtocolVersion added in v1.5.0

func (t *BaseTransport) SetProtocolVersion(version string)

SetProtocolVersion sets the negotiated MCP protocol version

type DebugHandler added in v1.2.2

type DebugHandler func(message string)

DebugHandler represents a function that receives debug messages from the transport

type MessageHandler

type MessageHandler func(message []byte) ([]byte, error)

MessageHandler represents a function that handles incoming messages

type Transport

type Transport interface {
	// Initialize initializes the transport
	Initialize() error

	// Start starts the transport
	Start() error

	// Stop stops the transport
	Stop() error

	// Send sends a message over the transport.
	Send(message []byte) error

	// Receive receives a message from the transport.
	Receive() ([]byte, error)

	// SetMessageHandler sets the message handler
	SetMessageHandler(handler MessageHandler)

	// SetDebugHandler sets a handler for debug messages
	SetDebugHandler(handler DebugHandler)

	// SetLogger sets the structured logger
	SetLogger(logger *slog.Logger)

	// GetLogger returns the current logger
	GetLogger() *slog.Logger

	// SetProtocolVersion sets the negotiated MCP protocol version
	SetProtocolVersion(version string)

	// GetProtocolVersion returns the current protocol version
	GetProtocolVersion() string
}

Transport represents a communication transport for MCP messages.

Directories

Path Synopsis
Package grpc provides a gRPC transport implementation for the MCP protocol.
Package grpc provides a gRPC transport implementation for the MCP protocol.
Package http provides a Streamable HTTP implementation of the MCP transport.
Package http provides a Streamable HTTP implementation of the MCP transport.
Package mqtt provides a MQTT implementation of the MCP transport.
Package mqtt provides a MQTT implementation of the MCP transport.
Package nats provides a NATS implementation of the MCP transport.
Package nats provides a NATS implementation of the MCP transport.
Package sse provides a Server-Sent Events implementation of the MCP transport.
Package sse provides a Server-Sent Events implementation of the MCP transport.
Package stdio provides a standard I/O implementation of the MCP transport.
Package stdio provides a standard I/O implementation of the MCP transport.
Package udp provides a UDP implementation of the MCP transport.
Package udp provides a UDP implementation of the MCP transport.
Package unix provides a Unix Domain Socket implementation of the MCP transport.
Package unix provides a Unix Domain Socket implementation of the MCP transport.
Package ws provides a WebSocket implementation of the MCP transport.
Package ws provides a WebSocket implementation of the MCP transport.

Jump to

Keyboard shortcuts

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