Documentation
¶
Overview ¶
Package http provides an HTTP implementation of the MCP transport.
This package implements the Transport interface using HTTP, suitable for applications requiring JSON-RPC communication.
Index ¶
- Constants
- type AsyncMessageHandler
- type Transport
- func (t *Transport) GetAddr() string
- func (t *Transport) GetFullAPIPath() string
- func (t *Transport) Initialize() error
- func (t *Transport) Receive() ([]byte, error)
- func (t *Transport) RegisterAsyncHandler(method string, handler AsyncMessageHandler)
- func (t *Transport) Send(message []byte) error
- func (t *Transport) SetAPIPath(path string) *Transport
- func (t *Transport) SetPathPrefix(prefix string) *Transport
- func (t *Transport) Start() error
- func (t *Transport) Stop() error
Constants ¶
const DefaultAPIPath = "/api"
DefaultAPIPath is the default endpoint path for HTTP API
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 AsyncMessageHandler ¶
type AsyncMessageHandler func(message []byte)
AsyncMessageHandler is a function that handles asynchronous JSON-RPC notifications
type Transport ¶
type Transport struct {
transport.BaseTransport
// contains filtered or unexported fields
}
Transport implements the transport.Transport interface for HTTP
func NewTransport ¶
NewTransport creates a new HTTP transport
func (*Transport) GetFullAPIPath ¶ added in v1.2.1
GetFullAPIPath returns the complete path for the HTTP API endpoint
func (*Transport) Initialize ¶
Initialize initializes the transport
func (*Transport) Receive ¶
Receive is not directly applicable for HTTP transport (HTTP is request/response based)
func (*Transport) RegisterAsyncHandler ¶
func (t *Transport) RegisterAsyncHandler(method string, handler AsyncMessageHandler)
RegisterAsyncHandler registers a handler for asynchronous message processing
func (*Transport) SetAPIPath ¶ added in v1.2.1
SetAPIPath sets the path for the HTTP API endpoint
func (*Transport) SetPathPrefix ¶ added in v1.2.1
SetPathPrefix sets a prefix for all endpoint paths For example, SetPathPrefix("/mcp") will result in endpoint like "/mcp/api"