sansan0/TrendRadar · error · InvalidParameterError

不支持的平台: {', '.join(invalid_platforms)}

Error message

不支持的平台: {', '.join(invalid_platforms)}

What it means

Raised when every entry in the platforms list was validated against supported_platforms (loaded from config.yaml) and at least one entry is not present. The suggestion enumerates the exact configured platform names, so mismatches are usually spelling or a stale config.

Source

Thrown at mcp_server/utils/validators.py:249

            # 空字符串或解析后为空,使用默认平台
            return supported_platforms if supported_platforms else []

    if not isinstance(platforms, list):
        raise InvalidParameterError("platforms 参数必须是列表类型")

    if not platforms:
        # 空列表时,返回配置文件中的平台列表
        return supported_platforms if supported_platforms else []

    # 如果配置加载失败(supported_platforms为空),允许所有平台通过
    if not supported_platforms:
        print("警告:平台配置未加载,跳过平台验证")
        return platforms

    # 验证每个平台是否在配置中
    invalid_platforms = [p for p in platforms if p not in supported_platforms]
    if invalid_platforms:
        raise InvalidParameterError(
            f"不支持的平台: {', '.join(invalid_platforms)}",
            suggestion=f"支持的平台(来自config.yaml): {', '.join(supported_platforms)}"
        )

    return platforms


def validate_limit(limit: Optional[Union[int, str]], default: int = 20, max_limit: int = 1000) -> int:
    """
    验证数量限制参数

    Args:
        limit: 限制数量(整数或字符串)
        default: 默认值
        max_limit: 最大限制

    Returns:
        验证后的限制值

View on GitHub (pinned to 8ee26026ba)

Solutions

  1. Use one of the exact names listed in the suggestion (they come straight from config.yaml), matching case exactly
  2. Check config.yaml for the canonical platform identifiers and correct your call
  3. Restart/redeploy the MCP server after editing config.yaml so supported_platforms is reloaded
  4. If the platform genuinely should exist, add its entry to config.yaml and reload

Example fix

// before
{"platforms": ["Twitter", "weibo"]}
// after
{"platforms": ["weibo"]}
Defensive patterns

Strategy: validation

Validate before calling

const CONFIGURED = new Set(['weibo', 'wechat']); // mirror config.yaml
const safe = platforms.filter(p => CONFIGURED.has(p));
if (!safe.length) safe = undefined; // or use defaults

Type guard

const isSupportedPlatform = (p: string): boolean => CONFIGURED.has(p);

Try / catch

try { call({ platforms }); }
catch (e) {
  const m = e.message.match(/支持的平台(来自config.yaml): (.+)/);
  if (m) call({ platforms: m[1].split(', ') }); // adopt server's list and retry
  else throw e;
}

Prevention

When it happens

Trigger: Calling a tool with platforms: ["twitter"] when config.yaml only defines e.g. weibo/wechat; case mismatches like ["Weibo"]; renamed platforms after a config change. Note: if config loading failed entirely (supported_platforms empty), validation is skipped with a printed warning instead — so this error specifically means config loaded and the name is wrong.

Common situations: Typo'd or capitalized platform keys; using platform names from an older project version; config.yaml edited but server not restarted; copying example invocations from docs of a different deployment.

Related errors


AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15). Data as JSON: /api/errors/d4eb34a6f6a8ffa1. Report an issue: GitHub.