Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/config/config_stdin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import (
"io"
"log"
"os"

"github.com/github/gh-aw-mcpg/internal/logger"
)

var logStdin = logger.New("config:config_stdin")

// StdinConfig represents the JSON configuration format read from stdin.
type StdinConfig struct {
// MCPServers maps server names to their configurations
Expand Down Expand Up @@ -192,6 +196,7 @@ func LoadFromStdin() (*Config, error) {

// convertStdinConfig converts StdinConfig to internal Config format.
func convertStdinConfig(stdinCfg *StdinConfig) (*Config, error) {
logStdin.Printf("Converting stdin config: %d servers", len(stdinCfg.MCPServers))
cfg := &Config{
Servers: make(map[string]*ServerConfig),
}
Expand All @@ -209,6 +214,7 @@ func convertStdinConfig(stdinCfg *StdinConfig) (*Config, error) {
cfg.Gateway.PayloadDir = stdinCfg.Gateway.PayloadDir
}
} else {
logStdin.Print("No gateway config in stdin, applying defaults")
cfg.Gateway = &GatewayConfig{}
applyGatewayDefaults(cfg.Gateway)
}
Expand Down Expand Up @@ -265,6 +271,8 @@ func convertStdinServerConfig(name string, server *StdinServerConfig, customSche
serverType = "stdio"
}

logStdin.Printf("Converting server %q: type=%s", name, serverType)

// Handle HTTP servers
if serverType == "http" {
logConfig.Printf("Configured HTTP MCP server: name=%s, url=%s", name, server.URL)
Expand Down Expand Up @@ -297,6 +305,7 @@ func buildStdioServerConfig(name string, server *StdinServerConfig) *ServerConfi

// Add entrypoint override if specified
if server.Entrypoint != "" {
logStdin.Printf("Server %q: using custom entrypoint %q", name, server.Entrypoint)
args = append(args, "--entrypoint", server.Entrypoint)
}

Expand Down Expand Up @@ -378,6 +387,7 @@ func normalizeLocalType(data []byte) ([]byte, error) {

// If we modified anything, re-marshal the data
if modified {
logStdin.Print("Normalized 'local' server type to 'stdio' for backward compatibility")
return json.Marshal(rawConfig)
}

Expand Down