Skip to content

Cannot pass array inputs into the CLI. (type: array results in string) #657

Description

@jfeingold35

Description
When using the CLI mode, and a tool input schema defines the type as "array", the CLI passes the value to the server as a single string instead of a JSON array.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following tool description and execution:
server.setRequestHandler(ListToolsRequestSchema, () => {
    return {
        tools: [{
            name: "some-tool",
            description: "sample description",
            inputSchema: {
                type: "object",
                properties: {
                    prop: "array",
                    description: "This should be an array"
                }
            },
            required: ["prop"]
        }]
    }
})

server.setRequestHandler(CallToolRequestSchema, async (request) => {
    const name = request.params.name;
    
    switch (name) {
        case 'some-tool':
            return {
                content: [{
                    type: "text",
                    text: `The arguments provided were ${JSON.stringify(request.params.arguments)}`
                }]
            };
        default:
            throw new Error('unknown tool');
    }
});
  1. Use the inspector CLI mode to invoke the tool, e.g.,
noglob npx @modelcontextprotocol/inspector --cli node dist/index.js --method tools/call --tool-name some-tool --tool-arg prop=["abcd","defg"]

(noglob is necessary when using zsh, because brackets are how zsh detects a glob.)
3. Observe that the return value is:

{
  "content": [
    {
      "type": "text",
      "text": "The arguments provided were {\"prop\":\"[abcd,defg]\"}"
    }
  ]
}

Expected behavior
The value of prop should be ["abcd", "defg"], not "[abcd,defg]".

Logs
N/A

Additional context
N/A

Activity

  1. olaservo commented on Aug 2, 2025

    @olaservo
    Member

    Hi @jfeingold35 , thanks for submitting this issue. I think this is a duplicate of this older issue: #431

    I recently opened a PR to fix parsing other types of inputs here: #647

    I'm going to close this as a duplicate and hoping to merge the fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions