googleapis/mcp-toolbox · error

failed to get instrumentation from context: %w

Error message

failed to get instrumentation from context: %w

What it means

Error "failed to get instrumentation from context: %w" thrown in googleapis/mcp-toolbox.

Source

Thrown at internal/server/server.go:97

	map[string]group.Group,
	error,
) {
	if cfg.EnableAPI {
		for _, sc := range cfg.AuthServiceConfigs {
			if sc.IsMCPEnabled() {
				return nil, nil, nil, nil, nil, nil, fmt.Errorf("MCP Auth cannot be enabled together with the legacy HTTP API (EnableAPI)")
			}
		}
	}

	metadataStr := cfg.Version
	if len(cfg.UserAgentMetadata) > 0 {
		metadataStr += "+" + strings.Join(cfg.UserAgentMetadata, "+")
	}
	ctx = util.WithUserAgent(ctx, metadataStr)
	instrumentation, err := util.InstrumentationFromContext(ctx)
	if err != nil {
		return nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get instrumentation from context: %w", err)
	}

	l, err := util.LoggerFromContext(ctx)
	if err != nil {
		return nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get logger from context: %w", err)
	}

	// initialize and validate the sources from configs
	sourcesMap := make(map[string]sources.Source)
	for name, sc := range cfg.SourceConfigs {
		s, err := func() (sources.Source, error) {
			childCtx, span := instrumentation.Tracer.Start(
				ctx,
				"toolbox/server/source/init",
				trace.WithAttributes(attribute.String("source_type", sc.SourceConfigType())),
				trace.WithAttributes(attribute.String("source_name", name)),
			)
			defer span.End()

View on GitHub (pinned to 8cc6e09de2)

When it happens

Trigger: Thrown at internal/server/server.go:97 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/9ce2309f16a83db5. Report an issue: GitHub.