http

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 11 Imported by: 0

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

View Source
const DefaultAPIPath = "/api"

DefaultAPIPath is the default endpoint path for HTTP API

View Source
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

func NewTransport(addr string) *Transport

NewTransport creates a new HTTP transport

func (*Transport) GetAddr added in v1.2.2

func (t *Transport) GetAddr() string

GetAddr returns the transport's address

func (*Transport) GetFullAPIPath added in v1.2.1

func (t *Transport) GetFullAPIPath() string

GetFullAPIPath returns the complete path for the HTTP API endpoint

func (*Transport) Initialize

func (t *Transport) Initialize() error

Initialize initializes the transport

func (*Transport) Receive

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

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) Send

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

Send sends a JSON-RPC request to a specified endpoint

func (*Transport) SetAPIPath added in v1.2.1

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

SetAPIPath sets the path for the HTTP API endpoint

func (*Transport) SetPathPrefix added in v1.2.1

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

SetPathPrefix sets a prefix for all endpoint paths For example, SetPathPrefix("/mcp") will result in endpoint like "/mcp/api"

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