Skip to main content
Glama

pq_upsert_expression

Creates or updates a shared Power Query M expression or parameter in a Power BI project’s expressions.tmdl file, enabling reusable queries or parameter definitions.

Instructions

Create or update a shared Power Query M expression or parameter in definition/expressions.tmdl.

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": {
      "projectPath": "<projectPath>",
      "name": "<name>",
      "mExpression": "<mExpression>"
    },
    "name": "pq_upsert_expression"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYesExpression or parameter name
descriptionNoOptional documentation comment
isParameterNoMark as a Power Query parameter (adds meta [IsParameterQuery=true, ...])
mExpressionYesPower Query M expression or literal parameter value (e.g. '"https://api.example.com"' or 'let ... in ...')
projectPathYesPath to the .pbip file or project root folder
parameterTypeNoParameter type when isParameter is true

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.4/5.0
Behavior2/5

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

With no annotations at all, the description carries the full burden and delivers little: it does not say whether an existing expression of the same name is silently overwritten, whether the M expression is validated before writing, what permissions or open-file state are required, or what the call returns. The mention of 'shared' and the exact file location is a small but real addition of context.

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

Conciseness5/5

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

One sentence, front-loaded with the verb and resource, ending with the concrete target file. Nothing is redundant or padded.

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

Completeness4/5

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

Six parameters, no output schema, and no annotations set a moderate bar; the fully documented schema covers the inputs and the description covers the write target. The gap is behavioral: overwrite semantics and failure modes for a mutation tool are unstated.

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% and every parameter, including the isParameter/parameterType pairing and the mExpression example, is documented in the schema itself. The description adds no syntax, formatting, or interaction details (for example that parameterType is only meaningful when isParameter is true) beyond that, so the baseline 3 applies.

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

Purpose4/5

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

The description names a specific verb pair (create or update) plus the resource (shared Power Query M expression or parameter) and even the target artifact (definition/expressions.tmdl). That is concrete enough to act on, but it never distinguishes this write path from the sibling query tools such as pq_get_queries or pq_set_table_query, so it stops short of a 5.

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

Usage Guidelines3/5

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

'Create or update' conveys the upsert semantics, which implies the agent can call it whether or not the expression exists. Beyond that there is no guidance on when to prefer pq_set_table_query, no prerequisites, and no exclusions, so usage is only implied.

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