Drive and perceive an existing live MapLibre GL map from an AI agent (MCP) or a human CLI — no test code, no browser automation.
Project description
map-mcp
Drive and perceive an existing, live MapLibre GL map from an AI agent (over MCP) or a human CLI — query the rendered features, read the viewport, click and read popups, navigate, toggle layers. The agent and the CLI act on the same map a person is looking at, with parity by construction.
It does not generate maps. Other geo-MCP servers (gis-mcp, Mapbox, CARTO) create maps or call GIS operations; map-mcp reaches into a map that's already on screen. Think of it as the agent-native counterpart to MapGrab: same live-map access, but conversational over MCP instead of written as test code.
Status: v1, MapLibre GL only. Cooperation-required (your app adds a one-line hook). A no-cooperation path and other map libraries are future work.
Install
uvx map-mcp --help # or: pip install map-mcp
Quickstart
- Start the bridge + MCP server. It prints a WebSocket URL and a per-session token.
map-mcp serve - Add the hook to your MapLibre page (
mapis your existingmaplibregl.Map):<script src="map-mcp-hook.js"></script> <script> mapMcp.register(map, { url: "ws://127.0.0.1:8765", token: "PASTE_TOKEN" }); </script>
- Point your agent at the MCP server (stdio by default;
--transport httpfor HTTP/SSE). Or drive it yourself from the terminal:map-mcp call get_viewport map-mcp call query_rendered_features --params '{"point":[12.5,41.9]}'
There's a runnable example in examples/sample_app/.
Tools (the operation surface)
The agent's MCP tools and the CLI's call operations are exactly the same set:
| Operation | What it does |
|---|---|
get_viewport |
center [lng,lat], zoom, bearing, pitch, bounds |
query_rendered_features |
features currently rendered (optionally at a point or within a bbox) |
get_features_at |
features rendered at a [lng,lat] point |
click_at |
fire the map's click at a point (runs your popup handlers), return features + popup |
read_popup |
text of any open popup(s) |
set_view |
center+zoom (and bearing/pitch), or fit a bbox |
list_layers |
the style's layers + visibility |
set_layer_visibility |
show/hide a layer |
screenshot |
a PNG data URL of the current map* |
Perception returns structured feature properties (GeoJSON-shaped) — agents reason over
properties, not pixels. screenshot is optional.
* needs the map created with preserveDrawingBuffer: true (see hook/snippet.md).
How it works
The hook connects out to a loopback WebSocket the map-mcp process runs. The MCP tools and
the CLI are thin frontends over one shared core-operations layer, so any operation one can do,
the other can too.
Security model (local-only). The bridge binds 127.0.0.1 only, so nothing off your machine
can reach it. Browsers do not apply same-origin policy to WebSocket connections, so the
per-session token is the security boundary: only a page that presents it can drive your map.
Treat the token like a secret — the convenience ?token= pattern in the example leaks it via
browser history and server logs, so for anything sensitive paste the token into the page rather
than the URL. A hardened Origin allowlist is future work.
Scope (v1)
- In: MapLibre GL; the operations above; stdio + HTTP/SSE; a human CLI with parity.
- Out: generating maps; a hosted service; non-map visualizations; other map libraries (Leaflet/deck.gl) and a no-cooperation (Playwright) path are future work.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file map_mcp-0.1.0.tar.gz.
File metadata
- Download URL: map_mcp-0.1.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b8b5ec096a9b0fdd96db1c594ad44624f6239b414e352c473b2510d5ba43fe
|
|
| MD5 |
00244f95d1df23a84a74602ca51e623b
|
|
| BLAKE2b-256 |
ec92a92e5043102f41016537170c4619d206ab0e6115434966e0413827c0fb9d
|
File details
Details for the file map_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: map_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd2b3a67dd76c590481516e5c34b44a6311d4044180d6d5612d91ed2a56da20c
|
|
| MD5 |
b27cdbf9d89fb74a15ed6aa88914ba84
|
|
| BLAKE2b-256 |
d298a72c9332eb79d203cab52c76d31eda157fdfd19021a78d3eb8c5ef5f769c
|