Skip to main content
Glama

Consulta de tabelas SIDRA

ibge_sidra
Read-onlyIdempotent

Query IBGE's SIDRA tables to retrieve Brazilian census, GDP, unemployment, and income statistics. Filter by territory and period, and compute rankings or distributions for comparisons.

Instructions

Queries SIDRA tables (IBGE's Automatic Recovery System).

SIDRA contains data from IBGE surveys like Census, PNAD, GDP, etc.

Common tables:

  • 6579: Population estimates (annual)

  • 9514: Census 2022 population

  • 200: Census population (1970-2010)

  • 4714: Population, territorial area and density (Census 2022)

  • 4099: Unemployment rate (PNAD Contínua, quarterly)

  • 5436: Average real income (PNAD Contínua, quarterly)

  • 6706: GDP at current prices

  • 5938: GDP per capita

Territorial levels:

  • 1: Brazil

  • 2: Region (North, Northeast, etc.)

  • 3: State (UF)

  • 6: Municipality

  • 7: Metropolitan Region

Examples:

  • Brazil population 2023: tabela="6579", periodos="2023"

  • Population by state: tabela="6579", nivel_territorial="3"

  • Census 2022 by municipality: tabela="9514", nivel_territorial="6", localidades="3550308"

Statistics mode: for largest/smallest/mean/median/distribution/ranking questions ("which municipality has the largest population?", "median GDP by state") use estatisticas=true — it computes min/max/mean/median/std-dev/labeled percentiles over ALL data rows BEFORE pagination and returns top/bottom rankings (default 10, cap 100 via topN), so one call answers what would otherwise require paging thousands of records. With agruparPor="" (e.g. "Unidade da Federação", "Ano") it ranks groups by descending sum, each with its own mini-distribution. Queries mixing several variables auto-group by "Variável" (units differ). SIDRA absence markers ("-", "..", "...", "X") are excluded from n. In this mode pagina/campos/formato are ignored and registros comes empty. Very large queries are refused by the source (since 2026-09-16 SIDRA tables are read through the Aggregates API, whose ceiling is lower than SIDRA's old 100,000-value cap: all municipalities × 12 yearly periods fails, × 8 works) — narrow periodos (e.g. "last 4") or raise nivel_territorial.

ibge_sidra is the low-level engine. Prefer a friendlier wrapper when it fits:

  • Census themes (1970–2022) → ibge_censo

  • Economic/social time series → ibge_indicadores

  • Rank/compare 2–10 localities → ibge_comparar

  • One municipality's panel → ibge_cidades Use ibge_sidra_tabelas and ibge_sidra_metadados to find a table code and its structure before querying.

Behavior: read-only and idempotent — a live GET against the public IBGE SIDRA API. Returns Markdown plus a typed structuredContent payload.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topNNoTamanho das listas top/bottom quando estatisticas=true sem agruparPor (padrão: 10, máx: 100)
camposNoSelecionar apenas algumas colunas por rótulo, separadas por vírgula (ex: 'Valor,Ano'). Reduz o volume da resposta. Omitir traz todas.
paginaNoPágina de resultados (100 registros por página)
tabelaYesCódigo da tabela SIDRA (ex: 6579 para estimativas de população, 9514 para censo 2022)
formatoNoFormato de saída: 'json' para dados brutos ou 'tabela' para formato legíveltabela
periodosNoPeríodos: 'last' para último, 'all' para todos, ou anos específicos (ex: 2020,2021,2022)last
variaveisNoIDs das variáveis separados por vírgula, ou 'allxp' para todasallxp
agruparPorNoCom estatisticas=true, agrupa pela coluna informada (rótulo, ex: 'Unidade da Federação', 'Ano') e ranqueia os grupos por soma decrescente (grupos[0] = maior total), cada grupo com sua mini-distribuição. Nome curto ('UF', 'estado', 'cidade', 'região') e rótulo parcial ('Federação') são resolvidos, e a resposta diz em `aviso` por qual coluna agrupou; rótulo que casa com duas colunas é recusado em vez de escolhido
localidadesNoCódigos das localidades separados por vírgula, ou 'all' para todasall
estatisticasNoComputa estatísticas (mínimo/máximo/média/mediana/desvio-padrão/percentis) sobre TODOS os registros da consulta, antes da paginação, + ranking top/bottom. Use para 'qual o maior/menor', 'média', 'mediana', 'distribuição', 'ranking'. Quando true, ignora pagina, campos e formato
classificacoesNoClassificações no formato 'id[categorias]' (ex: '2[6794]' para sexo masculino)
nivel_territorialNoNível territorial (código N): 1=Brasil, 2=Região, 3=UF, 6=Município, 7=Região Metropolitana, 8=Mesorregião, 9=Microrregião, 10=Distrito, 11=Subdistrito, 13=RM/RIDE, 14=RIDE, 15=Aglomeração Urbana, 17=Região Geográfica Imediata, 18=Região Geográfica Intermediária, 105=Macrorregião de Saúde, 106=Região de Saúde, 114=Aglomerado Subnormal, 127=Amazônia Legal, 128=Semiárido1

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
nomeYesNome da tabela (quando conhecido)
tabelaYesCódigo da tabela SIDRA consultada
colunasYesRótulos das colunas, na ordem
paginacaoYesMetadados de paginação para continuação
registrosYesRegistros da página atual: cada um mapeia rótulo da coluna -> valor
provenanceYesBloco de proveniência (contrato v1.0): fonte, URL, período, extração e licença
attributionYesURLs canônicas das fontes desta resposta (lista de atribuição)
estatisticasNoBloco estatístico presente quando estatisticas=true (registros vem vazio nesse modo)
totalRegistrosYesTotal de registros de dados disponíveis (todas as páginas)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv5.0.0
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / agruparPor / description
      Previous value: -"Com estatisticas=true, agrupa pela coluna informada (rótulo, ex: 'Unidade da Federação', 'Ano') e ranqueia os grupos por soma decrescente (grupos[0] = maior total), cada grupo com sua mini-distribuição"New value: +"Com estatisticas=true, agrupa pela coluna informada (rótulo, ex: 'Unidade da Federação', 'Ano') e ranqueia os grupos por soma decrescente (grupos[0] = maior total), cada grupo com sua mini-distribuição. Nome curto ('UF', 'estado', 'cidade', 'região') e rótulo parcial ('Federação') são resolvidos, e a resposta diz em `aviso` por qual coluna agrupou; rótulo que casa com duas colunas é recusado em vez de escolhido"
  2. Changed4 schema fields changedv4.0.0
    • removedOutput schema / properties / provenance / properties / data_vintage / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / provenance / properties / data_vintage / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / provenance / properties / license / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / provenance / properties / license / type
      Added value: +[
      +  "string",
      +  "null"
      +]
  3. Changed12 schema fields changedv3.3.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / agruparPor
      Added value: +{
      +  "description": "Com estatisticas=true, agrupa pela coluna informada (rótulo, ex: 'Unidade da Federação', 'Ano') e ranqueia os grupos por soma decrescente (grupos[0] = maior total), cada grupo com sua mini-distribuição",
      +  "type": "string"
      +}
    • addedInput schema / properties / estatisticas
      Added value: +{
      +  "default": false,
      +  "description": "Computa estatísticas (mínimo/máximo/média/mediana/desvio-padrão/percentis) sobre TODOS os registros da consulta, antes da paginação, + ranking top/bottom. Use para 'qual o maior/menor', 'média', 'mediana', 'distribuição', 'ranking'. Quando true, ignora pagina, campos e formato",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / pagina / maximum
      Added value: +9007199254740991
    • addedInput schema / properties / topN
      Added value: +{
      +  "default": 10,
      +  "description": "Tamanho das listas top/bottom quando estatisticas=true sem agruparPor (padrão: 10, máx: 100)",
      +  "maximum": 100,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedOutput schema / properties / attribution
      Added value: +{
      +  "description": "URLs canônicas das fontes desta resposta (lista de atribuição)",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / estatisticas
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Bloco estatístico presente quando estatisticas=true (registros vem vazio nesse modo)",
      +  "properties": {
      +    "agrupadoPor": {
      +      "description": "Rótulo da coluna de agrupamento (com agruparPor)",
      +      "type": "string"
      +    },
      +    "aviso": {
      +      "description": "Avisos sobre agrupamento automático, mistura de unidades ou truncamento",
      +      "type": "string"
      +    },
      +    "bottom": {
      +      "description": "Menores valores (sem agruparPor)",
      +      "items": {
      +        "additionalProperties": {},
      +        "propertyNames": {
      +          "type": "string"
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "colunaValor": {
      +      "description": "Rótulo da coluna numérica analisada (sempre 'Valor' no SIDRA)",
      +      "type": "string"
      +    },
      +    "distribuicao": {
      +      "additionalProperties": false,
      +      "description": "Distribuição do conjunto inteiro (sem agruparPor)",
      +      "properties": {
      +        "desvioPadrao": {
      +          "type": "number"
      +        },
      +        "maximo": {
      +          "type": "number"
      +        },
      +        "media": {
      +          "type": "number"
      +        },
      +        "mediana": {
      +          "type": "number"
      +        },
      +        "minimo": {
      +          "type": "number"
      +        },
      +        "n": {
      +          "description": "Registros com valor numérico considerados",
      +          "type": "number"
      +        },
      +        "percentis": {
      +          "items": {
      +            "additionalProperties": false,
      +            "properties": {
      +              "percentil": {
      +                "description": "Percentil (50 = mediana)",
      +                "type": "number"
      +              },
      +              "rotulo": {
      +                "description": "Enunciado por extenso, pronto para citar ao leitor",
      +                "type": "string"
      +              },
      +              "valor": {
      +                "type": "number"
      +              }
      +            },
      +            "required": [
      +              "percentil",
      +              "valor",
      +              "rotulo"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "soma": {
      +          "type": "number"
      +        }
      +      },
      +      "required": [
      +        "n",
      +        "soma",
      +        "minimo",
      +        "maximo",
      +        "media",
      +        "mediana",
      +        "desvioPadrao",
      +        "percentis"
      +      ],
      +      "type": "object"
      +    },
      +    "grupos": {
      +      "description": "Grupos ordenados por soma decrescente, cada um com sua mini-distribuição (com agruparPor)",
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "desvioPadrao": {
      +            "type": "number"
      +          },
      +          "grupo": {
      +            "type": "string"
      +          },
      +          "maximo": {
      +            "type": "number"
      +          },
      +          "media": {
      +            "type": "number"
      +          },
      +          "mediana": {
      +            "type": "number"
      +          },
      +          "minimo": {
      +            "type": "number"
      +          },
      +          "n": {
      +            "description": "Registros com valor numérico considerados",
      +            "type": "number"
      +          },
      +          "percentis": {
      +            "items": {
      +              "additionalProperties": false,
      +              "properties": {
      +                "percentil": {
      +                  "description": "Percentil (50 = mediana)",
      +                  "type": "number"
      +                },
      +                "rotulo": {
      +                  "description": "Enunciado por extenso, pronto para citar ao leitor",
      +                  "type": "string"
      +                },
      +                "valor": {
      +                  "type": "number"
      +                }
      +              },
      +              "required": [
      +                "percentil",
      +                "valor",
      +                "rotulo"
      +              ],
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          "soma": {
      +            "type": "number"
      +          }
      +        },
      +        "required": [
      +          "n",
      +          "soma",
      +          "minimo",
      +          "maximo",
      +          "media",
      +          "mediana",
      +          "desvioPadrao",
      +          "percentis",
      +          "grupo"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "registrosConsiderados": {
      +      "description": "Registros com valor numérico (contam no n)",
      +      "type": "number"
      +    },
      +    "registrosSemValor": {
      +      "description": "Registros excluídos por marcador de ausência SIDRA ('-', '..', '...', 'X') ou valor não numérico",
      +      "type": "number"
      +    },
      +    "top": {
      +      "description": "Maiores valores, com as colunas de identificação do registro (sem agruparPor)",
      +      "items": {
      +        "additionalProperties": {},
      +        "propertyNames": {
      +          "type": "string"
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "totalGrupos": {
      +      "description": "Total de grupos existentes antes do teto (com agruparPor)",
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "colunaValor",
      +    "registrosConsiderados",
      +    "registrosSemValor"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / provenance
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Bloco de proveniência (contrato v1.0): fonte, URL, período, extração e licença",
      +  "properties": {
      +    "citation": {
      +      "description": "Citação pronta para uso",
      +      "type": "string"
      +    },
      +    "data_vintage": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "description": "Período de referência do dado segundo a fonte; null se a fonte não expõe"
      +    },
      +    "license": {
      +      "anyOf": [
      +        {
      +          "type": "string"
      +        },
      +        {
      +          "type": "null"
      +        }
      +      ],
      +      "description": "Regime legal do dado"
      +    },
      +    "retrieved_at": {
      +      "description": "Instante real da extração no upstream (ISO-8601, horário de Brasília)",
      +      "type": "string"
      +    },
      +    "source": {
      +      "description": "Fonte oficial do dado (API do IBGE consultada)",
      +      "type": "string"
      +    },
      +    "source_url": {
      +      "description": "URL canônica que reproduz a consulta",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "source",
      +    "source_url",
      +    "data_vintage",
      +    "retrieved_at",
      +    "citation",
      +    "license"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / registros / items / propertyNames
      Added value: +{
      +  "type": "string"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "tabela",
      -  "nome",
      -  "totalRegistros",
      -  "colunas",
      -  "registros",
      -  "paginacao"
      -]New value: +[
      +  "tabela",
      +  "nome",
      +  "totalRegistros",
      +  "colunas",
      +  "registros",
      +  "paginacao",
      +  "provenance",
      +  "attribution"
      +]
  4. Changed4 schema fields changedv3.0.0
    • addedInput schema / properties / campos
      Added value: +{
      +  "description": "Selecionar apenas algumas colunas por rótulo, separadas por vírgula (ex: 'Valor,Ano'). Reduz o volume da resposta. Omitir traz todas.",
      +  "type": "string"
      +}
    • changedInput schema / properties / nivel_territorial / description
      Previous value: -"Nível territorial (código N sem o prefixo):\n1=Brasil, 2=Grande Região, 3=UF, 6=Município, 7=Região Metropolitana,\n8=Mesorregião, 9=Microrregião, 10=Distrito, 11=Subdistrito,\n13=RM e RIDE, 14=Região Integrada de Desenvolvimento, 15=Aglomeração Urbana,\n17=Região Geográfica Imediata, 18=Região Geográfica Intermediária,\n105=Macrorregião de Saúde, 106=Região de Saúde,\n114=Aglomerado Subnormal, 127=Amazônia Legal, 128=Semiárido"New value: +"Nível territorial (código N): 1=Brasil, 2=Região, 3=UF, 6=Município, 7=Região Metropolitana, 8=Mesorregião, 9=Microrregião, 10=Distrito, 11=Subdistrito, 13=RM/RIDE, 14=RIDE, 15=Aglomeração Urbana, 17=Região Geográfica Imediata, 18=Região Geográfica Intermediária, 105=Macrorregião de Saúde, 106=Região de Saúde, 114=Aglomerado Subnormal, 127=Amazônia Legal, 128=Semiárido"
    • addedInput schema / properties / pagina
      Added value: +{
      +  "default": 1,
      +  "description": "Página de resultados (100 registros por página)",
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "colunas": {
      +      "description": "Rótulos das colunas, na ordem",
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "nome": {
      +      "description": "Nome da tabela (quando conhecido)",
      +      "type": "string"
      +    },
      +    "paginacao": {
      +      "additionalProperties": false,
      +      "description": "Metadados de paginação para continuação",
      +      "properties": {
      +        "pagina": {
      +          "type": "number"
      +        },
      +        "porPagina": {
      +          "type": "number"
      +        },
      +        "temMais": {
      +          "type": "boolean"
      +        },
      +        "totalPaginas": {
      +          "type": "number"
      +        }
      +      },
      +      "required": [
      +        "pagina",
      +        "porPagina",
      +        "totalPaginas",
      +        "temMais"
      +      ],
      +      "type": "object"
      +    },
      +    "registros": {
      +      "description": "Registros da página atual: cada um mapeia rótulo da coluna -> valor",
      +      "items": {
      +        "additionalProperties": {
      +          "type": "string"
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "tabela": {
      +      "description": "Código da tabela SIDRA consultada",
      +      "type": "string"
      +    },
      +    "totalRegistros": {
      +      "description": "Total de registros de dados disponíveis (todas as páginas)",
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "tabela",
      +    "nome",
      +    "totalRegistros",
      +    "colunas",
      +    "registros",
      +    "paginacao"
      +  ],
      +  "type": "object"
      +}
  5. First observedv1.0.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint=false, but the description adds substantial behavioral context beyond those: it specifies it is a 'live GET against the public IBGE SIDRA API', mentions the return format ('Markdown plus a typed structuredContent payload'), explains that statistics mode ignores pagina/campos/formato, and discloses that SIDRA absence markers are excluded and that very large queries are refused due to the Aggregates API ceiling. This is rich behavioral disclosure with no contradictions.

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 description is long but well-structured: it front-loads the core purpose, then uses labeled sections for common tables, territorial levels, examples, statistics mode, and sibling guidance. Every sentence earns its place—even the long statistics section is necessary for a complex feature. It is slightly verbose (e.g., repeating the Aggregates API ceiling note) but remains organized and scannable, so a 4 is appropriate rather than a 5.

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 tool with 12 parameters, 1 required, and an output schema present, this description is nearly exhaustive. It covers common usage patterns, edge cases (statistics mode ignoring some params, large query limits), how to discover table codes and metadata, and how to disambiguate from sibling tools. The output schema handles return-value details, so nothing essential is missing for an agent to call it correctly.

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

Parameters5/5

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

Schema coverage is 100%, so the baseline is 3, but the description goes far beyond: it provides a curated list of common table codes with meanings, explains territorial level codes, gives concrete examples for each parameter, details the statistics mode and agruparPor resolution behavior (including refusal for ambiguous labels), and explains that topN caps at 100. This adds practical semantics that the schema alone does not convey.

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 opens with a clear verb+resource statement: 'Queries SIDRA tables (IBGE's Automatic Recovery System).' It further distinguishes itself from siblings by explicitly naming ibge_censo, ibge_indicadores, ibge_comparar, and ibge_cidades as friendlier wrappers for specific use cases, and references ibge_sidra_tabelas and ibge_sidra_metadados as lookup tools. This leaves no ambiguity about what the tool does and how it differs from the others.

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?

It gives explicit guidance on when to use this low-level engine vs. alternative tools ('Prefer a friendlier wrapper when it fits: Census themes → ibge_censo, Economic/social time series → ibge_indicadores, Rank/compare 2–10 localities → ibge_comparar, One municipality's panel → ibge_cidades'). It also explains the statistics mode for ranking/distribution questions and warns about the Aggregates API ceiling, telling the user to narrow periods or raise territorial level. This is explicit when/when-not guidance with alternatives.

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