Documentation
¶
Index ¶
- Constants
- func RunProxy(opts ProxyOptions) error
- func StartServer(config *ProxyConfig) error
- func StartServerWithContext(ctx context.Context, config *ProxyConfig) error
- type Client
- type Config
- type MCPClientConfigV2
- type MCPClientType
- type MCPProxyConfigV2
- type MCPServerType
- type MiddlewareFunc
- type OptionsV2
- type ProxyConfig
- type ProxyOptions
- type SSEMCPClientConfig
- type Server
- type StdioMCPClientConfig
- type StreamableMCPClientConfig
- type ToolFilterConfig
- type ToolFilterMode
Constants ¶
const ( DefaultConfigPath = "config.json" DefaultExpandEnv = true DefaultHTTPTimeout = 10 DefaultInsecure = false DefaultHTTPHeaders = "" )
Default values for proxy options
Variables ¶
This section is empty.
Functions ¶
func RunProxy ¶
func RunProxy(opts ProxyOptions) error
RunProxy is a convenience function that combines LoadConfig and StartServer. This is useful for simple use cases where you want to start the proxy with minimal setup.
Parameters:
- opts: the proxy options (equivalent to command-line flags)
Returns an error if configuration loading or server startup fails.
func StartServer ¶
func StartServer(config *ProxyConfig) error
StartServer starts the HTTP server with the provided configuration. This function blocks until the server is shut down or an error occurs.
The server will listen for shutdown signals (SIGINT, SIGTERM) and gracefully shutdown.
Parameters:
- config: the proxy configuration loaded from LoadConfig
Returns an error if the server fails to start or encounters an error during operation.
func StartServerWithContext ¶
func StartServerWithContext(ctx context.Context, config *ProxyConfig) error
StartServerWithContext starts the HTTP server with the provided configuration and context. This allows for more fine-grained control over server lifecycle.
Parameters:
- ctx: context for controlling server lifecycle
- config: the proxy configuration loaded from LoadConfig
Returns an error if the server fails to start or encounters an error during operation.
Types ¶
type Config ¶
type Config struct {
McpProxy *MCPProxyConfigV2 `json:"mcpProxy"`
McpServers map[string]*MCPClientConfigV2 `json:"mcpServers"`
}
type MCPClientConfigV2 ¶
type MCPClientConfigV2 struct {
TransportType MCPClientType `json:"transportType,omitempty"`
// Stdio
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
// SSE or Streamable HTTP
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
Options *OptionsV2 `json:"options,omitempty"`
}
type MCPClientType ¶
type MCPClientType string
const ( MCPClientTypeStdio MCPClientType = "stdio" MCPClientTypeSSE MCPClientType = "sse" MCPClientTypeStreamable MCPClientType = "streamable-http" )
type MCPProxyConfigV2 ¶
type MCPServerType ¶
type MCPServerType string
const ( MCPServerTypeSSE MCPServerType = "sse" MCPServerTypeStreamable MCPServerType = "streamable-http" )
type ProxyConfig ¶
type ProxyConfig struct {
McpProxy *MCPProxyConfigV2 `json:"mcpProxy"`
McpServers map[string]*MCPClientConfigV2 `json:"mcpServers"`
}
ProxyConfig represents the main configuration for the MCP proxy
func LoadConfig ¶
func LoadConfig(configPath string, insecure, expandEnv bool, httpHeaders string, httpTimeout int) (*ProxyConfig, error)
LoadConfig loads the configuration from a file or URL with the specified options. This is the public API function that external libraries can use.
Parameters:
- configPath: path to config file or HTTP(S) URL
- insecure: allow insecure HTTPS connections by skipping TLS certificate verification
- expandEnv: expand environment variables in config file
- httpHeaders: optional HTTP headers for config URL, format: 'Key1:Value1;Key2:Value2'
- httpTimeout: HTTP timeout in seconds when fetching config from URL
Returns the loaded configuration or an error.
type ProxyOptions ¶
type ProxyOptions struct {
ConfigPath string
Insecure bool
ExpandEnv bool
HTTPHeaders string
HTTPTimeout int
}
ProxyOptions represents the command-line options that can be used when starting the proxy
func NewDefaultProxyOptions ¶
func NewDefaultProxyOptions() ProxyOptions
NewDefaultProxyOptions creates a ProxyOptions struct with default values
type SSEMCPClientConfig ¶
type StdioMCPClientConfig ¶
type ToolFilterConfig ¶
type ToolFilterConfig struct {
Mode ToolFilterMode `json:"mode,omitempty"`
List []string `json:"list,omitempty"`
}
type ToolFilterMode ¶
type ToolFilterMode string
const ( ToolFilterModeAllow ToolFilterMode = "allow" ToolFilterModeBlock ToolFilterMode = "block" )