fix: parse object-type parameters as JSON in generated CLIs#114
Open
v2nic wants to merge 1 commit intosteipete:mainfrom
Open
fix: parse object-type parameters as JSON in generated CLIs#114v2nic wants to merge 1 commit intosteipete:mainfrom
v2nic wants to merge 1 commit intosteipete:mainfrom
Conversation
When an MCP tool schema declares a parameter with type 'object' (e.g. Atlassian's editJiraIssue fields parameter), the generated CLI previously passed the value as a raw string, causing MCP validation errors. Root cause: inferType() didn't recognize 'object' as a valid type, so it returned 'unknown'. optionParser() had no case for 'object', so no JSON.parse was generated for the Commander option. Changes: - Add 'object' to GeneratedOption type union in tools.ts - Add 'object' to resolveType whitelist in inferType() - Add 'case object' returning JSON.parse in optionParser() Fixes steipete#113
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.
Summary
Fix generated CLIs not parsing
object-type parameters as JSON, which causes MCP validation errors when calling tools like Atlassian'seditJiraIssuewith--fields '{"description":"..."}'.Fixes #113
Motivation
When an MCP tool schema declares a parameter with
"type": "object", the generated CLI passes the value as a raw string instead of parsing it as JSON. The MCP server then rejects it with a validation error:This makes any MCP tool with object-type parameters unusable from generated CLIs without workarounds.
Changes
src/cli/generate/tools.ts'object'to theGeneratedOption.typeunion (line 14)'object'to theresolveTypewhitelist ininferType()(line 231) — previouslyobjectschemas silently mapped to'unknown'src/cli/generate/template.tscase 'object'tooptionParser()(line 393) — returns'(value) => JSON.parse(value)', so the generated Commander option parses the CLI string into a JSON object before passing it to the MCP tool