mcp-territorio-brasil
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-territorio-brasilcompare population and GDP of São Paulo and Rio de Janeiro"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-territorio-brasil
Servidor MCP de dados territoriais oficiais do Brasil (IBGE) — com as armadilhas de cruzamento entre bases declaradas na resposta.
Três tools que não mentem, em vez de trinta que não sabem.
O problema que este servidor resolve
Quase toda análise regional no Brasil cruza o IBGE com outra base oficial — DATASUS, CNES, Receita Federal. E o primeiro cruzamento costuma falhar em silêncio:
O código de município do IBGE tem 7 dígitos — o 7º é dígito verificador. O DATASUS e o CNES usam 6 (Canoas/RS =
4304606no IBGE,430460no CNES). Um JOIN direto entre as bases devolve zero linhas, sem erro. A análise parece vazia, não quebrada.
Este servidor devolve os dois códigos em toda resposta e aceita qualquer um deles como entrada.
Related MCP server: ibge-data-mcp
A garantia
Toda resposta segue o phi-data-contract v0.1: data + provenance (fonte, data de coleta,
ano de referência) + caveats (os defeitos que se aplicam àquela consulta, com evidência e data
de verificação) + cannot_answer (o que a pergunta pediu e a fonte não responde).
Instalação
Requer Node ≥ 22.5 (SQLite embutido — zero dependências nativas).
npm install && npm run build
npm run db:build # baixa direto do IBGE (Localidades + SIDRA) e monta o SQLiteNada é redistribuído — a base é construída na sua máquina, sempre da fonte.
{
"mcpServers": {
"territorio": {
"command": "node",
"args": ["--experimental-sqlite", "/caminho/mcp-territorio-brasil/dist/index.js"],
"env": { "TERRITORIO_LANG": "pt" }
}
}
}As tools
Tool | O que faz |
| Município com região imediata/intermediária, população (estimativa + Censo 2022), PIB e PIB per capita. Aceita nome, código de 7 ou de 6 dígitos; |
| Totais de UF, região intermediária ou imediata (nº de municípios, população, PIB) + a lista de municípios. Aceita o código de um município. |
| As armadilhas conhecidas, com evidência e procedência. |
Os caveats
id | Severidade | Corrigido? |
| crítico | ✅ os dois códigos em toda resposta |
| aviso | — as duas séries vêm separadas, com ano |
| aviso | ✅ PIB per capita sobre a população do mesmo período (Censo 2022), nunca sobre a estimativa corrente |
| info | ✅ agrega pela região imediata (divisão oficial desde 2017) |
Fontes
IBGE — API de Localidades (servicodados.ibge.gov.br) e SIDRA (apisidra.ibge.gov.br):
tabelas 6579 (estimativa de população), 4709 (Censo 2022) e 5938 (PIB dos municípios).
npm testMIT · Autor: Luis Delfin · parte da rede de servidores MCP de dados públicos de Phi AI
English
MCP server for Brazil's official territorial data (IBGE) — with cross-dataset traps declared in the response.
The first join between IBGE and another official dataset (DATASUS, CNES, Federal Revenue) usually fails silently: IBGE municipality codes have 7 digits (the 7th is a check digit), DATASUS/CNES use 6. A direct JOIN returns zero rows, no error. This server returns both codes in every response and accepts either as input.
Every response follows phi-data-contract v0.1: data + provenance + caveats + cannot_answer.
Tool | What it does |
| Municipality with immediate/intermediate region, population (estimate + 2022 Census), GDP and GDP per capita. Accepts name, 7- or 6-digit code; |
| Totals for a state, intermediate or immediate region, plus its municipalities. |
| Known traps, with evidence and provenance. |
Requires Node ≥ 22.5. npm install && npm run build && npm run db:build. No data is redistributed.
MIT · Author: Luis Delfin
Available Tools
3 toolsterritorio_data_caveatsB
As armadilhas conhecidas destas bases, com evidência e procedência. Use antes de cruzar com outras bases.
| Name | Required | Description | Default |
|---|---|---|---|
| id | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
There are no annotations, so the description must carry the burden. It adds useful behavioral context: the output includes evidence and provenance and the tool is meant to be consulted before cross-referencing. However, it does not disclose call-level behavior such as whether id filters results, whether the operation is read-only, or any side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is compact and front-loaded: two short sentences that state the resource and the recommended use without filler. It is appropriately brief, though the brevity contributes to the lack of parameter explanation.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple caveats-lookup tool, the description conveys the core purpose and the trigger condition, and the absence of required parameters makes an empty call plausible. But it does not explain the id parameter, what 'destas bases' refers to, or the structure of the returned caveats, so it is only minimally complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the description never mentions the id parameter or explains what it selects or filters. With one optional parameter and zero schema guidance, the description needed to compensate but does not, leaving the agent with no parameter semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies the tool as providing known pitfalls of the databases, with evidence and provenance. It stops short of an explicit verb like 'returns' or 'lists', and it does not explicitly contrast itself with the sibling data-lookup tools, but the resource and intent are clear.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'Use antes de cruzar com outras bases' explicitly tells the agent when to invoke this tool: before joining or crossing with other datasets. It does not mention when not to use it or name alternatives, so it falls short of full usage guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
territorio_municipioA
Município brasileiro com a hierarquia regional oficial (região imediata e intermediária, UF), população (estimativa anual e Censo 2022) e PIB municipal. Aceita nome (sem acento, parcial), código IBGE de 7 dígitos ou código DATASUS/CNES de 6 dígitos — e devolve os dois códigos. Use codes para resolver muitos de uma vez.
| Name | Required | Description | Default |
|---|---|---|---|
| uf | No | Sigla da UF para desambiguar nomes. Ex: 'RS'. | |
| codes | No | Lista de códigos/nomes (até 1000). | |
| limit | No | Máximo de resultados por nome (default 20). | |
| query | No | Nome ou código de um município. Ex: 'Canoas', '4304606', '430460'. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description carries the full disclosure burden. It does a good job by stating that names are matched without accents and partially, that 7-digit IBGE or 6-digit DATASUS/CNES codes are accepted, and that both codes are returned. It stops short of describing result cardinality, ambiguity handling, or data caveats, but the disclosed input/output behaviors are substantially informative.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The definition is a single dense, front-loaded sentence that leads with the core resource and data contract, then moves to input formats and a batch tip. Every clause adds useful information, and there is no filler or repetition of schema details.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Even without an output schema, the description enumerates the main returned content (regional hierarchy, UF, population, PIB, and both codes) and the accepted identifier variants, which is enough to invoke the tool correctly. The main gap is that output shape and behavior for ambiguous or unknown names are not stated, but these are minor for a lookup tool with clear schema coverage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds real meaning by clarifying accepted canonical forms (unaccented/partial names, 7-digit IBGE, 6-digit DATASUS/CNES) and by framing `codes` as the batch-resolution path, which goes beyond the schema's generic list description. It leaves `uf` and `limit` to the schema, which is acceptable given their clear schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names the resource (Brazilian municipality) and specifies its data content: regional hierarchy, UF, population, Census 2022 and municipal PIB. It also makes the lookup behavior explicit by describing accepted identifiers and returning both IBGE and DATASUS/CNES codes, which clearly distinguishes it from sibling tools like territorio_regiao and territorio_data_caveats.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is a useful usage tip for batching ('Use `codes` para resolver muitos de uma vez'), and the municipality-focused wording implies when to use the tool. However, it never explicitly contrasts this tool with territorio_regiao or territorio_data_caveats, nor states when not to use it, so tool-selection guidance remains implicit rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
territorio_regiaoA
Totais de uma região — UF, região geográfica intermediária ou imediata (divisão oficial desde 2017): nº de municípios, população e PIB, mais a lista de municípios. Aceita o código de um município para devolver a região dele.
| Name | Required | Description | Default |
|---|---|---|---|
| nivel | No | Default: imediata. | |
| codigo | Yes | Sigla da UF, código da região, ou código de um município. | |
| incluir_municipios | No | Default true. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full behavioral burden. It usefully discloses the return content (totals and municipality list) and the flexible input modes (UF, region code, or municipality code). However, it does not explicitly state that the operation is read-only, nor does it cover error behavior, authentication, or rate limits, leaving the safety profile partially unspecified.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loaded with the core purpose, followed by a concise note on an alternative input mode. Every clause adds useful information: the region types, the 2017 official division, the output fields, and the flexible code input. No filler or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there is no output schema, the description partially compensates by listing the output fields (municipality count, population, GDP, and municipality list) and clarifying the official regional division. It omits error behavior and the interaction between `nivel` and a municipality-code `codigo`, but it is reasonably complete for a read-oriented aggregate tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so all three parameters are already documented in the input schema. The description reinforces the accepted code formats and the default inclusion of the municipality list, but it does not add meaningful semantic detail beyond what the schema already provides. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies the resource (region) and scope (totals of municipalities count, population, GDP, and municipality list), and notes the special ability to pass a municipality code to get its region. It distinguishes from siblings by focusing on region-level aggregates rather than a single municipality, but it lacks an explicit imperative verb for the main action (e.g., 'Retorna').
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear usage context: use it to get aggregate totals for a UF, intermediate, or immediate region, or to find which region a given municipality belongs to. It does not explicitly name sibling alternatives or state when not to use the tool, so it falls short of full exclusion guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.0- First observed
territorio_data_caveats - First observed
territorio_municipio - First observed
territorio_regiao
TDQS
Scored across 3 tools
Each tool targets a distinct level of data: municipality, region, and data caveats. Although both municipio and regiao can reveal a municipality's region, their outputs and purposes are clearly differentiated. No ambiguity exists.
All tools follow the same `territorio_<entity>` snake_case pattern, making the set predictable and easy to navigate. The naming convention is uniform across all three tools.
Three tools is a focused, well-scoped set for a Brazilian territory data server. Each tool addresses a distinct need without redundancy or bloat.
The server covers municipality-level data, regional aggregates, and data-quality caveats, which covers the core needs for querying official Brazilian territorial divisions. No obvious missing operations exist for a read-only data server.
Maintenance
Related MCP Connectors
IBGE: geography, census, economy and health from the official APIs, with provenance. 23 tools.
Discover, resolve, and query official Brazilian economic data with semantic search and provenance.
IBGE: Código de Município, official-source lookup. Platform-hosted, pay per query with prepaid credi
Brazilian addresses for agents: IBGE-geocoded CEP points, radius search and companies by CEP.
Related MCP Servers
- AlicenseAqualityBmaintenanceExposes official IBGE data as MCP tools, including Brazilian localities, SIDRA statistical aggregates, and population indicators.11MIT
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to access Brazilian IBGE statistical data (population, economy, agriculture) via natural language, with tools for querying aggregated data and metadata.-
- AlicenseAqualityDmaintenanceEnables AI agents to access Brazilian statistical, geographic, and economic data in real-time via IBGE public APIs.325 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables querying official Brazilian territorial area data from IBGE through a single read-only tool, usable with any MCP client.MIT