Skip to content

Ensure --output json is always added to CLI commands #72

@Adam-it

Description

@Adam-it

Description:

Summary

Currently, the runCliCommand function in src/util.ts executes commands without ensuring that the output format is JSON. This could lead to inconsistent output formats that are harder to parse.

Current Behavior

The runCliCommand function executes commands as-is:

const subprocess = spawn(command, {
    shell: true,
    timeout: 120000,
});

Proposed Enhancement

Modify runCliCommand to automatically append --output json to commands if it's not already present. This would ensure:

  • Consistent JSON output for easier parsing
  • Better error handling and response processing
  • More reliable integration with MCP server responses

Example Implementation

export async function runCliCommand(command: string): Promise<string> {
    // Ensure --output json is always present
    if (!command.includes('--output')) {
        command = `${command} --output json`;
    }
    
    return new Promise((resolve, reject) => {
        const subprocess = spawn(command, {
            shell: true,
            timeout: 120000,
        });
        // ... rest of implementation
    });
}

Benefits

  • Guarantees parseable JSON responses
  • Reduces potential errors from text parsing

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions