map-mcp
Enables AI agents to perceive and control a live MapLibre GL map over MCP, allowing querying rendered features, reading popups, navigating, and toggling layers.
README
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.

A LangChain agent finds the most-populous visible city and navigates to it — perceiving and driving the live map through map-mcp.
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 sample app in examples/sample_app/.
Example: a LangChain agent
examples/langchain_agent.py is a real agent — a langgraph
ReAct agent on any tool-capable model — that drives the live map through map-mcp's operations
(it's how the GIF above was made). Give it the map-mcp tools and a task, and it perceives and
navigates the map itself:
export OPENROUTER_API_KEY=sk-or-...
uvx playwright install chromium # one-time, for the live browser
uv run --extra demo python examples/langchain_agent.py
It defaults to an OpenRouter model (set OPENROUTER_MODEL to change). The agent's tools are
thin wrappers over the same CoreOps the MCP server exposes — so anything the agent does, the
CLI does too.
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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。