Skip to content

feat: add --name filter to automations list (CLI / SDK / MCP / tRPC)#3952

Merged
saddlepaddle merged 3 commits intomainfrom
feat/cli-automation-name-lookup
May 1, 2026
Merged

feat: add --name filter to automations list (CLI / SDK / MCP / tRPC)#3952
saddlepaddle merged 3 commits intomainfrom
feat/cli-automation-name-lookup

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 1, 2026

Summary

Add name?: string filter to automation.list across every surface, applied at the DB layer via ilike:

  • CLI: superset automations list --name <substring> (alias -n). Pairs with --quiet for ID-only output.
  • SDK: automations.list({ name })
  • MCP v2: automations_list tool now takes optional name
  • tRPC: automation.list accepts an optional { name } input and applies it as ilike(automations.name, '%...%') in the org-scoped query

Why this instead of name-as-positional-arg

Task 60e7984c originally proposed making each automations <subcommand> <id> positional accept a name. The catch: automation names aren't unique (the org has had two Triage Linear already). Resolution-on-positional bakes a fragile assumption into seven subcommands and forces an error-on-ambiguity fallback. A list --name filter respects the non-uniqueness directly and pairs cleanly with --quiet for scripting, which was the original irritation ("had to grep through ~50 entries of JSON").

Why DB-side, not client-side

Initial implementation filtered client-side in each surface. That doesn't scale to teams with hundreds of automations — every list call would still ship the full set over the wire. Pushing the filter into the tRPC query keeps payloads small and lets each surface stay a thin pass-through.

Verification

  • superset automations list --name "sales" → narrows to the 3 Sales automations
  • superset automations list -n sales --quiet → 3 UUIDs, one per line
  • superset automations list --name "no-such-thing" → empty, exits 0 (grep-like)
  • superset automations list → unchanged, returns all
  • superset automations list --help → shows the new flag

Follow-ups (not in this PR)

  • Same --name filter on projects list, workspaces list, tasks list (tasks already has --search), hosts list.

Test plan

  • Typecheck (@superset/trpc, @superset/sdk, @superset/mcp-v2, @superset/cli)
  • Lint clean
  • Manual smoke against live API (CLI)
  • Reviewer eyeball on filter behavior + flag naming

Summary by CodeRabbit

  • New Features

    • Added an optional name filter for automation listing; use --name / -n to show only automations whose names include the provided text (case-insensitive).
  • Bug Fixes

    • Listing now supports server-side name filtering (with safe pattern handling) and SDK/CLI/tooling updated so filtered results are applied consistently.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

Add optional case-insensitive name filtering to automation listing: CLI accepts --name/-n and forwards it; MCP tool and trpc router accept/validate name and apply server-side ilike filtering (with LIKE-escape); SDK exposes AutomationListParams and forwards name to the API.

Changes

Cohort / File(s) Summary
CLI Command
packages/cli/src/commands/automations/list/command.ts
Add name string option (-n); run now receives { ctx, options } and passes a filter object to ctx.api.automation.list.query when options.name is provided.
MCP v2 Tool
packages/mcp-v2/src/tools/automations/list.ts
Add zod inputSchema with optional name; handler accepts input and calls caller.automation.list() with { name: input.name } when present, otherwise calls with undefined.
SDK Resource
packages/sdk/src/resources/automations.ts
Add export interface AutomationListParams { name?: string }; change Automations.list signature to list(params?: AutomationListParams, options?: RequestOptions) and forward params into the "automation.list" API call.
Server / tRPC Router
packages/trpc/src/router/automation/automation.ts
automationRouter.list now accepts optional { name?: string } input, escapes %, _, \ for LIKE patterns, and applies case-insensitive ilike filtering on automations.name when name is provided (combined with org-scoping predicate).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CLI as CLI
  participant SDK as SDK
  participant MCP as MCP Server
  participant DB as Database

  CLI->>SDK: Automations.list({ name: "foo" })
  SDK->>MCP: RPC "automation.list" params { name: "foo" }
  MCP->>DB: SELECT ... WHERE org_id = ? AND name ILIKE '%foo%' (escaped)
  DB-->>MCP: rows[]
  MCP-->>SDK: rows[]
  SDK-->>CLI: rows[]
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code with a curious name,
Lowercased and escaped it so queries stay tame,
From CLI to server, then DB’s soft glade,
I found every match in the list that was made. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a --name filter to automations list across multiple surfaces (CLI, SDK, MCP, tRPC).
Description check ✅ Passed The PR description is comprehensive and well-structured, covering summary, rationale, design decisions, verification, and test plan, though it doesn't strictly follow the provided template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-automation-name-lookup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 1, 2026

Greptile Summary

Adds a --name/-n substring filter to superset automations list. All automations are fetched from the server (the automation.list tRPC procedure has no server-side pagination) and filtered client-side; the approach is appropriate for the current dataset size.

Confidence Score: 5/5

Safe to merge — small, well-scoped change with no logic errors or safety risks.

name is notNull() in the DB schema so row.name.toLowerCase() cannot throw; the falsy guard on options.name correctly short-circuits the empty-string edge case; client-side filtering is the right call given the server returns all rows without pagination.

No files require special attention.

Important Files Changed

Filename Overview
packages/cli/src/commands/automations/list/command.ts Adds --name/-n flag for case-insensitive client-side substring filtering; logic is correct, name is non-null in the DB schema so no null-safety risk

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI
    participant API as tRPC API (automation.list)

    User->>CLI: superset automations list [--name "sales"] [--quiet]
    CLI->>API: automation.list.query()
    API-->>CLI: all automations[]

    alt --name provided
        CLI->>CLI: filter rows where name.toLowerCase().includes(needle)
    end

    alt --quiet
        CLI-->>User: one ID per line
    else table display
        CLI-->>User: formatted table (id, name, agent, schedule, enabled, nextRun)
    end
Loading

Reviews (1): Last reviewed commit: "feat(cli): add --name filter to `automat..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/automations/list/command.ts`:
- Around line 12-16: The filter currently calls row.name.toLowerCase() which
will throw for missing/non-string names; update the run method's filtering logic
(where rows.filter is used after ctx.api.automation.list.query and options.name)
to first check typeof row.name === "string" (or coerce with String(row.name)
safely) before calling toLowerCase, e.g. only include rows where typeof row.name
=== "string" && row.name.toLowerCase().includes(needle) so the command won't
crash on partially populated rows.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed52cc47-519d-4db2-bdef-5ad96f0256fd

📥 Commits

Reviewing files that changed from the base of the PR and between 3549557 and a4d54ec.

📒 Files selected for processing (1)
  • packages/cli/src/commands/automations/list/command.ts

Comment thread packages/cli/src/commands/automations/list/command.ts Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

Town Hall added 2 commits May 1, 2026 15:47
Finding an automation's UUID previously required dumping the whole list
and grepping the JSON. Add a case-insensitive substring filter on
`name` so `automations list --name "sales"` (or `-n sales`) narrows the
output. Pairs with `--quiet` for ID-only output:

  superset automations list -n sales --quiet

Filtering happens client-side; the org-scoped list is small.
Add an optional `name` substring filter to `automations.list()` in the SDK
and to the `automations_list` MCP v2 tool, matching the CLI's `--name` flag.
Filtering happens client-side since the underlying tRPC query takes no params.
Move the `--name` substring match from client-side filtering to a
`name?: string` input on `automation.list`, applied as `ilike` against
the DB. CLI / SDK / MCP v2 now pass the filter through instead of
filtering the response, so it scales to teams with hundreds of
automations.
@saddlepaddle saddlepaddle changed the title feat(cli): add --name filter to automations list feat: add --name filter to automations list (CLI / SDK / MCP / tRPC) May 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/mcp-v2/src/tools/automations/list.ts`:
- Around line 11-23: The inputSchema currently allows empty strings which the
handler then treats as no filter and returns all automations; update the schema
for inputSchema.name to reject blank/whitespace-only values (e.g. use
z.string().trim().min(1).optional() or an equivalent non-empty string/refine) so
that handler logic using input.name and caller.automation.list only runs when a
real name is provided and empty inputs are rejected at the tool boundary; keep
the handler (createMcpCaller and caller.automation.list) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 97fa66f8-9878-41f0-b867-a3378c008155

📥 Commits

Reviewing files that changed from the base of the PR and between 0665e6f and 0c7e956.

📒 Files selected for processing (4)
  • packages/cli/src/commands/automations/list/command.ts
  • packages/mcp-v2/src/tools/automations/list.ts
  • packages/sdk/src/resources/automations.ts
  • packages/trpc/src/router/automation/automation.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/sdk/src/resources/automations.ts
  • packages/cli/src/commands/automations/list/command.ts

Comment on lines +11 to +23
inputSchema: {
name: z
.string()
.optional()
.describe(
"Filter rows by case-insensitive substring match on automation name.",
),
},
handler: async (input, ctx) => {
const caller = createMcpCaller(ctx);
return await caller.automation.list();
return await caller.automation.list(
input.name ? { name: input.name } : undefined,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Reject blank names at the tool boundary.

inputSchema currently accepts "", and the handler turns that into an unfiltered list request. That means a typo or empty default can silently return every automation instead of surfacing invalid input. Make the MCP schema reject blank values so it matches the TRPC contract.

Suggested fix
-		inputSchema: {
-			name: z
-				.string()
-				.optional()
-				.describe(
-					"Filter rows by case-insensitive substring match on automation name.",
-				),
-		},
+		inputSchema: {
+			name: z
+				.string()
+				.trim()
+				.min(1)
+				.optional()
+				.describe(
+					"Filter rows by case-insensitive substring match on automation name.",
+				),
+		},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
inputSchema: {
name: z
.string()
.optional()
.describe(
"Filter rows by case-insensitive substring match on automation name.",
),
},
handler: async (input, ctx) => {
const caller = createMcpCaller(ctx);
return await caller.automation.list();
return await caller.automation.list(
input.name ? { name: input.name } : undefined,
);
inputSchema: {
name: z
.string()
.trim()
.min(1)
.optional()
.describe(
"Filter rows by case-insensitive substring match on automation name.",
),
},
handler: async (input, ctx) => {
const caller = createMcpCaller(ctx);
return await caller.automation.list(
input.name ? { name: input.name } : undefined,
);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/mcp-v2/src/tools/automations/list.ts` around lines 11 - 23, The
inputSchema currently allows empty strings which the handler then treats as no
filter and returns all automations; update the schema for inputSchema.name to
reject blank/whitespace-only values (e.g. use
z.string().trim().min(1).optional() or an equivalent non-empty string/refine) so
that handler logic using input.name and caller.automation.list only runs when a
real name is provided and empty inputs are rejected at the tool boundary; keep
the handler (createMcpCaller and caller.automation.list) unchanged.

@saddlepaddle saddlepaddle merged commit c75c857 into main May 1, 2026
15 checks passed
saddlepaddle added a commit that referenced this pull request May 2, 2026
Bundles the 5 feat(cli) commits since v0.2.2:
- automations + tasks alignment with SDK and MCP-v2 (#3966)
- cross-device login via OAuth code + PKCE (#3965)
- 'automations prompt' split into 'prompt get' / 'prompt set' (#3959)
- --name filter on automations list (#3952)
- --assignee filter on tasks list (#3972)

Push cli-v0.2.3 after this lands to fire the release pipeline.
@Kitenite Kitenite deleted the feat/cli-automation-name-lookup branch May 6, 2026 04:51
@saddlepaddle saddlepaddle mentioned this pull request May 7, 2026
3 tasks
saddlepaddle added a commit that referenced this pull request May 7, 2026
npm has alpha.6 as the most recent published; alpha.7 was bumped in
71bf008 but never `npm publish`-ed. Skip alpha.7 on the registry
and ship the current repo state as alpha.8.

Changes since alpha.6:

- workspaces.create adopts the canonical host-service shape (#3893)
- automations.list accepts --name filter (#3952)
- automations.prompt split into automations.prompt.get / .set (#3959)
- agents.list (presets demoted to UI-only configuration) (#4097)
- agents.run / workspaces.create gain `superset-chat` agent + `kind`
  discriminator on launch results (terminal vs chat) (#4116)
- type adjustments for v2 workspace render path (#4141)
- redact x-api-key in debug-log header dumps (#3956, was alpha.7)

After merge: `cd packages/sdk && bun run build && cd dist && npm publish --access public`.
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.

1 participant