Skip to main content
Glama
business-central-mcp

business-central-mcp

by SShadowS

bc_lookup

Read-only

Enumerates valid candidate values for a related-table (FK) field by opening Business Central's lookup and returning rows without selecting a value, so you can choose before writing.

Instructions

Enumerates candidate values for a related-table (FK) field by invoking BC's built-in Lookup on the field and returning the result rows as { rows: [{ bookmark, cells }], returned, truncated } (cells keyed by column caption, like page rows; truncated: true means more candidates were loaded than maxRows). The rows are only what BC's lookup view loaded, which can be far fewer than the table holds; truncated: false does not prove there are no other values, so pass search to find a specific one. Use this when you need to see valid choices for a field before writing it with bc_write_data — for example, listing all Salesperson Codes before filling "Salesperson Code" on a Customer Card, or listing all Gen. Bus. Posting Groups before selecting one.

Use bc_lookup when the field has isLookup=true in the bc_open_page or bc_read_data response. The field must be on an open page (pageContextId from bc_open_page). The operation is non-mutating: it opens the lookup form and always cancels without selecting a value, leaving the source page field unchanged. Provide an optional search string to filter candidates (e.g., search:"AR" to narrow to codes starting with "AR").

Do NOT use bc_lookup for option/enum fields — those already expose their fixed choices in the options array of bc_open_page and bc_read_data responses. Do NOT use for fields where isLookup is false or absent. Do NOT use for fields that carry lookupCustom=true in the bc_open_page or bc_read_data response: isLookup=true together with lookupCustom=true means the field drives a custom AL OnLookup trigger that BC does not expose as an enumerable lookup form — bc_lookup returns a clear error for these. Use the field's own UI/AssistEdit instead.

Workflow: bc_open_page → inspect field isLookup=true → bc_lookup to list candidates → bc_write_data with chosen value.

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>",
      "field": "<field>"
    },
    "name": "bc_lookup"
  }
}

Input Schema

NameRequiredDescriptionDefault
fieldYesCaption of the field to enumerate lookup candidates for (e.g., "Salesperson Code", "Gen. Bus. Posting Group"). Must be an editable FK/related-table field that has a lookup (isLookup=true in bc_open_page or bc_read_data response).
searchNoOptional search string to filter candidates (e.g., "AR" to narrow to codes starting with AR). Applied via BC's native search on the lookup list. Omit to return all rows up to maxRows.
maxRowsNoMaximum number of candidate rows to return. Defaults to 50. Max 500. BC may return fewer if the table has fewer records.
pageContextIdYesPage context ID of the open page (card or list) returned by bc_open_page.

Output Schema

NameRequiredDescriptionDefault
rowsYes
returnedYes
truncatedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv3.0.0
    • addedOutput schema / properties / returned
      Added value: +{
      +  "type": "number"
      +}
    • changedOutput schema / properties / rows / items / additionalProperties
      Previous value: -{}New value: +false
    • addedOutput schema / properties / rows / items / properties / bookmark
      Added value: +{
      +  "type": "string"
      +}
    • addedOutput schema / properties / rows / items / properties / cells
      Added value: +{
      +  "additionalProperties": {
      +    "type": [
      +      "string",
      +      "null"
      +    ]
      +  },
      +  "propertyNames": {
      +    "type": "string"
      +  },
      +  "type": "object"
      +}
    • addedOutput schema / properties / rows / items / required
      Added value: +[
      +  "bookmark",
      +  "cells"
      +]
    • removedOutput schema / properties / totalFound
      Removed value: -{
      -  "type": "number"
      -}
    • addedOutput schema / properties / truncated
      Added value: +{
      +  "type": "boolean"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "rows",
      -  "totalFound"
      -]New value: +[
      +  "rows",
      +  "returned",
      +  "truncated"
      +]
  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": {
      +    "rows": {
      +      "items": {
      +        "additionalProperties": {},
      +        "properties": {},
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "totalFound": {
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "rows",
      +    "totalFound"
      +  ],
      +  "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?

Beyond readOnlyHint/openWorldHint it discloses that the lookup form is opened and always cancelled without selecting, leaving the source field unchanged, and that lookupCustom fields produce a clear error rather than an empty result. It also warns that results reflect only what BC's lookup view loaded, so truncated:false does not prove there are no other values — a behavioral caveat an agent could not infer from annotations or schema.

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?

Front-loaded with the core behavior, then usage rules, exclusions, and a workflow line — a sensible structure with no filler sentences. It is slightly verbose in the opening sentence, which describes the return shape in prose even though an output schema exists, and the example lists (Salesperson Code, Gen. Bus. Posting Group) are restated across paragraphs.

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 read-only enumeration tool with full schema coverage and an output schema, everything an agent needs is present: preconditions, exclusions, error behavior, result-truncation semantics, and the surrounding workflow. No material gap remains for correct invocation.

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 all four parameters are already documented; the description still adds value by tying truncated to maxRows ("more candidates were loaded than maxRows") and by warning that a non-truncated result is not proof of exhaustiveness, plus that search uses BC's native search on the lookup list. It stops short of adding further syntax or format detail, which is appropriate given the schema's completeness.

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?

States a specific verb and resource: "Enumerates candidate values for a related-table (FK) field by invoking BC's built-in Lookup on the field." It explicitly distinguishes itself from bc_write_data (performs no selection) and from option/enum handling elsewhere, so an agent can identify the tool without opening any 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?

Gives explicit preconditions (field must have isLookup=true on an open page with a pageContextId), explicit exclusions (option/enum fields, isLookup false or absent, lookupCustom=true), and names the alternative for the excluded case (the field's own UI/AssistEdit). It also closes with a concrete four-step workflow routing through bc_open_page and bc_write_data.

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