Why integer tool input is converted into float internally by Crew ai

The issue is in how the agent is calling the wait_for_mentions tool and how the framework is processing the input. Here’s what’s happening:

  1. The agent is trying to format the input as a JSON string: “{"timeoutMs": 60000}”

  2. However, when this gets processed by the CrewAI framework, it’s being parsed and converted into a Python dictionary with a float value: {‘timeoutMs’: 60000.0}

  3. The framework is then passing this as a keyword argument (kwargs) to the wait_for_mentions function

  4. When this gets serialized again to send to the MCP server, it becomes {“timeoutMs”:60000.0} with a float value

  5. The MCP server is strictly expecting an integer and rejects the float value with the error: Unexpected symbol ‘.’ in numeric literal at path: $.timeoutMs

What does your tool input class look like? Can you share some code?

the tool is actually taken from MCP server (our agent to agent protocol) in which wait for mention tool will be responsible for making the agent wait so that other agent can tell it what to do and the parameter

this is the code in our Protocol which is providing this tool to the agent :

fun CoralAgentIndividualMcp.addWaitForMentionsTool() {
addTool(
name = “wait_for_mentions”,
description = “Wait until mentioned. Call this tool when you’re done or want to wait for another agent to respond. This will block until a message is received. You will see all unread messages.”,
inputSchema = Tool.Input(
properties = buildJsonObject {
putJsonObject(“timeoutMs”) {
put(“type”, “number”)
put(“description”, “Timeout in milliseconds (default: $maxWaitForMentionsTimeoutMs ms)”)
}
},
required = listOf(“timeoutMs”)
)
) { request: CallToolRequest →
handleWaitForMentions(request)
// delay(10000)
}
}

@Ahsen_Tahir,

Looks like your code there is Kotlin. The issue you’re hitting isn’t a CrewAI thing (on the client side), but more likely something on your Kotlin server’s end.

In that snippet, you’re setting up a JSON Schema, and timeoutMs is defined like:

put("type", "number")

Now, according to the JSON Schema docs, number accepts any numeric type, either integer or floating. So, if your server is only expecting an integer, you need to change that to:

put("type", "integer")

yeah thanks i tried it is working with "integer " but i thought number should be accepting both int and float so number should also be working

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.