Skip to main content
Glama

Códigos geográficos do IBGE

ibge_geocodigo
Read-onlyIdempotent

Decode IBGE geographic codes or search codes by locality name to identify Brazilian regions, states, municipalities, and districts with their hierarchy.

Instructions

Decodes IBGE codes or searches codes by locality name.

Features:

  • Decode region, state, municipality, or district codes

  • Search IBGE code by name

  • Show complete geographic hierarchy

  • Return related codes

Code structure:

  • 1 digit: Region (1=North, 2=Northeast, 3=Southeast, 4=South, 5=Central-West)

  • 2 digits: State (11-53)

  • 7 digits: Municipality

  • 9 digits: District

Examples:

  • Decode municipality: codigo="3550308"

  • Decode state: codigo="35"

  • Search by name: nome="São Paulo"

  • Municipality in state: nome="Campinas", uf="SP"

This tool decodes a code's structure and resolves name→code at any level. Use a different tool when:

  • You only need to list/search municipalities → ibge_municipios

  • You want the full detailed record of one locality → ibge_localidade

Behavior: read-only and idempotent — a live GET against the public IBGE Localidades API. Returns Markdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ufNoEstado por sigla (SP), nome (São Paulo) ou código IBGE (35) para restringir a busca por nome de município
nomeNoNome da localidade para encontrar o código IBGE (estado ou município)
codigoNoCódigo IBGE para decodificar. Formatos aceitos: - 1 dígito: Região (1-5) - 2 dígitos: UF (11-53) - 7 dígitos: Município - 9 dígitos: Distrito

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
nomeNoNome da localidade resolvida
tipoYesTipo do resultado: localidade decodificada (regiao/uf/municipio/distrito) ou lista de municípios encontrados (lista)
siglaNoSigla da região ou UF, quando aplicável
totalNoQuantidade de municípios encontrados na busca por nome (apenas tipo lista)
codigoNoCódigo IBGE da localidade resolvida (ausente em resultados do tipo lista)
regiaoNoNome da região à qual a UF pertence (apenas tipo uf)
estadosNoEstados pertencentes à região (apenas tipo regiao)
matchesNoMunicípios encontrados na busca por nome (apenas tipo lista)
hierarquiaNoHierarquia geográfica completa, da região ao município/distrito (tipo municipio/distrito)
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)
codigoSidraNoCódigo SIDRA de 6 dígitos do município (apenas tipo municipio)
regiaoCodigoNoCódigo IBGE da região à qual a UF pertence (apenas tipo uf)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv5.0.0
    • addedInput schema / additionalProperties
      Added value: +false
  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. 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: -[
      -  "tipo"
      -]New value: +[
      +  "tipo",
      +  "provenance",
      +  "attribution"
      +]
  4. Changed2 schema fields changedv3.0.0
    • changedInput schema / properties / uf / description
      Previous value: -"Sigla da UF para restringir a busca por nome de município"New value: +"Estado por sigla (SP), nome (São Paulo) ou código IBGE (35) para restringir a busca por nome de município"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "codigo": {
      +      "description": "Código IBGE da localidade resolvida (ausente em resultados do tipo lista)",
      +      "type": "number"
      +    },
      +    "codigoSidra": {
      +      "description": "Código SIDRA de 6 dígitos do município (apenas tipo municipio)",
      +      "type": "string"
      +    },
      +    "estados": {
      +      "description": "Estados pertencentes à região (apenas tipo regiao)",
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "codigo": {
      +            "description": "Código IBGE da UF",
      +            "type": "number"
      +          },
      +          "nome": {
      +            "description": "Nome da UF",
      +            "type": "string"
      +          },
      +          "sigla": {
      +            "description": "Sigla da UF",
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "codigo",
      +          "sigla",
      +          "nome"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "hierarquia": {
      +      "description": "Hierarquia geográfica completa, da região ao município/distrito (tipo municipio/distrito)",
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "codigo": {
      +            "description": "Código IBGE do nível",
      +            "type": "number"
      +          },
      +          "nivel": {
      +            "description": "Nome do nível territorial (Região, UF, Município, etc.)",
      +            "type": "string"
      +          },
      +          "nome": {
      +            "description": "Nome da localidade neste nível",
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "nivel",
      +          "codigo",
      +          "nome"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "matches": {
      +      "description": "Municípios encontrados na busca por nome (apenas tipo lista)",
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "codigo": {
      +            "description": "Código IBGE (7 dígitos) do município",
      +            "type": "number"
      +          },
      +          "nome": {
      +            "description": "Nome do município",
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "codigo",
      +          "nome"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "nome": {
      +      "description": "Nome da localidade resolvida",
      +      "type": "string"
      +    },
      +    "regiao": {
      +      "description": "Nome da região à qual a UF pertence (apenas tipo uf)",
      +      "type": "string"
      +    },
      +    "regiaoCodigo": {
      +      "description": "Código IBGE da região à qual a UF pertence (apenas tipo uf)",
      +      "type": "number"
      +    },
      +    "sigla": {
      +      "description": "Sigla da região ou UF, quando aplicável",
      +      "type": "string"
      +    },
      +    "tipo": {
      +      "description": "Tipo do resultado: localidade decodificada (regiao/uf/municipio/distrito) ou lista de municípios encontrados (lista)",
      +      "enum": [
      +        "regiao",
      +        "uf",
      +        "municipio",
      +        "distrito",
      +        "lista"
      +      ],
      +      "type": "string"
      +    },
      +    "total": {
      +      "description": "Quantidade de municípios encontrados na busca por nome (apenas tipo lista)",
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "tipo"
      +  ],
      +  "type": "object"
      +}
  5. First observedv1.0.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already cover readOnly, idempotent, openWorld and non-destructive. The description adds genuinely new context beyond them: it is a live GET against the public IBGE Localidades API and returns Markdown. It does not discuss rate limits or error behavior, so it stops short of a 5.

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 purpose, then cleanly sectioned into features, code structure, examples and alternatives, which suits the tool's branching input modes. The code-structure bullets partially duplicate the parameter schema, costing some efficiency.

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, return values need not be explained. Between the level-decoding rules, the four examples, the named alternatives and the read-only/API/Markdown behavior note, an agent has everything needed to call it correctly.

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 already 100%, so the baseline is 3, but the description adds meaning the schema lacks — the digit-length-to-level mapping (1/2/7/9 digits) and worked examples such as nome="Campinas", uf="SP" that show how nome and uf combine. It stops short of documenting mutual exclusivity between codigo and nome.

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 opening sentence states a specific dual verb (decodes / searches) against a specific resource (IBGE geographic codes), and the 'Use a different tool when' block explicitly names ibge_municipios and ibge_localidade, so an agent can distinguish it from siblings without reading schemas.

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 routing is provided: it says when to use this tool (decode a code at any level, resolve name→code) and when not to, naming two concrete alternatives plus the condition that selects each. Nothing is left to inference.

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