DruxAI
← New search
TechnologyBeta — synthesis improving

Input validation error: '1.57' is not of type 'number' from langchain_mcp_adapter

3 modelsComplete
80%Consensus Score3 models converged on the same answer. High confidence.
80%
consensus
Mostly aligned
How much the models agreed on this answer

High agreement — the answer is well-supported across models.

Models agree on

  • The error indicates a type mismatch where a number is expected but a string is received.
  • The primary cause is the value '1.57' being treated as a string due to quotes.
  • The main solution is to convert the string to a numeric type (e.g., float) before passing it.
  • Correct JSON formatting involves not quoting numerical values.

An Input validation error: '1.57' is not of type 'number' from langchain_mcp_adapter indicates a fundamental type mismatch: the system expects a numerical value but receives a string. This is typically due to the value being enclosed in quotes, which designates it as a string, even if its content appears numeric.

Cause

The core issue is that the langchain_mcp_adapter (or underlying validation schema, e.g., JSON Schema) is enforcing a number type, but the input it's receiving is a string. This commonly arises when data is passed with quotation marks around the numeric value (e.g., '1.57') instead of being an unquoted numerical literal (e.g., 1.57).

Solutions

To resolve this, ensure the input is a true numeric type before it reaches the adapter's validation:

  1. ·

    Convert String to Number: If the value originates as a string (e.g., from user input, a form field, or a text-based data source), explicitly convert it to a numeric type (like float or int) in your code. In Python, this would typically look like value = float('1.57').

    python

    Incorrect (string)

    data = {'value': '1.57'}

    Correct (number)

    data = {'value': 1.57}

  2. ·

    Correct JSON/Dictionary Formatting: If you are constructing JSON or a Python dictionary to pass to the adapter, ensure that numerical values are not enclosed in quotes. A number in JSON should not have quotes.

    // Incorrect JSON (string) {"value": "1.57"}

    // Correct JSON (number) {"value": 1.57}

  3. ·

    Verify Schema Expectations: Independently confirm the langchain_mcp_adapter's expected data type. If it uses JSON Schema, verify that the relevant field is defined with "type": "number".

Example Fix

If you're processing an input_value that might be a string, and then passing it to the adapter:

python

Assuming input_value could be a string like '1.57'

processed_value = float(input_value) # Convert to float

data = {"confidence": processed_value} validated_data = adapter.validate(data) # Pass the numeric value

By ensuring the data type is correctly numerical before validation occurs, you will resolve this input validation error.

Follow-ups

You just saw open-source models answer

Want GPT-5, Claude, Gemini & more on the same question?

Sign in free to run any question against frontier models — side by side, same synthesis, honest comparison.

GPT-5Claude SonnetGemini 2.5 ProGrokDeepSeek R1Perplexity Sonar
Free models only · sign in for premium