OpenBB-finance/OpenBB · error · ValueError

Method '*' cannot be mixed with other HTTP methods.

Error message

Method '*' cannot be mixed with other HTTP methods.

What it means

Raised by the 'methods' validator when the wildcard '*' appears alongside other HTTP methods in the same mcp_config.methods list. '*' means 'all methods', so mixing it with explicit methods is ambiguous and rejected to keep route tool exposure deterministic.

Source

Thrown at openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py:179

    )

    @field_validator("methods", mode="before")
    @classmethod
    def validate_methods(cls, v: str | list[str] | None) -> list[HTTPMethod] | None:
        """Normalize and validate HTTP methods."""
        if v is None:
            return None

        # Handle single string
        if isinstance(v, str):
            v = [v]

        if not isinstance(v, list):
            raise ValueError("methods must be a list of strings")

        # If '*' is present, it should be the only method
        if "*" in v and len(v) > 1:
            raise ValueError("Method '*' cannot be mixed with other HTTP methods.")

        # Validate each method
        validated_methods = []
        for method in v:
            method_str = str(method).upper().strip() if method != "*" else "*"
            try:
                validated_methods.append(HTTPMethod(method_str))
            except ValueError as exc:
                valid_methods = [m.value for m in HTTPMethod]
                raise ValueError(
                    f"Invalid HTTP method '{method}'. Valid methods: {', '.join(valid_methods)}"
                ) from exc

        # Remove duplicates while preserving order
        seen = set()
        unique_methods = []
        for method in validated_methods:
            if method not in seen:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use '*' alone: "methods": ["*"]
  2. Or enumerate the concrete methods without '*': "methods": ["GET", "POST"]
  3. If merging configs from multiple sources, drop '*' whenever the merged list has more than one entry

Example fix

# before
openapi_extra={"mcp_config": {"methods": ["*", "GET"]}}

# after
openapi_extra={"mcp_config": {"methods": ["*"]}}
Defensive patterns

Strategy: validation

Validate before calling

methods = cfg.get("methods")
if isinstance(methods, list) and "*" in methods and len(methods) > 1:
    cfg["methods"] = ["*"]  # wildcard wins, or drop it instead
# also normalize case for comparison
methods = [m if m == "*" else m.upper() for m in (methods or [])]

Type guard

def methods_are_consistent(methods: list[str]) -> bool:
    up = [m.upper() for m in methods]
    return "*" not in up or len(up) == 1

Try / catch

try:
    model = validate_mcp_config(cfg)
except ValidationError as e:
    if "cannot be mixed" in str(e):
        cfg["methods"] = ["*"]
        model = validate_mcp_config(cfg)
    else:
        raise

Prevention

When it happens

Trigger: openapi_extra={"mcp_config": {"methods": ["*", "GET"]}} or ["POST", "*"]. Any list containing '*' with len > 1 triggers it, regardless of order or casing.

Common situations: Appending '*' to an existing per-method list 'to be safe', merging config fragments where one author used '*' and another enumerated methods, default templates that already list methods combined with a wildcard override.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/3964f1b11403bff5. Report an issue: GitHub.