Skip to content

Malformed JSON-RPC request with empty arguments #284

@kwivix

Description

@kwivix

Describe the bug
When calling a tool with no arguments the request is malformed. The PHP JSON implementation transforms the empty arguments array to a JSON array: [] instead of the expected {} by JSON-RPC.

To Reproduce
Use this script to reproduce the behavior:

<?php

use Mcp\Client;
use Mcp\Client\Transport\HttpTransport;

$client = Client::builder()
    ->setClientInfo('HTTP Example Client', '1.0.0')
    ->setInitTimeout(30)
    ->setRequestTimeout(60)
    ->build();

$transport = new HttpTransport(
    endpoint: 'https://knowledge-mcp.global.api.aws',
);
$client->connect($transport);

$client->callTool('aws___list_regions', []);

Expected behavior
Currently the request body is as follow:

{"jsonrpc":"2.0","id":3,"method":"tools\/call","params":{"name":"aws___list_regions","arguments":[]}}

Note "arguments":[], that should be "arguments":{}:

{"jsonrpc":"2.0","id":3,"method":"tools\/call","params":{"name":"aws___list_regions","arguments":{}}}

Logs

Additional context
The AWS MCP server returns the following error:

{"jsonrpc":"2.0","id":3,"error":{"code":-32600,"message":"Invalid request - Malformed JSON-RPC request"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ServerIssues & PRs related to the Server componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions