OpenBB-finance/OpenBB · error · ValueError

Invalid HTTP method '{method}'. Valid methods: {', '.join(va

Error message

Invalid HTTP method '{method}'. Valid methods: {', '.join(valid_methods)}

What it means

Raised when an entry in mcp_config.methods (after upper-casing and stripping) is not a member of the HTTPMethod enum. The message lists the accepted method names taken from the enum, so it doubles as documentation of the allowed set (standard HTTP verbs such as GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD, plus '*').

Source

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

        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:
                seen.add(method)
                unique_methods.append(method)

        return unique_methods if unique_methods else None

    @model_validator(mode="after")
    def validate_config_consistency(self) -> "MCPConfigModel":
        """Validate overall configuration consistency."""
        # If expose is False, other configurations don't matter much, but we still validate them
        if self.expose is False:

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Fix the method name to a standard HTTP verb, e.g. "methods": ["GET", "POST"]
  2. Copy the exact valid list from the error message itself (it enumerates HTTPMethod values)
  3. If you intended 'any method', use "methods": ["*"] instead of inventing a name

Example fix

# before
openapi_extra={"mcp_config": {"methods": ["FETCH"]}}

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

Strategy: validation

Validate before calling

from openbb_mcp_server.models.mcp_config import HTTPMethod

methods = cfg.get("methods")
for m in methods or []:
    candidate = m if m == "*" else str(m).upper().strip()
    if candidate != "*":
        HTTPMethod(candidate)  # raises early with a clear traceback if invalid

Type guard

def are_valid_http_methods(methods: list[str]) -> bool:
    valid = {m.value for m in HTTPMethod} | {"*"}
    return all(
        (m if m == "*" else m.upper().strip()) in valid for m in methods
    )

Try / catch

try:
    model = validate_mcp_config(cfg)
except ValidationError as e:
    if "Invalid HTTP method" in str(e):
        valid = [m.value for m in HTTPMethod]
        cfg["methods"] = [m for m in cfg["methods"] if m.upper() in valid]
        model = validate_mcp_config(cfg)
    else:
        raise

Prevention

When it happens

Trigger: "methods": ["FETCH"] or ["get-json"] — 'get-json'.upper() = 'GET-JSON' is not a valid enum value and raises. Also typos like 'PSOT', lowercase-with-suffix values, or vendor-specific pseudo-methods. The original enum ValueError is chained as the cause.

Common situations: Typos in hand-written YAML/JSON configs, method names copied from an RPC/GraphQL schema that are not HTTP verbs, version drift if a newer enum drops or adds a member while the config was written against a different version.

Related errors


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