Skip to main content
Glama

Comparação entre localidades

ibge_comparar
Read-onlyIdempotent

Compares and ranks up to 10 Brazilian municipalities or states by a chosen indicator—population, GDP, area, density, literacy, or households—and calculates summary statistics.

Instructions

Compares data between localities (municipalities or states).

Available indicators:

  • populacao: Current population estimate

  • populacao_censo: Census 2022 population

  • pib: GDP per capita

  • area: Territorial area (km²)

  • densidade: Population density (inhab/km²)

  • alfabetizacao: Literacy rate

  • domicilios: Number of households

Features:

  • Compare up to 10 localities at once

  • Calculate statistics (max, min, average, variation)

  • Generate ranked output

  • Accept municipality codes (7 digits) or state codes (2 digits)

Examples:

  • Compare capitals: localidades="3550308,3304557,4106902", indicador="populacao"

  • Compare states: localidades="35,33,41", indicador="pib"

  • Area ranking: localidades="3550308,3304557", formato="ranking"

  • List indicators: indicador="listar"

Use this tool ONLY to rank/compare 2–10 localities on one indicator. For a single locality, use ibge_cidades (municipal panel), ibge_censo, or ibge_sidra.

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

Input Schema

NameRequiredDescriptionDefault
formatoNoFormato de saída: tabela, json ou ranking (ordenado)tabela
indicadorNoIndicador para comparação: - populacao: Estimativa populacional atual - populacao_censo: População do Censo 2022 - pib: PIB a preços correntes (Mil Reais) - area: Área territorial (km²) - densidade: Densidade demográfica (hab/km²) - alfabetizacao: Taxa de alfabetização - domicilios: Número de domicílios - listar: Lista indicadores disponíveispopulacao
localidadesYesCódigos IBGE das localidades separados por vírgula (ex: "3550308,3304557,4106902"). Use 7 dígitos para municípios, 2 dígitos para UFs.

Output Schema

NameRequiredDescriptionDefault
nomeNoNome do indicador
tabelaNoTabela SIDRA de origem
formatoNoFormato solicitado
unidadesYesUnidade de medida de cada variável da resposta, FORA de `registros`: não some com `campos` nem com a paginação. Leia antes de citar um valor — 'Mil pessoas' significa que 1.234 são 1,234 milhão de pessoas
indicadorNoIndicador comparado
provenanceYesBloco de proveniência do portfólio: fonte, URL, período, extração, diagnóstico de origem e licença
attributionYesURLs canônicas das fontes desta resposta (lista de atribuição)
localidadesYesLocalidades comparadas, com o valor do indicador
estatisticasNoEstatísticas agregadas (quando há ao menos 2 valores positivos)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv5.11.0
    • addedOutput schema / properties / estatisticas / properties / maior / description
      Added value: +"Maior valor entre as localidades com valor"
    • addedOutput schema / properties / estatisticas / properties / media / description
      Added value: +"Média aritmética dos valores das localidades"
    • addedOutput schema / properties / estatisticas / properties / menor / description
      Added value: +"Menor valor entre as localidades com valor"
    • addedOutput schema / properties / estatisticas / properties / variacaoPct / description
      Added value: +"Quanto o maior supera o menor, em % ((maior/menor - 1) x 100; 0 se o menor for 0)"
  2. Changed9 schema fields changedv5.10.0
    • changedOutput schema / properties / provenance / description
      Previous value: -"Bloco de proveniência (contrato v1.1): fonte, URL, período, extração, diagnóstico de origem e licença"New value: +"Bloco de proveniência do portfólio: fonte, URL, período, extração, diagnóstico de origem e licença"
    • addedOutput schema / properties / provenance / properties / derivation_note
      Added value: +{
      +  "description": "O que o servidor calculou; presente junto com derived",
      +  "type": "string"
      +}
    • addedOutput schema / properties / provenance / properties / derived
      Added value: +{
      +  "description": "Presente (true) só quando o servidor calculou o valor — estatísticas, rankings, comparações — em vez de repassá-lo como veio do IBGE",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / provenance / properties / field_sources
      Added value: +{
      +  "description": "Proveniência por sub-fonte: presente só quando a resposta junta partes extraídas de origens ou em momentos distintos, uma entrada por grupo de campos; ausente quando a resposta vem de uma única extração",
      +  "items": {
      +    "additionalProperties": false,
      +    "description": "Proveniência de um grupo de campos da resposta: de onde veio e quando foi extraído",
      +    "properties": {
      +      "data_vintage": {
      +        "description": "Vintage/competência da sub-fonte",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "dataset_id": {
      +        "description": "Identificador do conjunto da sub-fonte",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "fields": {
      +        "description": "Campos do payload atribuídos a esta sub-fonte",
      +        "items": {
      +          "type": "string"
      +        },
      +        "minItems": 1,
      +        "type": "array"
      +      },
      +      "retrieved_at": {
      +        "description": "ISO-8601 da extração desta sub-fonte na origem",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "served_from_cache": {
      +        "description": "true se esta sub-fonte veio do cache do servidor (retrieved_at é o da extração original); false se foi buscada nesta chamada; null se o servidor não distingue",
      +        "type": [
      +          "boolean",
      +          "null"
      +        ]
      +      },
      +      "source_url": {
      +        "description": "URL canônica da sub-fonte que originou estes campos",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "fields",
      +      "source_url",
      +      "dataset_id",
      +      "data_vintage",
      +      "retrieved_at"
      +    ],
      +    "type": "object"
      +  },
      +  "minItems": 1,
      +  "type": "array"
      +}
    • addedOutput schema / properties / provenance / properties / notices
      Added value: +{
      +  "description": "Avisos que o IBGE publica junto com o dado (quebra de série, unidade, atualização), copiados como vieram; ausente quando não há aviso",
      +  "items": {
      +    "type": "string"
      +  },
      +  "minItems": 1,
      +  "type": "array"
      +}
    • changedOutput schema / properties / provenance / properties / retrieval / description
      Previous value: -"Diagnóstico de origem desta chamada (contrato v1.1): idas à API do IBGE, tentativas somadas e anomalias contornadas; unstable=true quando houve anomalia. null quando nada foi medido (resposta servida só do cache)"New value: +"Diagnóstico de origem desta chamada: idas à API do IBGE, tentativas somadas e anomalias contornadas; unstable=true quando houve anomalia. null quando nada foi medido (resposta servida só do cache)"
    • addedOutput schema / properties / provenance / properties / revision
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Se o dado ainda pode mudar no IBGE: current = versão vigente na extração, que o IBGE pode revisar depois; provisional = preliminar; final = não muda mais. note traz o específico da fonte quando há",
      +  "properties": {
      +    "note": {
      +      "description": "O específico da fonte: o que revisa, quando, por quê",
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "status": {
      +      "description": "current = versão vigente, a fonte pode revisá-la; provisional = preliminar, incompleta ou sujeita a mudança (não compare como se fosse fechada); final = não muda mais, declarado pela fonte",
      +      "enum": [
      +        "current",
      +        "provisional",
      +        "final"
      +      ],
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "status",
      +    "note"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / unidades
      Added value: +{
      +  "description": "Unidade de medida de cada variável da resposta, FORA de `registros`: não some com `campos` nem com a paginação. Leia antes de citar um valor — 'Mil pessoas' significa que 1.234 são 1,234 milhão de pessoas",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "multiplicador": {
      +        "description": "Multiplicador de escala publicado à parte; o SIDRA não publica — sempre null, a escala está no texto da unidade",
      +        "type": [
      +          "number",
      +          "null"
      +        ]
      +      },
      +      "nomeVariavel": {
      +        "description": "Nome da variável",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "unidade": {
      +        "description": "Unidade de medida como a fonte publica, com a escala no texto (ex.: 'Mil pessoas', 'Milhões de Reais'); null se a fonte não diz",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "variavel": {
      +        "description": "Código da variável SIDRA (null se a resposta não tem a dimensão Variável)",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      }
      +    },
      +    "required": [
      +      "variavel",
      +      "nomeVariavel",
      +      "unidade",
      +      "multiplicador"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "localidades",
      -  "provenance",
      -  "attribution"
      -]New value: +[
      +  "localidades",
      +  "unidades",
      +  "provenance",
      +  "attribution"
      +]
  3. Changed3 schema fields changedv5.4.0
    • changedOutput schema / properties / provenance / description
      Previous value: -"Bloco de proveniência (contrato v1.0): fonte, URL, período, extração e licença"New value: +"Bloco de proveniência (contrato v1.1): fonte, URL, período, extração, diagnóstico de origem e licença"
    • addedOutput schema / properties / provenance / properties / retrieval
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "anomalies": {
      +          "description": "Anomalias superadas até o sucesso, somadas por classe, em ordem fixa; [] se nenhuma",
      +          "items": {
      +            "additionalProperties": false,
      +            "properties": {
      +              "count": {
      +                "description": "Ocorrências desta classe na chamada",
      +                "maximum": 9007199254740991,
      +                "minimum": 1,
      +                "type": "integer"
      +              },
      +              "kind": {
      +                "description": "Classe da anomalia (vocabulário fechado do contrato)",
      +                "enum": [
      +                  "timeout",
      +                  "network",
      +                  "http_4xx",
      +                  "http_5xx",
      +                  "rate_limited",
      +                  "malformed_body"
      +                ],
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "kind",
      +              "count"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "attempts": {
      +          "description": "Tentativas somadas, incluindo as repetidas (>= requests)",
      +          "maximum": 9007199254740991,
      +          "minimum": 1,
      +          "type": "integer"
      +        },
      +        "requests": {
      +          "description": "Idas distintas à origem que compõem esta resposta (fatias, páginas)",
      +          "maximum": 9007199254740991,
      +          "minimum": 1,
      +          "type": "integer"
      +        },
      +        "unstable": {
      +          "description": "true se houve repetição (attempts > requests) ou alguma anomalia",
      +          "type": "boolean"
      +        }
      +      },
      +      "required": [
      +        "requests",
      +        "attempts",
      +        "anomalies",
      +        "unstable"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "Diagnóstico de origem desta chamada (contrato v1.1): idas à API do IBGE, tentativas somadas e anomalias contornadas; unstable=true quando houve anomalia. null quando nada foi medido (resposta servida só do cache)"
      +}
    • changedOutput schema / properties / provenance / required
      Previous value: -[
      -  "source",
      -  "source_url",
      -  "data_vintage",
      -  "retrieved_at",
      -  "citation",
      -  "license"
      -]New value: +[
      +  "source",
      +  "source_url",
      +  "data_vintage",
      +  "retrieved_at",
      +  "retrieval",
      +  "citation",
      +  "license"
      +]
  4. Changed1 schema field changedv5.0.0
    • addedInput schema / additionalProperties
      Added value: +false
  5. Changed6 schema fields changedv4.0.0
    • changedInput schema / properties / indicador / description
      Previous value: -"Indicador para comparação:\n- populacao: Estimativa populacional atual\n- populacao_censo: População do Censo 2022\n- pib: PIB per capita\n- area: Área territorial (km²)\n- densidade: Densidade demográfica (hab/km²)\n- alfabetizacao: Taxa de alfabetização\n- domicilios: Número de domicílios\n- listar: Lista indicadores disponíveis"New value: +"Indicador para comparação:\n- populacao: Estimativa populacional atual\n- populacao_censo: População do Censo 2022\n- pib: PIB a preços correntes (Mil Reais)\n- area: Área territorial (km²)\n- densidade: Densidade demográfica (hab/km²)\n- alfabetizacao: Taxa de alfabetização\n- domicilios: Número de domicílios\n- listar: Lista indicadores disponíveis"
    • changedOutput schema / properties / localidades / items / properties / valor / type
      Previous value: -"number"New value: +[
      +  "number",
      +  "null"
      +]
    • 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"
      +]
  6. Changed6 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
    • 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 / 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"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "localidades"
      -]New value: +[
      +  "localidades",
      +  "provenance",
      +  "attribution"
      +]
  7. Changed1 schema field changedv3.0.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "estatisticas": {
      +      "additionalProperties": false,
      +      "description": "Estatísticas agregadas (quando há ao menos 2 valores positivos)",
      +      "properties": {
      +        "maior": {
      +          "type": "number"
      +        },
      +        "media": {
      +          "type": "number"
      +        },
      +        "menor": {
      +          "type": "number"
      +        },
      +        "variacaoPct": {
      +          "type": "number"
      +        }
      +      },
      +      "required": [
      +        "maior",
      +        "menor",
      +        "media",
      +        "variacaoPct"
      +      ],
      +      "type": "object"
      +    },
      +    "formato": {
      +      "description": "Formato solicitado",
      +      "type": "string"
      +    },
      +    "indicador": {
      +      "description": "Indicador comparado",
      +      "type": "string"
      +    },
      +    "localidades": {
      +      "description": "Localidades comparadas, com o valor do indicador",
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "codigo": {
      +            "type": "string"
      +          },
      +          "nome": {
      +            "type": "string"
      +          },
      +          "valor": {
      +            "type": "number"
      +          },
      +          "valorTexto": {
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "codigo",
      +          "nome",
      +          "valor",
      +          "valorTexto"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "nome": {
      +      "description": "Nome do indicador",
      +      "type": "string"
      +    },
      +    "tabela": {
      +      "description": "Tabela SIDRA de origem",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "localidades"
      +  ],
      +  "type": "object"
      +}
  8. First observedv1.0.0

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare read-only, idempotent, open-world, non-destructive, so the safety profile is covered; the description adds useful extra context about the live GET against public IBGE APIs (SIDRA and Localidades) and the Markdown plus structuredContent return. The 10-locality cap is also disclosed behaviourally. It stops short of noting failure modes (invalid codes, missing indicators).

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?

Front-loaded purpose sentence, then a scannable indicator list, features, examples, and a routing line. Every block earns its place and the exclusions appear before the examples.

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?

With an output schema present and full annotations, the description only needs to cover intent, scope, routing, and input shape — all of which it does, including a 'listar' escape hatch for indicator discovery.

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

Parameters2/5

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

Schema coverage is 100%, so the description adds little — and where it does it can mislead: it describes 'pib' as 'GDP per capita', while the schema defines pib as 'PIB a preços correntes (Mil Reais)', a total at current prices. An agent relying on the description would misinterpret the returned value. The code-format guidance (7-digit municipality, 2-digit UF) matches the schema rather than extending it.

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 ('Compares data between localities') and immediately scopes the resource type (municipalities or states, 2–10 at once, one indicator). The closing line 'Use this tool ONLY to rank/compare 2–10 localities on one indicator' makes it unambiguously distinguishable from siblings like ibge_indicadores or ibge_sidra.

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?

Explicit both ways: 'Use this tool ONLY to rank/compare 2–10 localities on one indicator' gives the when, and 'For a single locality, use ibge_cidades, ibge_censo, or ibge_sidra' names the alternatives and the condition that selects them. Concrete example calls reinforce the routing.

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