ws

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ws provides a WebSocket implementation of the MCP transport.

This package implements the Transport interface using WebSockets, suitable for web applications requiring bidirectional communication.

Index

Constants

View Source
const DefaultShutdownTimeout = 10 * time.Second

DefaultShutdownTimeout is the default timeout for graceful shutdown

View Source
const DefaultWSPath = "/ws"

DefaultWSPath is the default endpoint path for WebSocket connections

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

type Transport struct {
	transport.BaseTransport
	// contains filtered or unexported fields
}

Transport implements the transport.Transport interface for WebSocket

func NewTransport

func NewTransport(addr string) *Transport

NewTransport creates a new WebSocket transport

func (*Transport) GetFullWSPath added in v1.2.1

func (t *Transport) GetFullWSPath() string

GetFullWSPath returns the complete path for the WebSocket endpoint

func (*Transport) Initialize

func (t *Transport) Initialize() error

Initialize initializes the transport

func (*Transport) Receive

func (t *Transport) Receive() ([]byte, error)

Receive receives a message (client mode only)

func (*Transport) Send

func (t *Transport) Send(message []byte) error

Send sends a message

func (*Transport) SetPathPrefix added in v1.2.1

func (t *Transport) SetPathPrefix(prefix string) *Transport

SetPathPrefix sets a prefix for the endpoint path For example, SetPathPrefix("/mcp") will result in endpoint like "/mcp/ws"

func (*Transport) SetWSPath added in v1.2.1

func (t *Transport) SetWSPath(path string) *Transport

SetWSPath sets the path for the WebSocket endpoint

func (*Transport) Start

func (t *Transport) Start() error

Start starts the transport

func (*Transport) Stop

func (t *Transport) Stop() error

Stop stops the transport

Jump to

Keyboard shortcuts

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