Skip to content

Update gateway to accept OTLP headers as string (spec v1.13.0) #3337

Description

@lpcox

Context

The MCP Gateway Specification is being updated to v1.13.0 in github/gh-aw#25135. The headers field in the opentelemetry configuration is changing from object | string to string-only. The compiler will now emit "headers": "${OTEL_EXPORTER_OTLP_HEADERS}" as a raw string value instead of converting it to a JSON object.

What Needs to Change

1. Stdin config: accept headers as a string

StdinOpenTelemetryConfig.Headers in internal/config/config_stdin.go is currently map[string]string. It needs to become a string:

// Before
Headers map[string]string `json:"headers,omitempty"`

// After  
Headers string `json:"headers,omitempty"`

2. TOML config: align if needed

Check TracingConfig / OpenTelemetryConfig in internal/config/config_tracing.go — if it also has Headers map[string]string, update to string.

3. Tracing provider: parse the string at export time

internal/tracing/provider.go currently passes headers as map[string]string to otlptracehttp.WithHeaders(). It will need to parse the key=value,key=value string format into a map before passing to the OTLP exporter:

func parseOTLPHeaders(raw string) map[string]string {
    headers := make(map[string]string)
    for _, pair := range strings.Split(raw, ",") {
        k, v, ok := strings.Cut(strings.TrimSpace(pair), "=")
        if ok {
            headers[strings.TrimSpace(k)] = strings.TrimSpace(v)
        }
    }
    return headers
}

4. JSON schema: update to string type

Update internal/config/schema/mcp-gateway-config.schema.json — change opentelemetry.headers from object with additionalProperties: string to type: string.

5. Update tests

  • Config parsing tests for string headers
  • Tracing provider tests for header string parsing
  • Validation tests if any check header types

References

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions