Skip to content
Open
Show file tree
Hide file tree
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
48 changes: 42 additions & 6 deletions cmd/mcp/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/ethpandaops/mcp/pkg/config"
"github.com/ethpandaops/mcp/pkg/observability"
)

var (
Expand All @@ -20,15 +23,48 @@ var rootCmd = &cobra.Command{
Ethereum network analytics capabilities including ClickHouse blockchain data,
Prometheus metrics, Loki logs, and sandboxed Python execution.`,
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
level, err := logrus.ParseLevel(logLevel)
// Load config to get logging settings if available.
cfg, err := config.Load(cfgFile)
if err != nil {
// Fall back to CLI flag if config fails to load.
level, err := logrus.ParseLevel(logLevel)
if err != nil {
return err
}
log.SetLevel(level)
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
return nil
}

// Configure logging based on config file.
loggerCfg := observability.LoggerConfig{
Level: observability.LogLevel(cfg.Observability.Logging.Level),
Format: observability.LogFormat(cfg.Observability.Logging.Format),
OutputPath: cfg.Observability.Logging.OutputPath,
}

// CLI flag overrides config file.
if logLevel != "" && logLevel != "info" {
loggerCfg.Level = observability.LogLevel(logLevel)
}

configuredLog, err := observability.ConfigureLogger(loggerCfg)
if err != nil {
return err
// Fall back to default logging.
level, _ := logrus.ParseLevel(logLevel)
log.SetLevel(level)
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
return nil
}

log.SetLevel(level)
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
// Copy settings to the global log.
log.SetLevel(configuredLog.Level)
log.SetFormatter(configuredLog.Formatter)
log.SetOutput(configuredLog.Out)

return nil
},
Expand Down
44 changes: 40 additions & 4 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/spf13/cobra"

"github.com/ethpandaops/mcp/internal/version"
"github.com/ethpandaops/mcp/pkg/observability"
"github.com/ethpandaops/mcp/pkg/proxy"
)

Expand All @@ -34,13 +35,48 @@ var rootCmd = &cobra.Command{
Prometheus, and Loki backends. This is designed for Kubernetes deployment where
the proxy runs centrally and MCP clients connect using JWTs for authentication.`,
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
level, err := logrus.ParseLevel(logLevel)
// Load config to get logging settings if available.
cfg, err := proxy.LoadServerConfig(cfgFile)
if err != nil {
return err
// Fall back to CLI flag if config fails to load.
level, err := logrus.ParseLevel(logLevel)
if err != nil {
return err
}
log.SetLevel(level)
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
return nil
}

log.SetLevel(level)
log.SetFormatter(&logrus.JSONFormatter{})
// Configure logging based on config file.
loggerCfg := observability.LoggerConfig{
Level: observability.LogLevel(cfg.Logging.Level),
Format: observability.LogFormat(cfg.Logging.Format),
OutputPath: cfg.Logging.OutputPath,
}

// CLI flag overrides config file.
if logLevel != "" && logLevel != "info" {
loggerCfg.Level = observability.LogLevel(logLevel)
}

configuredLog, err := observability.ConfigureLogger(loggerCfg)
if err != nil {
// Fall back to default logging.
level, _ := logrus.ParseLevel(logLevel)
log.SetLevel(level)
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
return nil
}

// Copy settings to the global log.
log.SetLevel(configuredLog.Level)
log.SetFormatter(configuredLog.Formatter)
log.SetOutput(configuredLog.Out)

return nil
},
Expand Down
5 changes: 5 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ proxy:
observability:
metrics_enabled: true
metrics_port: 31490
# Logging configuration
logging:
level: info # debug, info, warn, error
format: text # text or json
output_path: "" # Optional: file path for log output (default: stdout)

# Semantic search configuration (required).
# Ensure the model file exists at the configured path.
Expand Down
12 changes: 1 addition & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/ethpandaops/mcp
go 1.24.1

require (
github.com/ClickHouse/clickhouse-go/v2 v2.42.0
github.com/aws/aws-sdk-go-v2 v1.41.1
github.com/aws/aws-sdk-go-v2/credentials v1.19.7
github.com/containerd/errdefs v1.0.0
Expand All @@ -24,10 +23,8 @@ require (
)

require (
github.com/ClickHouse/ch-go v0.69.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.2.0 // indirect
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/aws/smithy-go v1.24.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -40,16 +37,13 @@ require (
github.com/docker/go-connections v0.6.0 // indirect
github.com/ebitengine/purego v0.8.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/go-github/v53 v53.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/kelindar/iostream v1.4.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
Expand All @@ -59,15 +53,11 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/paulmach/orb v0.12.0 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.8.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
Expand All @@ -79,8 +69,8 @@ require (
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sys v0.39.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
Expand Down
Loading