Skip to main content
Glama
Horizun PBI MCP

Horizun PBI MCP

Official
by HorizunGroup

pbi_add_table_from_file

Loads CSV, Excel, JSON, or HTML files into a Power BI model as a table, generating editable Power Query steps with header detection, culture handling, and code-safe text columns.

Instructions

Carga un archivo al modelo como lo haria una persona: abrir, transformar, cargar.

El mismo recorrido de Power Query —Obtener datos, promover encabezados, cambiar tipos, Cargar— pero escrito directo en el proyecto. Los pasos de la consulta se llaman como los pone Power BI ('Origen', 'Encabezados promovidos', 'Tipo cambiado'), asi que se puede abrir y editar en el editor sin que desentone.

Admite .csv, .txt, .tsv, .xlsx, .xlsm, .json, .html/.htm y '.xls'. Sin dependencias nuevas: el .xlsx se lee como lo que es, un zip con XML, y el HTML con html.parser de la biblioteca estandar.

Un '.xls' NO se toma por la extension: se mira la firma real del archivo. En la practica, casi ningun '.xls' que exportan los ERPs es el binario OLE2 que la extension promete -- es una tabla HTML con esa extension porque Excel la abre igual. Si de verdad es OLE2 (Excel 97-2003), se rechaza con un mensaje claro en vez de leerlo mal; si es un .xlsx renombrado, se lee como .xlsx.

Para HTML: si el archivo trae varias <table>, se elige la mas grande y se avisa (usa table_id para elegir una en concreto, el id HTML de la tabla). Los encabezados solo se promueven si la tabla usa <th>; un reporte sin esa marca (el caso normal en un reporte de ERP, donde la fila 1 es el titulo del reporte, no un encabezado) carga con columnas 'Column1', 'Column2'...

La cultura se deduce del archivo, mirando como escribe los decimales, y se emite SIEMPRE explicita en la consulta. Asumir la del modelo es lo que convierte 10527.52 en diez millones sin que nada falle: un informe que abre, pinta y miente. culture permite forzarla.

Lo escrito se valida antes de darlo por bueno: si el TMDL generado no pasara pbi_validate_tmdl, se aborta en vez de dejar un proyecto que no abre.

Filas de basura antes del encabezado: es el patron de export mas comun de un ERP -fila 1 con el titulo del reporte y el resto de la fila vacia, encabezado real en la fila 2-. Por defecto se AUTODETECTA la primera fila que pueda ser encabezado (sin huecos y sin nombres repetidos) y se dice cual se eligio en warnings. skip_rows fuerza cuantas saltar cuando la deteccion no acierta; skip_rows=0 obliga a usar la fila 1 tal cual. Aplica a csv y xlsx.

Los codigos se cargan como texto. Una columna cuyo encabezado dice que es un codigo (codigo, cod, code, clave, item, sku, ref...) queda en texto aunque sus valores parezcan numeros: como numero 2.10 se vuelve 2.1 y deja de cruzar con otras tablas. Igual con enteros con ceros a la izquierda (007). Se avisa en warnings. text_columns fuerza texto en columnas que el encabezado no delata (p. ej. ["partida"]); un nombre que no exista es error.

Filas vacias y de TOTAL: en csv y xlsx, las filas sin ningun valor y las que empiezan por TOTAL, SUBTOTAL o GRAN TOTAL en una de las tres primeras columnas se quitan en Power Query (paso 'Filas vacias y totales quitadas') y se avisa en warnings. Una fila TOTAL dentro de la tabla duplica las sumas y deja una clave en blanco que rompe las relaciones. keep_summary_rows=true las conserva.

dry_run=true devuelve el TMDL y la M sin escribir nada. sheet: hoja del libro; si se omite, la primera. Solo aplica a xlsx.

Escribe en TMDL: requiere el proyecto CERRADO en Power BI Desktop.

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": {
      "path": "<path>"
    },
    "name": "pbi_add_table_from_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes
sheetNo
cultureNo
dry_runNo
table_idNo
overwriteNo
skip_rowsNo
request_idNo
table_nameNo
descriptionNo
text_columnsNo
keep_summary_rowsNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.2.0
    • addedInput schema / properties / keep_summary_rows
      Added value: +{
      +  "default": false,
      +  "title": "Keep Summary Rows",
      +  "type": "boolean"
      +}
  2. Changed1 schema field changedv2.1.2
    • addedInput schema / properties / text_columns
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Text Columns"
      +}
  3. Changed1 schema field changedv1.2.0
    • addedInput schema / properties / skip_rows
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Skip Rows"
      +}
  4. First observedv1.0.1

TDQS

A3.6/5.0
Behavior4/5

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

Beyond the annotations (readOnlyHint=false, destructiveHint=false, idempotent=false), the description discloses substantial behavior: the generated TMDL is validated against pbi_validate_tmdl and aborts on failure, malformed OLE2 .xls files are rejected rather than mis-read, and each heuristic step reports itself via `warnings`. The notable gap is `overwrite`, a write-path flag with no described semantics, which is exactly the kind of behavior a caller needs before mutating a project.

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

Conciseness3/5

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

The purpose is front-loaded and the bolded per-topic paragraphs make it scannable, but several sentences are implementation trivia the agent cannot act on — notably the note that .xlsx is read as a zip of XML and HTML via `html.parser` — and the section on culture inference is repeated in emphasis rather than tightened. It is longer than the decision-relevant content requires.

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?

For a 12-parameter mutation tool this is largely complete: it covers the file formats, header autodetection, culture inference, text-column coercion, summary-row removal, dry-run behavior, and the closed-project prerequisite, and an output schema exists so return shape need not be spelled out. The remaining hole is the undocumented overwrite/table_name/description parameters, which leaves ambiguity about what happens when the target table already exists.

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 0% across 12 parameters, so the description carries the whole burden. It does this well for eight of them (path, sheet, culture, dry_run, table_id, skip_rows, text_columns, keep_summary_rows, including an error case for unknown column names), but `overwrite`, `table_name`, `description`, and `request_id` are never mentioned, and `overwrite` in particular changes the operation's risk profile.

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 opening line states a concrete verb and resource: load a file into the model as a table, replicating a Power Query 'Get Data → transform → Load' flow written directly into the TMDL project. It is specific about the resource and scope, but it never names the obvious sibling pbi_add_table_from_source, so the agent must infer the file-vs-connection boundary by itself.

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?

Usage is implied rather than stated: the supported extension list and the `dry_run=true` flag signal when this tool is viable, and the closing line gives a hard prerequisite (the project must be closed in Power BI Desktop). There is no explicit when-to-use/when-not guidance and no routing to pbi_add_table_from_source or pbi_update_power_query for the alternative paths.

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

Deploy Server

Other Tools