mcpproxy

package
v0.0.0-...-7a8aca8 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemStore

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

MemStore implements the SessionManager interface

func NewMemStore

func NewMemStore() *MemStore

NewMemStore creates a new session store

func (*MemStore) Delete

func (s *MemStore) Delete(sessionID string)

Delete removes a sessionID from the store

func (*MemStore) Get

func (s *MemStore) Get(sessionID string) (string, bool)

Get retrieves the backend endpoint for a sessionID

func (*MemStore) New

func (s *MemStore) New() string

func (*MemStore) Set

func (s *MemStore) Set(sessionID, endpoint string)

Set stores a sessionID and its corresponding backend endpoint

type SSEOption

type SSEOption func(*SSEServer)

SSEOption defines a function type for configuring SSEServer

func WithKeepAlive

func WithKeepAlive(keepAlive bool) SSEOption

func WithKeepAliveInterval

func WithKeepAliveInterval(keepAliveInterval time.Duration) SSEOption

func WithMessageEndpoint

func WithMessageEndpoint(endpoint string) SSEOption

WithMessageEndpoint sets the message endpoint path

type SSEServer

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

SSEServer implements a Server-Sent Events (SSE) based MCP server. It provides real-time communication capabilities over HTTP using the SSE protocol.

func NewSSEServer

func NewSSEServer(server mcpservers.Server, opts ...SSEOption) *SSEServer

NewSSEServer creates a new SSE server instance with the given MCP server and options.

func (*SSEServer) HandleMessage

func (s *SSEServer) HandleMessage(ctx context.Context, req []byte) error

handleMessage processes incoming JSON-RPC messages from clients and sends responses back through both the SSE connection and HTTP response.

func (*SSEServer) ServeHTTP

func (s *SSEServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

handleSSE handles incoming SSE connection requests. It sets up appropriate headers and creates a new session for the client.

type SessionManager

type SessionManager interface {
	New() (sessionID string)
	// Set stores a sessionID and its corresponding backend endpoint
	Set(sessionID, endpoint string)
	// Get retrieves the backend endpoint for a sessionID
	Get(sessionID string) (string, bool)
	// Delete removes a sessionID from the store
	Delete(sessionID string)
}

SessionManager defines the interface for managing session information

type StreamableHTTPOption

type StreamableHTTPOption func(*StreamableHTTPServer)

type StreamableHTTPServer

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

func NewStatelessStreamableHTTPServer

func NewStatelessStreamableHTTPServer(
	server mcpservers.Server,
	opts ...StreamableHTTPOption,
) *StreamableHTTPServer

NewStatelessStreamableHTTPServer creates a new streamable-http server instance

func (*StreamableHTTPServer) ServeHTTP

func (s *StreamableHTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

type StreamableProxy

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

StreamableProxy represents a proxy for the MCP Streamable HTTP transport

func NewStreamableProxy

func NewStreamableProxy(
	backend string,
	headers map[string]string,
	store SessionManager,
) *StreamableProxy

NewStreamableProxy creates a new proxy for the Streamable HTTP transport

func (*StreamableProxy) ServeHTTP

func (p *StreamableProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles both GET and POST requests for the Streamable HTTP transport

Jump to

Keyboard shortcuts

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