Skip to main content
Glama
business-central-mcp

business-central-mcp

by SShadowS

bc_read_data

Read-only

Refresh exact rows, fields, or factboxes from an open Business Central page, applying filters, sorting, and paging to read current values before writing.

Instructions

Refreshes a single section on an already-open page. Returns { section: { sectionId, kind, caption, fields?, rows?, actions?, filters?, sort?, hasMore?, newRowBookmark? }, stateVersion }. Each row is { bookmark, cells } with every cell BC's display string or null. A list section echoes the filters and sort this session applied (sort survives clearFilters, as in BC); newRowBookmark is the empty new-line row to write to. Card-shape sections (header, factbox, requestPage) refresh their fields[]; list-shape sections refresh rows[]. The returned stateVersion can be passed as expectedStateVersion to bc_write_data / bc_execute_action to reject stale-state writes. Requires a pageContextId from a prior bc_open_page call.

Do NOT use this for bulk or analytical reads over standard entities (customers, items, ledger entries, ...) -- prefer bc_query, which reads server-side via OData with no open page and no UI paging. Use bc_read_data when you need the interactive page's exact rows, factboxes, or option metadata.

Pass section: "header" (default) to refresh the page's header. Pass section: "lines" to refresh document line items. Pass a factbox sectionId (e.g. "factbox:Customer Statistics", as listed in the bc_open_page response) to refresh the FactBox card.

Option/enum and boolean fields in card-shape sections carry "options" (allowed choices as [{text, value}]) and "selectedOption" (current choice). When writing an enum field with bc_write_data, use the "value" string from "options" -- do NOT guess values. Example: after opening Item Card, the "Type" field returns options=[{text:"Inventory",value:"0"},{text:"Service",value:"1"},{text:"Non-Inventory",value:"2"}]; to change to Service, write value "1".

Filtering applies to list-shape sections only. Pass an array of { column, value }; values use BC filter syntax (exact "10000", ranges "10000..20000", wildcards "consulting", expressions ">1000"). Multiple filters combine with AND. Filters stay on the page until clearFilters (an empty value is refused: BC cannot remove a filter that way); bc_close_page clears them, so the page opens unfiltered next time.

clearFilters: true resets agent-applied filters and restores the page to its default/native filtered state before reading. Note: page-defined SourceTableView filters (set in AL code) remain active -- this does NOT guarantee a completely empty filter set. Use before applying new filters to avoid stacking. Applies to list-shape sections only. Runs before any filters[] in the same call.

Sorting: pass sort: { column, direction } to sort the repeater before reading. Applied server-side after any filters. Resets BC viewport to top of sorted result. "asc" = A-Z / 0-9, "desc" = Z-A / 9-0. The column must be a visible repeater column on the section. Non-sortable columns (FlowFields, BLOBs) may be rejected by BC with an error. Applies to list-shape sections only.

Column selection: pass columns: ["No.", "Name"] to limit the cells in each row, or the fields[] entries on a card section.

Range slicing: { offset, limit } returns rows[offset..offset+limit] for list sections, with hasMore: true when more rows follow (BC reports no total count). Page on with offset += limit until hasMore is false.

Examples:

  • Refresh header: { "pageContextId": "abc" }

  • Filter customer list: { "pageContextId": "abc", "filters": [{ "column": "City", "value": "London" }] }

  • Sort by Name ascending: { "pageContextId": "abc", "sort": { "column": "Name", "direction": "asc" } }

  • Sort by Name descending: { "pageContextId": "abc", "sort": { "column": "Name", "direction": "desc" } }

  • Filter and sort: { "pageContextId": "abc", "filters": [{ "column": "City", "value": "London" }], "sort": { "column": "Name", "direction": "asc" } }

  • Clear filters and re-read: { "pageContextId": "abc", "clearFilters": true }

  • Clear and re-filter: { "pageContextId": "abc", "clearFilters": true, "filters": [{ "column": "City", "value": "London" }] }

  • Read sales order lines: { "pageContextId": "abc", "section": "lines" }

  • Refresh a FactBox: { "pageContextId": "abc", "section": "factbox:Customer Statistics" }

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": {
      "pageContextId": "<pageContextId>"
    },
    "name": "bc_read_data"
  }
}

Input Schema

NameRequiredDescriptionDefault
tabNoTab name to filter header fields by (e.g., "General", "Invoice Details", "Shipping and Billing"). Omit to return all header fields.
sortNoSort the repeater by a column before reading. Applied after filters, resets BC viewport to top of sorted result. Applies to list-shape sections only. Non-sortable columns (FlowFields, BLOBs) may be rejected by BC.
rangeNoSlice a subset of repeater rows. Returns rows[offset..offset+limit]; the section then says hasMore: true when rows exist past the range (read on with offset + limit).
columnsNoColumn caption names to include in results. Omit to return all columns. Reduces output size.
filtersNoServer-side filters to apply before reading. Multiple filters combine with AND logic.
sectionNosectionId to refresh. Defaults to "header". Examples: "lines" (document line items), "factbox:Customer Statistics" (FactBox). Listed in the bc_open_page sections array.
clearFiltersNoClears agent-applied filters and restores the page to its default/native filtered state. Page-defined SourceTableView filters (set in AL code) remain active — this is NOT a guaranteed blank filter set. Use before applying new filters to avoid stacking. Applies to list-shape sections only.
pageContextIdYesPage context ID returned by bc_open_page.
includeActionsNoAlso return the section's actions. Off by default: bc_open_page already returned them; ask again only when they may have changed (e.g. after a write).

Output Schema

NameRequiredDescriptionDefault
sectionYes
stateVersionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed16 schema fields changedv3.0.0
    • addedInput schema / properties / includeActions
      Added value: +{
      +  "description": "Also return the section's actions. Off by default: bc_open_page already returned them; ask again only when they may have changed (e.g. after a write).",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / range / description
      Previous value: -"Slice a subset of repeater rows. Returns rows[offset..offset+limit]. Use with totalRowCount for pagination."New value: +"Slice a subset of repeater rows. Returns rows[offset..offset+limit]; the section then says hasMore: true when rows exist past the range (read on with offset + limit)."
    • changedOutput schema / properties / section / additionalProperties
      Previous value: -{}New value: +false
    • addedOutput schema / properties / section / properties / actions
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "name": {
      +        "type": "string"
      +      },
      +      "systemAction": {
      +        "type": "number"
      +      },
      +      "wizardNav": {
      +        "enum": [
      +          "back",
      +          "next",
      +          "finish",
      +          "cancel"
      +        ],
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / section / properties / caption
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / section / properties / cues
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "groupCaption": {
      +        "type": "string"
      +      },
      +      "hasAction": {
      +        "type": "boolean"
      +      },
      +      "name": {
      +        "type": "string"
      +      },
      +      "synopsis": {
      +        "type": "string"
      +      },
      +      "value": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "value",
      +      "hasAction"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / section / properties / fields
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "editable": {
      +        "type": "boolean"
      +      },
      +      "isLookup": {
      +        "type": "boolean"
      +      },
      +      "lookupCustom": {
      +        "type": "boolean"
      +      },
      +      "name": {
      +        "type": "string"
      +      },
      +      "options": {
      +        "items": {
      +          "additionalProperties": false,
      +          "properties": {
      +            "text": {
      +              "type": "string"
      +            },
      +            "value": {
      +              "type": "string"
      +            }
      +          },
      +          "required": [
      +            "text",
      +            "value"
      +          ],
      +          "type": "object"
      +        },
      +        "type": "array"
      +      },
      +      "selectedOption": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "text": {
      +            "type": "string"
      +          },
      +          "value": {
      +            "type": "string"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "showMandatory": {
      +        "type": "boolean"
      +      },
      +      "tab": {
      +        "type": "string"
      +      },
      +      "type": {
      +        "type": "string"
      +      },
      +      "value": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "editable",
      +      "type"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / section / properties / filters
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "column": {
      +        "type": "string"
      +      },
      +      "value": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "column",
      +      "value"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / section / properties / hasMore
      Added value: +{
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / section / properties / kind
      Added value: +{
      +  "enum": [
      +    "header",
      +    "lines",
      +    "factbox",
      +    "subpage",
      +    "requestPage"
      +  ],
      +  "type": "string"
      +}
    • addedOutput schema / properties / section / properties / newRowBookmark
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / section / properties / rows
      Added value: +{
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "bookmark": {
      +        "type": "string"
      +      },
      +      "cells": {
      +        "additionalProperties": {
      +          "type": [
      +            "string",
      +            "null"
      +          ]
      +        },
      +        "propertyNames": {
      +          "type": "string"
      +        },
      +        "type": "object"
      +      }
      +    },
      +    "required": [
      +      "bookmark",
      +      "cells"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / section / properties / sectionId
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / section / properties / sort
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "column": {
      +          "type": "string"
      +        },
      +        "direction": {
      +          "enum": [
      +            "asc",
      +            "desc"
      +          ],
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "column",
      +        "direction"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ]
      +}
    • addedOutput schema / properties / section / properties / tabs
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / section / required
      Added value: +[
      +  "sectionId",
      +  "kind",
      +  "caption"
      +]
  2. Changed1 schema field changedv2.0.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "https://json-schema.org/draft/2020-12/schema",
      +  "additionalProperties": false,
      +  "properties": {
      +    "section": {
      +      "additionalProperties": {},
      +      "properties": {},
      +      "type": "object"
      +    },
      +    "stateVersion": {
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "section",
      +    "stateVersion"
      +  ],
      +  "type": "object"
      +}
  3. First observedv1.5.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only supply readOnlyHint=true and openWorldHint=false; the description adds the behavior that matters: filters persist until clearFilters, bc_close_page clears them, clearFilters does NOT guarantee a blank filter set because AL SourceTableView filters survive, sort resets the BC viewport to the top, FlowField/BLOB columns may be rejected, and empty filter values are refused. It also explains that stateVersion can be fed to bc_write_data/bc_execute_action to reject stale writes, which is a real concurrency trait absent from the annotations.

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?

Information is front-loaded correctly: purpose, then exclusion/alternative, then section targeting, then output shape, then filter/sort/slice rules. It is longer than necessary, though — the nine examples include near-duplicates (sort asc, sort desc, filter+sort, clear+filter) and several passages restate schema text almost verbatim, which dilutes the high-value ordering rules.

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?

For a 9-parameter tool with nested objects, an output schema, and an open-page context dependency, the definition covers everything an agent needs: prerequisite pageContextId, valid section values, filter/sort/clear interaction order, paging semantics, and enum-option handling for writes. Return-value explanation overlaps the output schema but is not harmful.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3, but the description earns extra credit with details the schema lacks: clearFilters executes before filters[] in the same call, sort is applied after filtering, values use BC range/wildcard/expression syntax, and offset+=limit paging continues until hasMore is false. The one flaw is that range slicing is written as '{ offset, limit }' while the schema nests them under a required 'range' object, which could mislead an agent into passing top-level keys.

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?

Opens with a precise verb+resource+scope: 'Refreshes a single section on an already-open page.' It immediately distinguishes itself from the main sibling by stating it is the interactive-page read versus bc_query's server-side OData read, so an agent can route correctly without opening either schema.

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

Usage Guidelines5/5

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

Contains an explicit exclusion ('Do NOT use this for bulk or analytical reads ... prefer bc_query') paired with the positive condition ('Use bc_read_data when you need the interactive page's exact rows, factboxes, or option metadata'). It further disambiguates section targets (header vs lines vs factbox:<id>) and states the bc_open_page prerequisite.

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