Skip to content

fix: parse object-type parameters as JSON in generated CLIs#114

Open
v2nic wants to merge 1 commit intosteipete:mainfrom
v2nic:fix/object-type-parsing
Open

fix: parse object-type parameters as JSON in generated CLIs#114
v2nic wants to merge 1 commit intosteipete:mainfrom
v2nic:fix/object-type-parsing

Conversation

@v2nic
Copy link

@v2nic v2nic commented Mar 16, 2026

Summary

Fix generated CLIs not parsing object-type parameters as JSON, which causes MCP validation errors when calling tools like Atlassian's editJiraIssue with --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:

MCP error -32602: Invalid arguments: [
  { "code": "invalid_type", "expected": "object", "received": "string", "path": ["fields"] }
]

This makes any MCP tool with object-type parameters unusable from generated CLIs without workarounds.

Changes

src/cli/generate/tools.ts

  • Added 'object' to the GeneratedOption.type union (line 14)
  • Added 'object' to the resolveType whitelist in inferType() (line 231) — previously object schemas silently mapped to 'unknown'

src/cli/generate/template.ts

  • Added case 'object' to optionParser() (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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated CLI: object-type parameters not JSON-parsed (inferType + optionParser missing 'object' case)

1 participant