Parse JSON arguments correctly in docker mcp tools call#365
Open
Pnkcaht wants to merge 1 commit intodocker:mainfrom
Open
Parse JSON arguments correctly in docker mcp tools call#365Pnkcaht wants to merge 1 commit intodocker:mainfrom
Pnkcaht wants to merge 1 commit intodocker:mainfrom
Conversation
Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Updated the CLI argument parsing logic for docker mcp tools call to correctly handle complex JSON values passed via the command line.
The CLI now attempts to deserialize argument values as JSON when possible, allowing objects and arrays (e.g. {}, nested maps, lists) to be passed to tools as structured data instead of raw strings.
Related issue
Fixed #307
What was the problem?
When calling MCP tools via the CLI, arguments provided in the form key=value were always treated as plain strings.
This caused failures for tools that expect structured JSON objects, for example:
docker mcp tools call API-patch-page
page_id=''
properties='{}'
Instead of receiving an empty object ({}), the tool received the literal string "{}".
Downstream APIs then attempted to interpret each character of the string as a property key, resulting in validation errors such as:
Couldn't find editable properties for these identifiers: 0,1
As a result:
How this change fixes it
The argument parsing logic now attempts to unmarshal each key=value argument as JSON.
Specifically:
This allows tools to receive structured data exactly as expected, without breaking existing behavior for simple string arguments.
Before / After (Summary)
Before
After
Screenshot
How this change fixes it
The CLI argument parsing logic was updated to intelligently interpret argument values as JSON when possible.
In parseArgs, each key=value argument is now processed as follows:
This allows users to pass structured JSON payloads (such as {}, nested objects, or arrays) directly via the CLI, while remaining fully backward-compatible with simple string arguments.