Repository avatar
Other Tools
v0.9.1
active

geosgb-br-mcp

io.github.SidneyBissoli/geosgb-br-mcp

Brazil geology from GeoSGB (Geological Survey of Brazil): mineral occurrences, outcrops, lithology.

Documentation

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:

QuestionWhat the server does
Which mineral substances does the SGB record?every substance in the occurrence layer, with the exact spelling the search needs
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 Brazilsubstance "Lítio", the whole country
Give me the details of occurrence 40362the full record: cobalt, copper, chromium, nickel, gold and platinum in komatiite, São Francisco province, Passos (MG)
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

Remote (nothing to install)

The server is hosted at https://geosgb.sidneybissoli.com/mcp (Streamable HTTP, no account or key). In Claude, add it as a custom connector (Settings → Connectors → Add custom connector) with that URL. In Claude Code:

claude mcp add --transport http geosgb https://geosgb.sidneybissoli.com/mcp

Any client that speaks Streamable HTTP takes the same URL. To run the server on your own machine instead, follow the sections below.

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

ToolWhat forRequired filter
search_mineral_occurrencesMineral occurrences by substance, state, municipality, economic status and/or rectanglenone
search_rare_earth_occurrencesReady-made rare-earth search by state and/or rectanglenone
get_occurrence_detailsThe full record of one occurrence: rocks, province, map sheet, projectthe id
list_mineral_substancesEvery substance, with the exact spelling the search requires—
get_geological_outcropsOutcrops: rock described in the field, not orestate + municipality, or a rectangle of up to 1 square degree
get_lithology_by_areaUnits of the 1:1,000,000 geological map in a rectangle or beneath a pointa rectangle of up to 25 square degrees, or a point
search / fetchChatGPT 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, the extraction timestamp and how hard the data was to get (retrieval: requests to the portal, attempts, and the anomalies overcome on the way — timeouts, portal errors, malformed responses; unstable: true when the portal wavered, and a line in the footer says so);
  • 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.