mapicgc-gl-js 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.1.0
2
+
3
+ ### Added
4
+
5
+ - Add an MCP stdio server with tools for the library documentation, API reference, examples, styles and changelog.
6
+
1
7
  ## 1.0.0
2
8
 
3
9
  ### ✨ Features and improvements
package/README.md CHANGED
@@ -22,7 +22,7 @@ The MapICGC GL JS library builds upon the open-source library [**MapLibre GL JS
22
22
 
23
23
  Our goal is to simplify the development process for MapICGC developers! With MapICGC GL JS, you won't need to load external plugins for basic functionalities, deal with complex data source URLs, or search for syntax to enable 3D terrain every time you embark on a project. All these features are either built-in, loaded dynamically when necessary, or accessible through straightforward functions.
24
24
 
25
- Moreover, MapICGC GL JS provides well-documented and user-friendly wrapper functions for MapICGC Cloud API services, including geocoding, static maps, geolocation, and a coordinate reference system search engine for transforming coordinates between different CRSs.
25
+ Moreover, MapICGC GL JS provides well-documented and user-friendly wrapper functions for MapICGC Cloud API services, including geocoding, geolocation, exporting the current map view to an image or PDF, and territorial lookup by clicking on the map.
26
26
 
27
27
 
28
28
 
@@ -142,6 +142,146 @@ or directly with Vitest:
142
142
  npx vitest run
143
143
  ```
144
144
 
145
+ ---
146
+
147
+ ## MCP Server
148
+
149
+ This package also ships an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/)
150
+ server that teaches AI assistants (opencode, Claude, Cursor, GitHub Copilot...)
151
+ how to correctly use this library: install snippets, API reference, code
152
+ examples, available styles/layers and the changelog, served as MCP tools.
153
+
154
+ > The MCP server only serves documentation/data about this library; it does
155
+ > not run or render any map itself.
156
+
157
+ ### Quick start
158
+
159
+ - **Already added `mapicgc-gl-js` to your project?** The MCP server ships
160
+ bundled inside the same package — nothing extra to install:
161
+ ```bash
162
+ npx mapicgc-mcp
163
+ ```
164
+ (npx finds the `mapicgc-mcp` bin in your project's own `node_modules/.bin`.)
165
+
166
+ - **Haven't installed it yet, or just want an AI assistant to use it?**
167
+ No manual install needed either — point your MCP client at:
168
+ ```bash
169
+ npx -y -p mapicgc-gl-js mapicgc-mcp
170
+ ```
171
+ See [Client configuration](#client-configuration) below for ready-to-paste
172
+ configs (opencode, Claude Desktop, VS Code, Cursor).
173
+
174
+ ### Running it
175
+
176
+ The server's `bin` name (`mapicgc-mcp`) is different from the package name
177
+ (`mapicgc-gl-js`), so `npx` needs the `-p` flag to know what to install:
178
+
179
+ ```bash
180
+ npx -y -p mapicgc-gl-js mapicgc-mcp
181
+ ```
182
+
183
+ This runs the server in stdio mode, the mode expected by MCP clients below.
184
+
185
+ ### Client configuration
186
+
187
+ **opencode** (`opencode.json`):
188
+
189
+ ```json
190
+ {
191
+ "$schema": "https://opencode.ai/config.json",
192
+ "mcp": {
193
+ "mapicgc": {
194
+ "type": "local",
195
+ "command": ["npx", "-y", "-p", "mapicgc-gl-js", "mapicgc-mcp"],
196
+ "enabled": true
197
+ }
198
+ }
199
+ }
200
+ ```
201
+
202
+ **Claude Desktop** (`claude_desktop_config.json`) / **Claude Code**:
203
+
204
+ ```json
205
+ {
206
+ "mcpServers": {
207
+ "mapicgc": {
208
+ "command": "npx",
209
+ "args": ["-y", "-p", "mapicgc-gl-js", "mapicgc-mcp"]
210
+ }
211
+ }
212
+ }
213
+ ```
214
+
215
+ **VS Code (GitHub Copilot)** (`.vscode/mcp.json`):
216
+
217
+ ```json
218
+ {
219
+ "servers": {
220
+ "mapicgc": {
221
+ "type": "stdio",
222
+ "command": "npx",
223
+ "args": ["-y", "-p", "mapicgc-gl-js", "mapicgc-mcp"]
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ **Cursor** uses the same `command`/`args` shape as Claude Desktop.
230
+
231
+ ### How it works
232
+
233
+ You don't install or run anything yourself — you just paste one of the
234
+ configs above into your MCP client's config file. From there, the client
235
+ takes care of everything:
236
+
237
+ 1. It reads the `command`/`args` and launches it as a subprocess, exactly as
238
+ if you'd typed it in a terminal.
239
+ 2. `npx` resolves `mapicgc-gl-js` (downloading it from the npm registry the
240
+ first time, if it isn't cached yet) and runs its `mapicgc-mcp` binary.
241
+ 3. The server starts in stdio mode, and the client talks to it over that
242
+ subprocess's stdin/stdout using the MCP (JSON-RPC) protocol — listing
243
+ tools, calling them, reading resources, etc.
244
+ 4. The client stops the subprocess once it no longer needs it.
245
+
246
+ Requirements: `node`/`npm` (and therefore `npx`) available on `PATH`, and
247
+ network access the first time the package is fetched (npm caches it for
248
+ later runs).
249
+
250
+ > A Streamable HTTP entry point exists in the MCP source
251
+ > (`mcp/src/http.ts`) but is **not wired into the current build** yet
252
+ > (`npm run build:mcp` only bundles the stdio entry point), so a
253
+ > `{ "type": "remote", "url": "..." }` config is not supported yet.
254
+
255
+ ### Tools
256
+
257
+ | Tool | Description |
258
+ | --- | --- |
259
+ | `get_started` | Installation (NPM and CDN) and a minimal working map example. |
260
+ | `search_docs(query, limit?)` | Keyword search across all bundled documentation. |
261
+ | `get_api(name)` | Detailed docs for a specific method/class (e.g. `Map.addMarker`). |
262
+ | `get_example(topic)` | A complete code example for a topic (3D terrain, markers, geocoder...). |
263
+ | `list_styles` | Available styles, terrains and layer groups (live, with a local fallback). |
264
+ | `get_changelog(version?)` | Full changelog, or just one version's entries. |
265
+
266
+ It also registers the `mapicgc://readme` and `mapicgc://changelog` **resources**,
267
+ and the `crear_mapa(estil, ubicacio)` **prompt**.
268
+
269
+ ### Local development
270
+
271
+ ```bash
272
+ npm install
273
+ npm run build:content # downloads this library's docs/changelog into mcp/content/
274
+ npm run build:mcp # type-checks mcp/src and bundles it into dist-mcp/index.js
275
+ node dist-mcp/index.js # runs the server in stdio mode
276
+ ```
277
+
278
+ To sanity-check the server end-to-end (connects a real MCP client over
279
+ stdio and calls every tool):
280
+
281
+ ```bash
282
+ node mcp/scripts/smoke-test.js
283
+ ```
284
+
145
285
  ---
146
286
  ## Developed by:
147
287