Skip to content
Arrays and MCP serv...
 
Notifications
Clear all

Arrays and MCP server

4 Posts
2 Users
0 Reactions
4 Views
Marcelo_Oliveira
(@marcelo_oliveira)
Posts: 2
New Member
Topic starter
 

Describe the problem/error/question

I've set up a callin.io server that requires an array of objects. The data from the AI agent is received correctly, but callin.io is returning an error indicating it expected a string but received an array.

The callin.io server uses a webhook to get the data and process it. The issue is that I can't send the data as an array; it only accepts it as a string.

What is the error message (if any)?

Error: [ { "code": "invalid_type", "expected": "string", "received": "array", "path": [ "fields" ], "message": "Expected string, received array" } ]

Information on your callin.io setup

  • callin.io version: 1.99.1
  • Database (default: SQLite): Postgres
  • callin.io EXECUTIONS_PROCESS setting (default: own, main):
  • Running callin.io via (Docker, npm, callin.io cloud, desktop app): Digital Ocean
  • Operating system: Linux
 
Posted : 30/06/2025 3:11 pm
Bogdan1
(@bogdan1)
Posts: 2
New Member
 

Hi,

Looking at your error, it appears to be a common type mismatch between MCP and callin.io.

Keep the MCP schema as a “string” and parse it within the handler:

const fieldsArray = JSON.parse(args.fields); // Parse string to array

// Send to callin.io
body: JSON.stringify({
  fields: fieldsArray
})

Alternatively, if you prefer to keep the array in MCP, stringify it before sending:

body: JSON.stringify({
  fields: JSON.stringify(args.fields)
})

The first approach is generally cleaner. The AI sends it as a string, you parse it, and then send the proper array to callin.io.

 
Posted : 30/06/2025 3:20 pm
Marcelo_Oliveira
(@marcelo_oliveira)
Posts: 2
New Member
Topic starter
 

I attempted this method, but when I attempt to parse or stringify the data, it renders the MCP inaccessible.

Should this be handled within the agent or the tool inside the MCP server?

 
Posted : 30/06/2025 4:09 pm
Bogdan1
(@bogdan1)
Posts: 2
New Member
 

So, if I understand correctly, your MCP server is expecting a request from the AI agent, but the AI is sending an array instead of a string.

Therefore, you have two options:

1) Have the AI agent convert the array to a string; then, nothing needs to change on the MCP side:

// In AI agent (Claude/ChatGPT) when calling MCP tool:
const fieldsData = [
  { name: "field1", type: "text" },
  { name: "field2", type: "number" }
];

// Convert to string before sending
return {
  fields: JSON.stringify(fieldsData) // Now it's a string
};

2) Alternatively, have the MCP server accept the array and work with it:

// In MCP schema - change type to array
{
  name: "send_webhook",
  inputSchema: {
    type: "object", 
    properties: {
      fields: {
        type: "array", // Instead of string
        items: {
          type: "object",
          properties: {
            name: { type: "string" },
            type: { type: "string" }
          }
        }
      }
    }
  }
}

// In handler - use directly as array
export async function handleWebhook(args: any) {
  const fieldsArray = args.fields; // Already an array, no parsing needed

  await fetch('webhook-url', {
    method: 'POST',
    body: JSON.stringify({
      fields: fieldsArray
    })
  });
}

Note: There isn't sufficient information to fully assess where and what exactly is failing, but this is a common issue with type mismatches between systems. Somewhere in your data flow, you'll need to perform the data type conversion – either on the sending side (AI agent) or the receiving side (MCP server).

 
Posted : 30/06/2025 4:32 pm
Share: