mcp-geo-server
Provides integration with local or cloud Ollama models as the LLM backend for the agent, enabling natural language processing of geospatial requests to drive GeoServer operations.
Click on "Install 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-geo-serverhow many features are in topp:states?"
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-geo-server
An intelligent MCP (Model Context Protocol) server that drives a GeoServer instance in natural language, plus a chat + map web UI and a fully Dockerised, domain-agnostic GIS stack.
The MCP server is built with the Microsoft Agent Framework: an LLM-backed
agent is given the GeoServer operations as tools and exposed as a single MCP
tool via agent.as_mcp_server(). Any MCP client sends a request like "how many
features in topp:states?" and the agent decides which GeoServer operations to
call. The LLM backend is pluggable β host Ollama, Ollama Cloud, or
Anthropic Claude.
Nothing in the code is tied to a specific dataset: the example stack ships the ISPRA landslide/hazard open data, but the catalog, the natural-language layer resolution and the thematic styles are all driven by GeoServer metadata and config, so the same stack serves any domain.
The same async core (GeoServerClient + the geo_* tool functions + the shared
ingest/catalog/styling modules) is used by the agent, the web UI and the
data bootstrap β there is exactly one place that talks to GeoServer.

The chat (left) resolves a natural-language request to GeoServer layers and renders them on the map (right) with a thematic legend β here the landslide areas of the Marche region, classified by movement type.
Highlights
π§ Natural-language GeoServer agent over MCP (stdio or streamable-HTTP).
π¬ Chat-first web UI: ask in plain language, the matching layers render on a Leaflet map with a live WMS legend. Shapefile upload on a dedicated page.
π¦ Idempotent data bootstrap: drop shapefiles in
./data, the stack loads them into PostGIS and publishes them as GeoServer layers automatically.π¨ Config-driven thematic SLD styles (YAML) β no styles hardcoded in code.
π Domain-agnostic: the layer catalog is read from the WMS capabilities; style assignment is name-pattern based. Point it at any GeoServer.
π₯οΈ Native arm64 + amd64 images (no QEMU emulation on Apple Silicon), with a per-architecture image switch in the Makefile.
π CI/CD: a GitHub Action builds and publishes multi-arch images to GHCR.
Related MCP server: AnythingLLM MCP Server
Prerequisites
Python 3.11+
Docker + Docker Compose
A host Ollama (https://ollama.com) for the local LLM β or use Ollama Cloud / Anthropic instead. There is no Ollama container; the stack talks to the host Ollama via
host.docker.internal.
1. Start the stack (Docker)
ollama serve & # start host Ollama (if not already running)
make ollama-pull # pull the model onto the HOST Ollama (see OLLAMA_LLM_MODEL)
make build # build the app images + pull GeoServer/PostGIS (per host arch)
make up # start the whole stack (checks host Ollama is reachable)The Compose project is mcp-geo-server:
Service | Container | Endpoint / role |
|
| http://localhost:8000 β chat + map UI (also proxies WMS) |
|
| http://localhost:9000/mcp β intelligent MCP server (streamable-HTTP) |
|
| http://localhost:8080/geoserver (admin / |
|
|
|
|
| one-shot: load |
The LLM (host Ollama / Cloud / Anthropic) is reached lazily over the network, so
it never gates startup. GeoServer runs with CORS_ENABLED=true; the web UI also
proxies WMS (see below) so the browser never needs to reach GeoServer directly.
Native images & the per-architecture switch
Base images are multi-arch and selected by uname -m in the Makefile, so they
run native (no emulation) on both Apple Silicon and Intel:
Host arch | PostGIS | GeoServer | GeoServer data dir |
|
|
|
|
|
|
|
|
Override per run with POSTGIS_IMAGE / GEOSERVER_IMAGE / GEOSERVER_DATA_DIR.
Bare docker compose (without make) defaults to the multi-arch images.
2. Web UI β chat & map
Open http://localhost:8000. The window is split: left = chat, right = a Leaflet/OpenStreetMap map with a WMS legend (bottom-right).
Chat β type a request like "mostrami le frane lineari del Molise" or "trova le frane in Puglia". An LLM resolves it to the matching published layer(s) (
POST /api/ask); the map renders them as WMS overlays, zooms to their extent, shows the legend, and the assistant replies with a textual description of the data type (geometry kind, feature count, attributes). Empty layers are flagged and not drawn.β¬οΈ Carica shapefile (dedicated page
/upload) β drag-and-drop a.zipshapefile; it is loaded into PostGIS (uploadsworkspace) and published (POST /api/upload).
WMS proxy
The UI talks to WMS only through the web UI (GET /wms), which forwards
GetMap/GetLegendGraphic to GeoServer over the internal network and streams the
bytes back. This keeps everything same-origin (no host/port juggling, no CORS),
and retries on transient 429 so tiled overlays load reliably.
3. Data bootstrap & thematic styles
Bootstrap β the geo-init container loads every shapefile under ./data
into PostGIS and publishes each as a GeoServer layer (default workspace ispra,
datastore ispra_pg), reprojecting to EPSG:4326. It also registers every
GeoTIFF (*.tif / *.tiff, e.g. a DTM/DEM) as an external coverage store β
zero-copy: GeoServer reads the file in place through the shared ./data mount,
the raster is never duplicated. Fully idempotent and transversal β no assumption
about folder names; the layer name comes from the parent folder. It runs
automatically on make up; re-run on demand:
make init # load any new shapefiles + (re)apply styles
make init-force # drop & reload tables that already exist
make styles # only (re)apply the thematic styles
make init-logs # tail the geo-init logsVariable | Default | Meaning |
|
| Turn the bootstrap on/off |
|
| Target workspace / PostGIS datastore |
|
| All layers reprojected to this SRS |
| (none) | Fallback source SRS for shapefiles without a |
|
| Shapefile attribute encoding (e.g. ISPRA |
|
| Drop & reload existing tables |
|
| Register GeoTIFFs ( |
| (vector workspace) | Workspace for the raster coverages |
|
| Rewrite each raster as a COG (overviews) for fast WMS β recommended for large DTMs |
|
| Apply the thematic styles after publishing |
|
| Style config file (falls back to the packaged default if missing) |
|
| Target for UI shapefile uploads |
Thematic styles are config-driven β no SLD is hardcoded. Styles and the
layerβstyle assignment live in a YAML file, so the same engine serves any
domain. The active config is data/styles.yml; if absent, the packaged
mcp_geo_server/styles_default.yml (ISPRA landslide/hazard domain) is the
fallback.
styles: # name -> SLD definition
frana_tipo_poly:
kind: polygon # polygon | line | point | flat | outline | raster
attribute: tipo_movim # categorical: one rule per class
stroke: true
classes:
- {value: "1", label: "Crollo / Ribaltamento", color: "#e41a1c"}
# ...
dtm_elevation: # raster elevation ramp (RasterSymbolizer)
kind: raster
entries:
- {quantity: 0, color: "#1a9850", label: "0 m"}
- {quantity: 3500, color: "#ffffff", label: "3500 m"}
assign: # ordered rules, FIRST match wins (by layer name)
- {name_matches: "^frane_line", style: frana_tipo_line}
- {name_matches: "^(frane|aree|dgpv)_poly", style: frana_tipo_poly}
- {name_contains: idraulica, style: pericolosita_idraulica}
- {name_matches: "(dtm|dem)", style: dtm_elevation}assign rules match a layer by name (name_contains substring or
name_matches regex) β purely name-based, so the styling engine carries no
hardcoded vocabulary. The patterns are domain-specific config, not code. To
restyle for another domain, edit data/styles.yml and run make styles.
4. Natural-language layer resolution (domain-agnostic)
POST /api/ask maps a request to layers with no hardcoded vocabulary:
The catalog is built from the WMS GetCapabilities document β every published layer's real
name,title,abstractandkeywords.A lightweight LLM "resolver" (no GeoServer tools, JSON-only output) matches the request against that metadata and returns the exact layer name(s), an optional
cql_filter, and a short explanation. Hallucinated names are dropped against the catalog.Filterable attributes (with their allowed values and the layers they live on) are derived from the style config and passed to the resolver, so it builds a CQL on real values and picks a layer that actually has the attribute (e.g.
per_fr_ita = 'Elevata P3'for "alta pericolositΓ " β the hazard layer, not a landslide-inventory one).
The server does the rest β the response is ready for any map client:
Draw order β
layerscome back bottomβtop (rasters below vectors; broadest raster lowest) with akindper layer, so an opaque raster never hides the vectors.Admin-area scoping β if the request names a comune / provincia / regione (ISTAT boundary layers), the response carries the zoom
bboxand, per layer, the way to restrict it to that area: rasters get an exact-polygonclip, vectors get a CQLINTERSECTSspatial filter (a robust predicate β no geometry overlay, so no JTS non-noded intersection failure on dense layers).Per-layer CQL β
cql_by_layeronly applies a filter to layers that have the attribute, so one filter can't fail the whole render.Terrain enrichment β if the request names a metric (quota / slope / aspect / curvature), the selected vector layers are enriched from a DTM (
geo_enrich_from_dtm) and a ready-to-show summary is returned.
Because it relies on GeoServer metadata + config, it works for any GeoServer
β just publish layers with meaningful titles/keywords (and, optionally, your own
data/styles.yml).
5. The intelligent MCP server (Microsoft Agent Framework)
The MCP server is an agent, not a flat list of tools. server.py builds a
GeoServer agent (agent.py: a chat client + the geo_* functions as tools) and
exposes it with agent.as_mcp_server(). The MCP client therefore sees one
tool, geoserver-agent, that takes a natural-language task.
Run it over either transport (selected by GEO_MCP_TRANSPORT):
# stdio (for MCP clients that spawn the process, e.g. Claude Desktop)
mcp-geo-server
# streamable-HTTP (long-lived, visible container) at http://localhost:9000/mcp
GEO_MCP_TRANSPORT=http mcp-geo-serverIn Docker the mcp service runs it over HTTP. Example MCP client call:
from mcp.client.streamable_http import streamablehttp_client
from mcp import ClientSession
async with streamablehttp_client("http://localhost:9000/mcp") as (r, w, _):
async with ClientSession(r, w) as s:
await s.initialize()
res = await s.call_tool("geoserver-agent",
{"task": "How many features are in topp:states?"})
print(res.content[0].text)Choosing the LLM backend (GEO_LLM_PROVIDER)
Provider | Value | Needs | Notes |
Host Ollama |
| host Ollama running | Default. No API key; |
Ollama Cloud |
|
| Hosted models; set |
Anthropic Claude |
|
| Uses |
The model is read from OLLAMA_LLM_MODEL (falls back to OLLAMA_MODEL).
Put your per-machine config in .env.local (loaded by the Makefile and
gitignored), e.g. OLLAMA_LLM_MODEL=llama3.2:3b.
6. Install (local dev, no Docker)
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,webui]"
cp .env.example .env.local # then edit
uvicorn webui.app:app --reload --port 8000 # run the UI locally7. Configuration (environment variables)
Variable | Default | Meaning |
| β (required) | Server-side GeoServer base URL (e.g. |
| = | Browser-facing URL (used by generated standalone maps) |
| β (required) | REST credentials |
| (none) | Workspace used when a tool omits one |
|
| SRS used when publishing without one |
|
| HTTP timeout, retry attempts, linear backoff |
|
| Verify TLS certificates |
|
| Where generated maps / downloaded PNGs are saved |
|
| Port for the web UI |
|
|
|
|
| Ollama endpoint (containers use |
|
| Ollama model (tool-calling capable / cloud model id) |
|
| Ollama Cloud endpoint / key |
| (none) / | Anthropic key / model |
|
| MCP transport + bind |
|
| Allow destructive tools ( |
Data-bootstrap (GEO_INIT_*, GEO_STYLES_CONFIG, GEO_UPLOAD_*) and image
(POSTGIS_IMAGE, GEOSERVER_IMAGE, GEOSERVER_DATA_DIR) knobs are documented in
Β§3 and Β§1. Secrets are never hardcoded β everything is read from the environment.
8. Tests
pytest # unit + behavioural (no GeoServer)
GEO_RUN_INTEGRATION=1 pytest tests/integration # live round-trip vs real GeoServertest_formatting,test_styles_helpers,test_ogc_helpers,test_map_templateβ pure helpers / template rendering.test_tools_behaviourβ every tool driven with aFakeClient, asserting on request bodies / params / WFS-T XML (no network).test_catalogβ WMS-capabilities parsing + LLM-selection validation.test_stylingβ config-driven SLD generation + name-based style assignment.tests/integration/test_live.pyβ skipped unlessGEO_RUN_INTEGRATION=1.tests/evals/geo_eval.xmlβ read-only eval questions against sample data.
9. CI/CD β published images (GHCR)
.github/workflows/docker-publish.yml runs on push to main and on v* tags:
it runs the test suite, then builds and pushes multi-arch (amd64 + arm64)
images to the GitHub Container Registry:
Image | Stage | Contents |
|
| app image (web UI + MCP agent) |
|
| adds GDAL ( |
Agent tools (33 geo_* functions)
These are the tools the agent calls internally (they are not exposed
individually over MCP β the agent is). make tools lists them.
Tool | Kind | Description |
| read | Version + connectivity ( |
| read | List workspaces |
| read | Get one workspace |
| write | Create workspace (optionally default) |
| destructive | Delete workspace ( |
| read | List datastores in a workspace |
| read | Get one datastore |
| write | Create a PostGIS datastore |
| destructive | Delete datastore ( |
| read | List coverage (raster) stores |
| read | Get a published coverage (bbox / SRS) |
| write | Register a GeoTIFF as an external coverage store + publish it |
| destructive | Delete coverage store ( |
| read | Terrain metrics (quota/slope/aspect/curvature) for a vector layer, sampled from a DTM coverage |
| read | List feature types (or available tables) |
| write | Publish a table as a layer (recalculates bbox) |
| read | List layers |
| read | Get one layer |
| read | Layer bounding boxes + SRS |
| idempotent | Set default style / enabled flag |
| destructive | Delete layer (+ feature type cleanup) |
| read | List styles |
| read | Get style SLD |
| write | Create style from SLD string/file |
| idempotent | Replace style SLD |
| idempotent | Assign style to layer (default/extra) |
| destructive | Delete style ( |
| read | WMS GetCapabilities |
| read | Build WMS GetMap URL (optionally download PNG) |
| read | WFS GetCapabilities |
| read | WFS GetFeature β GeoJSON (bbox or CQL) |
| write | WFS-T delete / update / raw |
| read | Generate a Leaflet HTML map (OSM + WMS overlays) |
Destructive-operation safety
A Microsoft Agent Framework function middleware (middleware.py,
DestructiveGuard) intercepts destructive tools (geo_delete_* and
geo_wfs_transaction). Unless GEO_ALLOW_DESTRUCTIVE=true, the call is
short-circuited and the agent reports a refusal instead of mutating data β a
deterministic guard that works even though the MCP server is non-interactive.
Resilience
Retry with linear backoff on connect errors, timeouts, and HTTP 502/503/504 (
GEOSERVER_RETRIES,GEOSERVER_RETRY_BACKOFF); the WMS proxy also retries on429.Actionable errors: 401/403/404/405/409/500 translated into messages with a suggested fix.
OGC exceptions:
ServiceExceptionReport(HTTP 200) detected and raised.Logging on the
mcp_geo_serverlogger (GEO_LOG_LEVEL=DEBUG).
Project layout
src/mcp_geo_server/
config.py settings from env (incl. public URL, providers)
client.py async GeoServer HTTP client (auth, retry, OGC helpers)
agent.py Microsoft Agent Framework agent (pluggable LLM)
server.py MCP server (stdio / streamable-HTTP)
tools/ the geo_* tool functions
ingest.py shared shapefile -> PostGIS -> publish core
bootstrap.py batch loader over ./data (compose service geo-init)
catalog.py domain-agnostic catalog (WMS caps) + NL-selection validation
styling.py config-driven SLD engine + name-based assignment
styles_default.yml default (ISPRA) style config
webui/
app.py FastAPI backend (chat /api/ask, /api/upload, /wms proxy, β¦)
static/ chat+map UI (index.html) + upload page (upload.html)
data/ your shapefiles + optional styles.yml (gitignored)
tests/ unit, behavioural, catalog, styling, integration, evals
Dockerfile multi-stage: base (app) + bootstrap (adds GDAL/psql)
docker-compose.yml postgis + geoserver + geo-init + webui + mcp
.github/workflows/ docker-publish.yml β build & push multi-arch images to GHCRMaintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/agent-engineering-studio/mcp-geo-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server