Skip to main content

GeoSGB MCP — Brazilian geological data in your AI assistant

CI Python MCP License: MIT

🇧🇷 Leia em Português

An MCP server that brings to Claude, ChatGPT or any MCP client the data of GeoSGB, the geoportal of the Geological Survey of Brazil (SGB/CPRM): mineral occurrences, geological outcrops and the units of the geological map of Brazil.

Getting at this data today means knowing the SGB's ArcGIS portal, its layer names and its query syntax. With this server, geologists, researchers, students and mining-sector analysts ask in plain language ("where are the rare earth occurrences in Goiás?") and get the records from the official source, with coordinates, municipality, economic status and a reference to where each value came from.

Independent project. A community-built client of the geoportal's public services, not affiliated with or endorsed by the Geological Survey of Brazil. The data belong to the SGB; see Data provenance and license.

Contents

Questions it answers

In plain language, inside the MCP client. The assistant picks the tool and the filters:

Question What the server does
Where are the rare earth occurrences in Goiás? rare-earth search in GO: Catalão, Ouvidor, Nova Roma…
Which minerals occur around Araxá (MG)? occurrences in a rectangle around Araxá: niobium, phosphorus, barium…
Which gold mines are recorded in Minas Gerais? substance "Ouro", state "MG", economic status "Mina"
List lithium occurrences in Brazil substance "Lítio", the whole country
Which geological unit lies beneath Belo Horizonte? point query on the 1:1,000,000 geological map
Which outcrops has the SGB described in Ouro Preto? outcrops by state and municipality

The source is in Portuguese. You can ask in English, but substance names, economic statuses and municipalities are matched with the source's Portuguese spelling, accents included: "Ouro" (gold), "Lítio" (lithium), "Nióbio" (niobium), "Terras raras" (rare earths). The assistant translates when it builds the filters, and list_mineral_substances returns the exact names. Records come back with the source's Portuguese values.

A sample response, for the unit beneath downtown Belo Horizonte (excerpt; the full response also carries eras, periods and the whole provenance block):

{
  "count": 1,
  "units": [
    {
      "code": "A34bh",
      "name": "Complexo Belo Horizonte",
      "hierarchy": "Complexo",
      "lithotypes": "Biotita gnaisse, Gnaisse, Granodiorito, Migmatito, Ortognaisse",
      "age_min_ma": 2500.1,
      "age_max_ma": 3200.0,
      "eon_min": "Arqueano"
    }
  ]
}

And the footer that comes with every response, for clients that only show text (it is written in Portuguese, like the source):

---
Fonte: Serviço Geológico do Brasil (SGB/CPRM) — GeoSGB · https://geoportal.sgb.gov.br/server/rest/services/geologia/litoestratigrafia_1000000/MapServer/0/query?where=1%3D1&f=json&geometry=-43.94%2C-19.92&geometryType=esriGeometryPoint&spatialRel=esriSpatialRelIntersects&inSR=4326 · extraído em 04/12/2026 às 00:55 (UTC)
Licença: Serviço Geológico do Brasil - CPRM (copyrightText do serviço; a fonte não declara licença de uso).

Installation

Prerequisites

  • uv (recommended), which fetches Python and the dependencies by itself; or Python 3.10 or newer, with pip.
  • Internet access: queries go to the SGB geoportal when the question is asked.
  • No account, key or sign-up.

Claude Desktop

Open the configuration file (Settings → Developer → Edit Config) and add:

{
  "mcpServers": {
    "geosgb": {
      "command": "uvx",
      "args": ["geosgb-mcp"]
    }
  }
}

Restart Claude Desktop. The tools show up under the name geosgb.

Claude Code

claude mcp add geosgb -- uvx geosgb-mcp

Other MCP clients

Any client that runs servers over stdio works, with the same command:

uvx geosgb-mcp

With pip

pip install geosgb-mcp
geosgb-mcp

From source

git clone https://github.com/SidneyBissoli/geosgb-br-mcp
cd geosgb-br-mcp
pip install -e .
geosgb-mcp            # or: python -m geosgb_mcp.server

Usage

Tools

Tool What for Required filter
search_mineral_occurrences Mineral occurrences by substance, state, municipality, economic status and/or rectangle none
search_rare_earth_occurrences Ready-made rare-earth search by state and/or rectangle none
get_occurrence_details The full record of one occurrence: rocks, province, map sheet, project the id
list_mineral_substances Every substance, with the exact spelling the search requires —
get_geological_outcrops Outcrops: rock described in the field, not ore state + municipality, or a rectangle of up to 1 square degree
get_lithology_by_area Units of the 1:1,000,000 geological map in a rectangle or beneath a point a rectangle of up to 25 square degrees, or a point
search / fetch ChatGPT Deep Research contract: finds mineral substances and provinces and reads a document —

All tools are read-only. A request without the required filter is refused before it reaches the portal, with a message saying what was missing.

Resources

Read without calling the portal:

  • geosgb://guide: the usage guide, with the tool flow, what each filter accepts and the source's limits (in Portuguese).
  • geosgb://reference/substances: the recorded substances and mineral provinces, with the number of occurrences of each.

Filling in the filters

  • State (uf) is the two-letter code in capitals: "MG", not "mg" or "Minas".
  • Substance and municipality follow the source's spelling, accents included. "Nióbio" finds hundreds of occurrences; "Niobio" finds none. When in doubt, the assistant calls list_mineral_substances.
  • Economic status is one of four values: "Mina" (mine), "Garimpo" (artisanal mining), "Indeterminado" (undetermined) or "Não explotado" (not exploited).
  • Rectangle (bbox) in WGS84 degrees, with all four corners (bbox_xmin, bbox_ymin, bbox_xmax, bbox_ymax) or none.
  • Rare earths: by default the search looks at the substance. With include_related_rocks=True it adds the rocks that typically host them and returns many more records, almost all of them pegmatites; use it when the target is the rock, not the element.

What to expect from the source

The SGB geoportal does not paginate: each query downloads everything that matches the filter, and limit/offset are applied afterwards, in ascending id order (limit goes up to 120, or 100 geological units, so that a page fits in what the client receives; total_count says how many there are). A filtered search usually answers in under a second; a whole state's occurrences take a few seconds; the full substance list takes about 20 seconds the first time and then comes from a 24-hour cache. With a "cold" portal, the first call can take much longer. That is why outcrops and geological units require a cut: they are hundreds of thousands of points and tens of thousands of polygons.

In get_lithology_by_area the response is computed by the server: the portal returns polygons and the server groups them by unit. The area_deg2 field sums the area of the whole polygons that touch the cut, in square degrees. It is for ranking the units, not for measuring the area inside the cut.

Data provenance and license

Every response says where it came from, in three places:

  • in the result's provenance block: layer queried, filter applied, a URL that reproduces the query on the portal, and the extraction timestamp;
  • in the response's _meta, for clients that audit or display the source;
  • in the text footer shown above, for clients that only show text.

The SGB declares no license of use for these services: it publishes only the notice "Serviço Geológico do Brasil - CPRM", and states at sgb.gov.br/dados-abertos that it has no Open Data Plan. When using the data, cite: Fonte: Serviço Geológico do Brasil (SGB/CPRM) — GeoSGB.

Built with

  • Python 3.10+, with the official MCP SDK
  • httpx for the queries to the SGB's ArcGIS REST portal
  • Pydantic for the input and output schemas the server publishes to the client
  • pytest and jsonschema in the tests; mcpscore for the MCP conformance audit

Development and tests

pip install -e ".[dev]"
pytest                       # offline suite, with a simulated portal (the one CI runs)
INTEGRATION_TESTS=1 pytest   # adds the suites that hit the real geoportal

The offline suite starts the real server in an in-memory MCP session and checks each tool against the schema it publishes. CI also audits the server with mcpscore and requires a full score. Every week a job checks that the portal's services still have the fields and formats the server expects.

Each tool is tested in four layers, from one table of cases with fixed arguments and content checks (tests/support/tool_cases.py):

  1. Coverage (tests/test_tool_coverage.py, offline): every tool listed by the server has a case, a recording, a tool-selection query, an answer question and a worst case for the size gates; and every tool with limit has offset.
  2. Live (tests/test_tools_live.py and tests/test_tamanho.py, with INTEGRATION_TESTS=1): each case against the real portal, and the worst case of each tool within the ~80,000 characters a client receives.
  3. Replay (tests/test_tool_replay.py, offline): each case against the portal's recorded response in tests/fixtures/tools/, written only by python scripts/record_tool_fixtures.py [case id].
  4. Evals with a real model: python -m evals.run_answers asks one question per tool through claude -p and checks the facts in the answer; python -m evals.run_selection measures tool choice through the Anthropic API (paid; needs ANTHROPIC_API_KEY).

Two scripts regenerate the files in src/geosgb_mcp/data/: python scripts/gerar_referencia.py (the substance and province list, read from the portal) and uv run --no-project --with pillow python scripts/gerar_icone.py (the icon).

Contributing

  • Found an error or odd data? Open an issue with the question asked, the tool and filters used, and what you expected to see. English or Portuguese.
  • Want to propose a change? Open an issue before a large pull request, so we can agree on the design. In the pull request, run pytest and add tests for what changed.

License

Code under the MIT license. The data queried belong to the Geological Survey of Brazil; see Data provenance and license.

Metadata

Release files for geosgb-mcp 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geosgb-mcp 0.9.0
File Size Uploaded Provenance Actions
geosgb_mcp-0.9.0.tar.gz 369.6 kB With provenance Details for geosgb_mcp-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geosgb-mcp 0.9.0
File Interpreter ABI Platform Actions
geosgb_mcp-0.9.0-py3-none-any.whl Python 3 none any Details for geosgb_mcp-0.9.0-py3-none-any.whl

Total release size: 442.4 kB

Release files / geosgb_mcp-0.9.0.tar.gz

Download URL geosgb_mcp-0.9.0.tar.gz
Size 369.6 kB
Tags Source
SHA-256 checksum
How to use checksums
db814d5f79ef8c0de4b785abc94c9b275a1811a96e4a5063e2fde7728a79a0f6
BLAKE2b-256 checksum
How to use checksums
def55fa5db2bf3b76fb6a4aa2568a9092ad227392e7d75a77fd769bac3c78b59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / geosgb_mcp-0.9.0-py3-none-any.whl

Download URL geosgb_mcp-0.9.0-py3-none-any.whl
Size 72.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f37e14701d22f5e0c8949969ce2a34481389247e718d472b1358e1b1af2041da
BLAKE2b-256 checksum
How to use checksums
b4f2b360876b7607705fdcf2c8b5ab02ffee0ff387ee376b741d5d162d7a03e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for geosgb-mcp 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geosgb_mcp-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page