Skip to content

run_gcloud_command splits args containing spaces (breaks filter expressions) #385

@ndelitski

Description

@ndelitski

Description

When passing a compound filter expression as a single element in the args array to run_gcloud_command, the server appears to split the argument on spaces, causing gcloud to receive them as separate positional arguments.

Steps to Reproduce

Call run_gcloud_command with a gcloud logging read filter:

{
  "args": [
    "logging",
    "read",
    "resource.type=cloud_run_revision AND resource.labels.service_name=temporal-ui AND severity>=WARNING",
    "--project=my-project",
    "--limit=30",
    "--format=json(timestamp,severity,textPayload,jsonPayload)"
  ]
}

Expected Behavior

The filter string should be passed as a single argument to gcloud, equivalent to:

gcloud logging read 'resource.type=cloud_run_revision AND resource.labels.service_name=temporal-ui AND severity>=WARNING' --project=my-project --limit=30 --format=json(...)

Actual Behavior

Error: UnrecognizedArgumentsError: unrecognized arguments:
  AND
  resource.labels.service_name=temporal-ui
  severity>=WARNING (did you mean '--verbosity'?)

The AND and subsequent filter clauses are treated as separate arguments, indicating the single array element was split on spaces somewhere in the execution pipeline.

Environment

  • @google-cloud/gcloud-mcp v0.5.3
  • Client: Claude Code (CLI)
  • macOS, Node.js 22

Notes

This likely affects any gcloud subcommand that accepts a positional argument containing spaces (e.g., logging read FILTER, compute instances list --filter=EXPR). Commands with simple args like run services describe work correctly.

Possible cause: the gcloud meta lint-gcloud-commands validation step or the argument passing to child_process.spawn may be joining and re-splitting the args array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions