Documentation
¶
Index ¶
- Constants
- func RegisterHandler(endpoint string, proxy *MCPProxy, mux *http.ServeMux, ...)
- type CentianProxy
- type CentianProxySession
- type DownstreamConnection
- func (dc *DownstreamConnection) CallTool(ctx context.Context, toolName string, args map[string]any) (*mcp.CallToolResult, error)
- func (dc *DownstreamConnection) Close() error
- func (dc *DownstreamConnection) Connect(ctx context.Context, authHeaders map[string]string) error
- func (dc *DownstreamConnection) IsConnected() bool
- func (dc *DownstreamConnection) Tools() []*mcp.Tool
- type EventProcessor
- type HeaderRoundTripper
- type MCPProxy
Constants ¶
const NamespaceSeparator = "___"
NamespaceSeparator is used to create tool names in an aggregated proxy server.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandler ¶
func RegisterHandler(endpoint string, proxy *MCPProxy, mux *http.ServeMux, options *mcp.StreamableHTTPOptions)
RegisterHandler registers a ServerProvider with the HTTP mux.
Types ¶
type CentianProxy ¶
type CentianProxy struct {
Name string
ServerID string // used to uniquely identify this specific object instance
Config *config.GlobalConfig
Mux *http.ServeMux
Server *http.Server
Logger *logging.Logger // Shared base logger (ONE file handle)
Gateways map[string]*MCPProxy
APIKeys *auth.APIKeyStore
AuthHeader string
}
CentianProxy is the main server struct.
It holds 4 critical components: - mux - used to register URL paths - server - used to serve the mux - logger - main logger for all events in the proxied endpoints - gateways - holds all gateways and proxy endpoints for easy access
Additionally it has a reference to the global config which was loaded to initialize this server.
func NewCentianProxy ¶
func NewCentianProxy(globalConfig *config.GlobalConfig) (*CentianProxy, error)
NewCentianProxy takes a GlobalConfig struct and returns a new CentianProxy.
func (*CentianProxy) Setup ¶
func (c *CentianProxy) Setup() error
Setup uses CentianServer.config to create all gateways and endpoints.
type CentianProxySession ¶
type CentianProxySession struct {
// contains filtered or unexported fields
}
CentianProxySession represents a session with one or more downstream connections. For single-server mode, the map has exactly one entry. For aggregated mode, the map has multiple entries.
func (*CentianProxySession) GetConnectionByName ¶
func (s *CentianProxySession) GetConnectionByName(serverName string) (*DownstreamConnection, error)
GetConnectionByName returns a MCP connection for the given server name.
type DownstreamConnection ¶
type DownstreamConnection struct {
// contains filtered or unexported fields
}
DownstreamConnection represents a connection to a downstream MCP server.
func NewDownstreamConnection ¶
func NewDownstreamConnection(name string, cfg *config.MCPServerConfig) *DownstreamConnection
NewDownstreamConnection creates an unconnected downstream wrapper.
func (*DownstreamConnection) CallTool ¶
func (dc *DownstreamConnection) CallTool(ctx context.Context, toolName string, args map[string]any) (*mcp.CallToolResult, error)
CallTool forwards a tool call to the downstream server.
func (*DownstreamConnection) Close ¶
func (dc *DownstreamConnection) Close() error
Close terminates the downstream connection.
func (*DownstreamConnection) Connect ¶
Connect establishes connection to downstream server authHeaders: additional headers from upstream request (for passthrough auth).
func (*DownstreamConnection) IsConnected ¶
func (dc *DownstreamConnection) IsConnected() bool
IsConnected returns true if connection was established and not yet closed.
func (*DownstreamConnection) Tools ¶
func (dc *DownstreamConnection) Tools() []*mcp.Tool
Tools returns the cached tools (nil if not connected).
type EventProcessor ¶
type EventProcessor struct {
// contains filtered or unexported fields
}
EventProcessor is used to call the main processing loop for any MCP transport method.
func NewEventProcessor ¶
func NewEventProcessor(logger *logging.Logger, processors *processor.Chain) *EventProcessor
NewEventProcessor returns a new EventProcessor with the provided logger and processors.
func (*EventProcessor) Process ¶
func (ep *EventProcessor) Process(event common.McpEventInterface) error
Process starts the main event loop processing, including logging and any configured processors.
type HeaderRoundTripper ¶
type HeaderRoundTripper struct {
Base http.RoundTripper
Headers map[string]string
}
HeaderRoundTripper is used to store.
type MCPProxy ¶
type MCPProxy struct {
// contains filtered or unexported fields
}
MCPProxy is a unified proxy that handles both aggregated (multiple servers with namespaced tools) and single-server (pass-through) modes.
Mode is controlled by the namespaceTools flag:
- true: Aggregated mode - tools are prefixed with "serverName__"
- false: Single mode - tools pass through with original names
func NewAggregatedProxy ¶
func NewAggregatedProxy(name, endpoint string, gatewayConfig *config.GatewayConfig) *MCPProxy
NewAggregatedProxy creates a proxy that aggregates multiple downstream servers. Tools from each server are namespaced as "serverName__toolName" to avoid collisions.
func NewSingleProxy ¶
func NewSingleProxy(serverName, endpoint string, serverConfig *config.MCPServerConfig) *MCPProxy
NewSingleProxy creates a proxy for a single downstream server. Tools pass through with their original names (no namespacing).
func (*MCPProxy) GetServerForRequest ¶
GetServerForRequest returns (or creates) an MCP server for the given HTTP request's session.
func (*MCPProxy) NewMcpServer ¶
NewMcpServer returns a new *mcp.Server based on the MCPProxy name.