mirror of
https://github.com/hanzoai/o11y-mcp.git
synced 2026-10-30 18:26:37 +00:00
The module declared itself github.com/SigNoz/signoz-mcp-server and imported the
schema migrator from github.com/SigNoz/signoz-otel-collector — a fork that
hanzoai/otel-collector superseded, where the same package is
cmd/o11yschemamigrator/schema_migrator. Both now point at the repo that is
actually maintained, at v1.3.0.
Go identifiers came with it: the client type is Client rather than SigNoz, the
import alias is o11yclient, and the env-name constants are EnvURL and
EnvAPIKey.
NOT touched, because each is a contract with something running and renaming it
breaks that thing rather than debranding it:
the 30 MCP tool names (signoz_list_alerts, signoz_get_trace_details, …) and
the signoz://dashboard/* resource URIs, which are this server's public API
and are what an agent calls;
the env vars SIGNOZ_URL and SIGNOZ_API_KEY and the SIGNOZ-API-KEY header,
which the deployment sets;
the table names — signoz_traces.distributed_signoz_index_v3, signoz_logs.*,
signoz_metrics.* — and the metric names signoz_calls_total and
signoz_latency_*, which name rows and series that exist on the server.
Those want a coordinated change on both sides, not a rename here.
go build and go vet both clean.
62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type Config struct {
|
|
URL string
|
|
APIKey string
|
|
LogLevel string
|
|
TransportMode string
|
|
Port string
|
|
}
|
|
|
|
const (
|
|
EnvURL = "SIGNOZ_URL"
|
|
EnvAPIKey = "SIGNOZ_API_KEY"
|
|
LogLevel = "LOG_LEVEL"
|
|
TransportMode = "TRANSPORT_MODE"
|
|
MCPPort = "MCP_SERVER_PORT"
|
|
)
|
|
|
|
func LoadConfig() (*Config, error) {
|
|
// Trim trailing slash from URL to prevent double-slash issues in API paths
|
|
url := strings.TrimSuffix(getEnv(EnvURL, ""), "/")
|
|
return &Config{
|
|
URL: url,
|
|
APIKey: getEnv(EnvAPIKey, ""),
|
|
LogLevel: getEnv(LogLevel, "info"),
|
|
TransportMode: getEnv(TransportMode, "stdio"),
|
|
Port: getEnv(MCPPort, "8000"),
|
|
}, nil
|
|
}
|
|
|
|
func getEnv(key, defaultValue string) string {
|
|
if value := os.Getenv(key); value != "" {
|
|
return value
|
|
}
|
|
return defaultValue
|
|
}
|
|
|
|
func (c *Config) ValidateConfig() error {
|
|
if c.URL == "" {
|
|
return fmt.Errorf("SIGNOZ_URL is required")
|
|
}
|
|
|
|
// In HTTP mode, API key can come from Authorization header, so it's optional
|
|
// In stdio mode, API key must be provided via environment variable
|
|
if c.TransportMode != "http" && c.APIKey == "" {
|
|
return fmt.Errorf("SIGNOZ_API_KEY is required for stdio mode")
|
|
}
|
|
|
|
if c.TransportMode == "http" {
|
|
if c.Port == "" {
|
|
return fmt.Errorf("MCP_SERVER_PORT is required for HTTP transport mode")
|
|
}
|
|
}
|
|
return nil
|
|
}
|