proxy

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnhanceToolsList

func EnhanceToolsList(cfg *config.Config, agentID, backendID string, result *model.ToolsListResult) *model.ToolsListResult

EnhanceToolsList filters and enhances tools/list responses per agent.

func HealthCheck

func HealthCheck(cfgMgr *config.Manager) http.HandlerFunc

HealthCheck returns a handler that checks backend health.

func NewMux

func NewMux(
	handler *Handler,
	healthCheck http.HandlerFunc,
	approvalCallback http.Handler,
	apiRouter http.Handler,
) *http.ServeMux

NewMux creates the main HTTP router.

func ParseToolsListResult

func ParseToolsListResult(resp *model.Response) (*model.ToolsListResult, error)

ParseToolsListResult unmarshals the tools/list result from a JSON-RPC response.

Types

type Forwarder

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

Forwarder sends JSON-RPC requests to backend MCP servers.

func NewForwarder

func NewForwarder(cfgMgr *config.Manager) *Forwarder

NewForwarder creates a forwarder that sends requests to backend MCP servers.

func (*Forwarder) Forward

func (f *Forwarder) Forward(ctx context.Context, backendID string, rpcReq *model.Request, sessionID string) (*model.Response, string, error)

Forward sends a JSON-RPC request to the specified backend and returns the response. sessionID is the MCP session ID to include in the request; respSessionID is the session ID returned by the backend (if any).

func (*Forwarder) ForwardRaw

func (f *Forwarder) ForwardRaw(ctx context.Context, backendID string, body []byte, sessionID string) ([]byte, int, string, error)

ForwardRaw sends raw bytes to the backend and returns raw response bytes. Used for passthrough of non-tools/call messages.

type Handler

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

Handler is the main MCP proxy HTTP handler. Routes: /agents/{agentID}/mcp

func NewHandler

func NewHandler(
	cfgMgr *config.Manager,
	forwarder *Forwarder,
	sessions *SessionManager,
	stages []pipeline.Stage,
	queue *pipeline.FIFOQueue,
	auditLog *audit.Logger,
) *Handler

NewHandler creates the MCP proxy handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes incoming MCP requests by method (tools/call, tools/list, or passthrough).

type SessionManager

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

SessionManager tracks MCP sessions (mcp-session-id) per agent.

func NewSessionManager

func NewSessionManager() *SessionManager

NewSessionManager creates a session manager for tracking MCP sessions.

func (*SessionManager) Get

func (sm *SessionManager) Get(agentID string) string

Get returns the backend session ID for an agent, or empty string if none.

func (*SessionManager) Set

func (sm *SessionManager) Set(agentID, sessionID string)

Set stores the backend session ID for an agent.

Jump to

Keyboard shortcuts

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