Skip to main content
Glama

pbi_generate_cleanup_script

Read-onlyIdempotent

Generates a reviewable Tabular Editor C# (.csx) cleanup script for unused columns and DAX measures, ordered leaf-first for safe dependency handling and defaulting to non-destructive hide actions.

Instructions

Generates a reviewable Tabular Editor 2/3 C# (.csx) cleanup script targeting unused columns and/or DAX measures in a semantic model, ordered leaf-first for safe dependency handling. Does NOT modify any Power BI model or file on disk; returns the .csx script text for human review. Defaults to safe non-destructive action='hide' rather than action='delete'. Refuses to emit mutation code when has_parsed_layouts is false. Use after auditing unused fields with pbi_find_unused_fields.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "model": "<model>"
    },
    "name": "pbi_generate_cleanup_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelYesSemantic model name or dataset GUID.
tableNoOptional table name filter.
actionNoRemediation action: 'hide' (default, marks IsHidden=true and tags Description) or 'delete' (calls Delete()).hide
workspaceNoOptional workspace name filter to disambiguate identically named models.
field_typeNoTarget object kind: 'all' (default), 'columns', or 'measures'.all
exclude_fieldsNoOptional deny-list of field refs ('Table[Field]' or bare names) to keep untouched.
include_fieldsNoOptional allow-list of field refs ('Table[Field]' or bare names) to include.
dry_run_commentNoWhen true, comments out all mutations and emits Info() preview logs only (default: false).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.2.0

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true, and the description reinforces this with concrete behavior: no model or on-disk file is touched, and the .csx text is returned for human review. It also discloses the safe 'hide' default and a refusal path, though the 'has_parsed_layouts' guard references state that is not present in the input schema, leaving the agent unclear on how that condition is satisfied.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The definition is front-loaded with the artifact and target, then layers on safety and provenance in four dense, purposeful sentences. There is mild redundancy with the annotations (restating that nothing is modified) and one dangling reference to has_parsed_layouts that costs a little clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description correctly takes on the burden of explaining the return value (the .csx script text for human review) and the key behavioral precondition. For an 8-parameter generation tool whose schema is fully documented, nothing essential an agent needs to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all eight parameters, including both enums and the default values for action and dry_run_comment, are already fully documented in the schema. The description adds little beyond restating the non-destructive default, which the schema itself explains as IsHidden=true plus Description tagging; the baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a precise verb+resource+output artifact: generates a reviewable Tabular Editor 2/3 C# (.csx) cleanup script targeting unused columns and/or DAX measures, ordered leaf-first. It distinguishes itself from the sibling pbi_find_unused_fields by being the downstream generator rather than the auditor.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly states when to call it ('Use after auditing unused fields with pbi_find_unused_fields'), which names the upstream sibling and the precondition. It does not spell out a when-not-to-use case or an alternative generator, but no plausible alternative is evident from the description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.