mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-06-27 17:13:31 +00:00
parent
fc0d939e16
commit
316370be1c
4 changed files with 37 additions and 41 deletions
|
@ -19,15 +19,16 @@ const (
|
|||
|
||||
// Common path configuration for all transport modes
|
||||
type PathsConfig struct {
|
||||
SSE string `yaml:"sse"`
|
||||
Messages string `yaml:"messages"`
|
||||
SSE string `yaml:"sse"`
|
||||
Messages string `yaml:"messages"`
|
||||
StreamableHTTP string `yaml:"streamable_http"` // Path for streamable HTTP requests
|
||||
}
|
||||
|
||||
// StdioConfig contains stdio-specific configuration
|
||||
type StdioConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
UserCommand string `yaml:"user_command"` // The command provided by the user
|
||||
WorkDir string `yaml:"work_dir"` // Working directory (optional)
|
||||
UserCommand string `yaml:"user_command"` // The command provided by the user
|
||||
WorkDir string `yaml:"work_dir"` // Working directory (optional)
|
||||
Args []string `yaml:"args,omitempty"` // Additional arguments
|
||||
Env []string `yaml:"env,omitempty"` // Environment variables
|
||||
}
|
||||
|
@ -85,18 +86,18 @@ type DefaultConfig struct {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
AuthServerBaseURL string
|
||||
ListenPort int `yaml:"listen_port"`
|
||||
BaseURL string `yaml:"base_url"`
|
||||
Port int `yaml:"port"`
|
||||
JWKSURL string
|
||||
TimeoutSeconds int `yaml:"timeout_seconds"`
|
||||
PathMapping map[string]string `yaml:"path_mapping"`
|
||||
Mode string `yaml:"mode"`
|
||||
CORSConfig CORSConfig `yaml:"cors"`
|
||||
TransportMode TransportMode `yaml:"transport_mode"`
|
||||
Paths PathsConfig `yaml:"paths"`
|
||||
Stdio StdioConfig `yaml:"stdio"`
|
||||
AuthServerBaseURL string
|
||||
ListenPort int `yaml:"listen_port"`
|
||||
BaseURL string `yaml:"base_url"`
|
||||
Port int `yaml:"port"`
|
||||
JWKSURL string
|
||||
TimeoutSeconds int `yaml:"timeout_seconds"`
|
||||
PathMapping map[string]string `yaml:"path_mapping"`
|
||||
Mode string `yaml:"mode"`
|
||||
CORSConfig CORSConfig `yaml:"cors"`
|
||||
TransportMode TransportMode `yaml:"transport_mode"`
|
||||
Paths PathsConfig `yaml:"paths"`
|
||||
Stdio StdioConfig `yaml:"stdio"`
|
||||
|
||||
// Nested config for Asgardeo
|
||||
Demo DemoConfig `yaml:"demo"`
|
||||
|
@ -138,7 +139,7 @@ func (c *Config) Validate() error {
|
|||
|
||||
// GetMCPPaths returns the list of paths that should be proxied to the MCP server
|
||||
func (c *Config) GetMCPPaths() []string {
|
||||
return []string{c.Paths.SSE, c.Paths.Messages}
|
||||
return []string{c.Paths.SSE, c.Paths.Messages, c.Paths.StreamableHTTP}
|
||||
}
|
||||
|
||||
// BuildExecCommand constructs the full command string for execution in stdio mode
|
||||
|
@ -147,7 +148,6 @@ func (c *Config) BuildExecCommand() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
// For Windows, we need to properly escape the inner command
|
||||
escapedCommand := strings.ReplaceAll(c.Stdio.UserCommand, `"`, `\"`)
|
||||
|
@ -176,12 +176,12 @@ func LoadConfig(path string) (*Config, error) {
|
|||
if err := decoder.Decode(&cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
// Set default values
|
||||
if cfg.TimeoutSeconds == 0 {
|
||||
cfg.TimeoutSeconds = 15 // default
|
||||
}
|
||||
|
||||
|
||||
// Set default transport mode if not specified
|
||||
if cfg.TransportMode == "" {
|
||||
cfg.TransportMode = SSETransport // Default to SSE
|
||||
|
@ -191,11 +191,11 @@ func LoadConfig(path string) (*Config, error) {
|
|||
if cfg.Port == 0 {
|
||||
cfg.Port = 8000 // default
|
||||
}
|
||||
|
||||
|
||||
// Validate the configuration
|
||||
if err := cfg.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue