agentscope-ai/agentscope · error · MCPRenderError

Invalid values for MCP {card.name!r}: {e.message}

Error message

Invalid values for MCP {card.name!r}: {e.message}

What it means

render_mcp validates the supplied input values against the MCP card's inputs_schema using jsonschema and raises MCPRenderError on the first validation failure. It means the values dict passed for the MCP server violates the card's declared schema (wrong types, unknown constrained values, etc.).

Source

Thrown at src/agentscope/app/_service/_mcp_render.py:132

            The user-supplied values keyed by input name.
        name (`str | None`, optional):
            The name for the installed client. Defaults to the card name.

    Returns:
        `MCPClient`:
            The client ready to hand to ``workspace.add_mcp``.

    Raises:
        `MCPRenderError`:
            When ``values`` violate the card's ``inputs_schema``, leave a
            declared placeholder unfilled, or produce a config the
            client rejects.
    """
    values = _effective_values(card.inputs_schema, values)
    try:
        jsonschema.validate(values, card.inputs_schema)
    except jsonschema.ValidationError as e:
        raise MCPRenderError(
            f"Invalid values for MCP {card.name!r}: {e.message}",
        ) from e

    declared = set(card.inputs_schema.get("properties", {}))
    required = set(card.inputs_schema.get("required", []))
    missing: set[str] = set()
    config_template = card.config_template.model_dump(mode="json")
    _omit_unfilled_optional_env(
        config_template,
        values,
        declared,
        required,
    )
    config = _substitute(
        config_template,
        values,
        declared,
        missing,

View on GitHub (pinned to e90f1c7592)

Solutions

  1. Inspect card.inputs_schema (properties, types, enums) and correct the offending value
  2. Validate values client-side with the same JSON Schema before calling install/update
  3. Re-fetch the MCP card after upgrading to pick up schema changes
  4. Use the rendered input form / defaults from the card rather than manual dicts

Example fix

# before
client = render_mcp(card, values={"max_retries": "3"})
# after
client = render_mcp(card, values={"max_retries": 3})
Defensive patterns

Strategy: validation

Validate before calling

import jsonschema
values = _apply_defaults(card.inputs_schema, values)
jsonschema.validate(instance=values, schema=card.inputs_schema)  # run before install_mcp

Type guard

def values_match_schema(values: dict, schema: dict) -> bool:
    try:
        jsonschema.validate(values, schema)
        return True
    except jsonschema.ValidationError:
        return False

Try / catch

try:
    client = render_mcp(card, values)
except MCPRenderError as e:
    if e.args[0].startswith("Invalid values"):
        # surface schema errors to the form UI
        ...

Prevention

When it happens

Trigger: Calling install_mcp or update_mcp (or render_mcp directly) with values that fail jsonschema validation against card.inputs_schema — e.g. a string where an integer is declared, an invalid enum member, or wrong nesting.

Common situations: Hand-writing MCP config values instead of using the form generated from the schema; version drift where an updated MCP card changed its inputs_schema; passing raw strings from environment variables into typed fields.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28). Data as JSON: /api/errors/4557a7da0acf0bcd. Report an issue: GitHub.