bharatlas-mcp 1.2.0 → 1.3.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/README.md CHANGED
@@ -36,7 +36,7 @@ Add to your MCP client config:
36
36
  |------|-------------|
37
37
  | **list_layers** | Discover layers by category, level, source, or text search |
38
38
  | **get_layer_schema** | Column names, types, distinct values. Call before querying. |
39
- | **query_layer** | Filter, select, group_by on any column, with per-group sums of numeric columns. Runtime parquet reads. |
39
+ | **query_layer** | Select any column; filter (exact, case-insensitive) and group_by on flat columns, with per-group sums of numeric columns. Runtime parquet reads. |
40
40
  | **locate** | Point-in-polygon: what state, district, ward, zone is this point in? |
41
41
  | **nearby** | Find features within a radius. Works for points, polygons, and lines. |
42
42
  | **get_layer_detail** | Download URLs in 5 formats (parquet, pmtiles, geojson, kml, shapefile) |
@@ -68,7 +68,7 @@ Thin wrapper over the [bharatlas REST API](https://bharatlas.com/docs). Each too
68
68
  The server sends instructions to the LLM at connection time that teach:
69
69
  - **Schema-first pattern**: check column names and sample values before querying (column names vary: `state` vs `State_LGD` vs `stname`)
70
70
  - **Source preference**: LGD for admin boundaries, with SOI/Bhuvan/geoBoundaries as alternates
71
- - **Concept-to-layer mapping**: "water bodies" = rivers + canals + reservoirs + wetlands + ramsar sites + dams; "groundwater" = aquifers + extraction stage
71
+ - **Concept-to-layer mapping**: "water bodies" = rivers + canals + reservoirs + wetlands + ramsar sites + dams; "groundwater" = aquifers + extraction stage + wells (minor irrigation census); "places/shops/ATMs" = Overture places
72
72
  - **Spatial join workflow**: locate for context, query for data, nearby for proximity
73
73
 
74
74
  ## Links
package/index.js CHANGED
@@ -27,7 +27,7 @@ Workflow patterns:
27
27
 
28
28
  - **Discovery**: start with list_layers or list_categories to find relevant layers. Use the q parameter for text search.
29
29
  - **Schema first**: always call get_layer_schema BEFORE query_layer. Column names vary per layer (e.g. "state" vs "State_LGD" vs "stname"). The schema shows exact names and sample values.
30
- - **Filtering**: query_layer where conditions are case-insensitive. Pass column=value pairs. Check the schema for the right column name and value format.
30
+ - **Filtering**: query_layer where is an exact, case-insensitive match (no partial or substring match). Pass column=value pairs; check the schema for the right column name and value format. Columns the schema marks as type "nested" (structs, lists, maps, e.g. Overture names/addresses) can be selected but not used in where or group_by (the API returns 400 listing the flat columns).
31
31
  - **Counting**: use group_by to count features by any column. Example: group_by "category" on the gs_wildlife layer returns national parks vs sanctuaries.
32
32
  - **Totals**: add sum (numeric columns) to group_by to total values per group, e.g. group_by "district" + sum ["area_ha"] rolls block-level areas up to districts. Percentages are not additive: sum the underlying amounts and recompute shares.
33
33
  - **Location queries**: locate returns all admin boundaries + zones at a lat/lng, and (for the ~30 covered cities) auto-includes the municipal ward layer that contains the point — so "what ward is this?" just works with lat/lng alone. Use it to answer "what state/district/ward is this point in?"
@@ -36,7 +36,8 @@ Workflow patterns:
36
36
  2. Use query_layer with a where filter to narrow the other layer by that admin context
37
37
  3. For precise spatial containment, test individual points via locate against the target layer
38
38
  - **Community layers**: list_submissions returns user-contributed datasets. These work with query_layer and get_layer_schema exactly like curated layers.
39
- - **Downloads**: get_layer_detail returns direct URLs for parquet, pmtiles, geojson, kml, and shapefile formats.
39
+ - **Downloads**: get_layer_detail returns direct URLs for the formats a layer has (parquet and pmtiles always; geojson, kml and shapefile for most).
40
+ - **Large layers**: overture_places_india has 4.4M places. Always narrow it: where on basic_category (e.g. "hospital", "restaurant") or name, group_by, or nearby for places around a point. Whole-table filters and group_by take several seconds; nearby is the fast path for "near me".
40
41
  - **Honor the terms**: every layer and community submission carries its own source and open licence. When you use, quote, or publish results from a layer, credit its source and respect that licence; get_layer_detail returns the attribution and licence, and each /view page's Dataset JSON-LD carries a creditText to reproduce.
41
42
 
42
43
  Source preference (multiple layers often cover the same level):
@@ -56,14 +57,17 @@ Cross-layer queries (combining data from different layers):
56
57
  - Use locate as the bridge: find what's at a point across ALL relevant layers in one call by passing multiple layer IDs.
57
58
  - **Map user concepts to multiple layers.** Users say "water bodies" not "wris_rivers." Translate:
58
59
  - "water bodies/water" → wris_rivers, wris_reservoirs, bp_wetlands, bp_ramsar, wris_basin, wris_subbasin, wris_canals
59
- - "groundwater/aquifer/water table" → cgwb_aquifers, cgwb_gw_extraction
60
+ - "groundwater/aquifer/water table" → cgwb_aquifers, cgwb_gw_extraction, mi6_wells_districts
61
+ - "wells/borewells/tubewells/irrigation pumps" → mi6_wells_districts (census counts per district, 2017-18)
60
62
  - "forests/green cover/ecology" → soi_forests, gs_wildlife, bm_eco_zones, biogeographic_zones
61
- - "agriculture/farming/cropping zones" → agro_ecological_zones, agro_climatic_zones
63
+ - "agriculture/farming/cropping zones" → agro_ecological_zones, agro_climatic_zones, corestack_lulc_blocks (land use and cropping intensity by block, modelled)
64
+ - "places/POIs/shops/restaurants/ATMs/schools/hospitals by name" → overture_places_india (filter on name or basic_category; 4.4M rows, always add a where or group_by, or use nearby)
62
65
  - "hazards/risks" → seismic_zones, india_flood_inventory
63
66
  - "health/medical" → nic_health
64
67
  - "boundaries/admin" → lgd_states, lgd_districts, lgd_subdistricts, lgd_blocks, lgd_villages
65
68
  - "roads/transport" → gs_highways, airports
66
69
  When unsure, use list_layers with a broad q search and list_categories to discover what's available. Combine ALL relevant layers, not just the first match.
70
+ - **Sky and air over a place**: once you have a coordinate (from locate, nearby or a layer row), the mugilu MCP (mugilu.live/mcp, tool conditions_at) gives the live air quality, heat, fog and warnings there. bharatlas answers where; mugilu answers what the sky is doing.
67
71
 
68
72
  Column naming conventions (vary by source):
69
73
  - State: State_LGD (number), STNAME, stname, state, state_name
@@ -154,7 +158,7 @@ const TOOLS = [
154
158
  where: {
155
159
  type: "object",
156
160
  additionalProperties: { type: "string" },
157
- description: "Filter conditions as {column: value} pairs. Case-insensitive matching.",
161
+ description: "Filter conditions as {column: value} pairs. Exact, case-insensitive match on flat columns (not partial). Values may contain commas.",
158
162
  },
159
163
  group_by: {
160
164
  type: "string",
@@ -205,9 +209,9 @@ const TOOLS = [
205
209
  {
206
210
  name: "nearby",
207
211
  description:
208
- "Find features from a layer that are near a given point. Samples a grid of points around the " +
209
- "center and checks which hit the target layer via locate. Generic: works for any layer type " +
210
- "(polygons, points, lines) without needing coordinate columns. " +
212
+ "Find features from a layer that are near a given point, nearest first, within radius_km. " +
213
+ "Reads the layer's parquet bounding boxes and ranks features by distance to their centres; " +
214
+ "works for points, polygons and lines. Returns the true count within the radius plus the nearest `limit`. " +
211
215
  "Example: 'reservoirs near Bengaluru' -> layer_id: 'wris_reservoirs', lat: 12.97, lng: 77.59, radius_km: 50.",
212
216
  inputSchema: {
213
217
  type: "object",
@@ -398,6 +402,10 @@ function httpGet(url) {
398
402
  });
399
403
  }
400
404
 
405
+ // Mirrors RESERVED in web/functions/lib/query-params.ts: these names are query
406
+ // options, so a where column with one of them must go inside where=.
407
+ const QUERY_RESERVED = new Set(["select", "group_by", "sum", "limit", "where", "order_by", "include_centroid"]);
408
+
401
409
  async function callApi(path, params = {}) {
402
410
  const url = new URL(API + path);
403
411
  for (const [k, v] of Object.entries(params)) {
@@ -497,8 +505,16 @@ async function handleTool(name, args) {
497
505
  if (group_by) params.group_by = group_by;
498
506
  if (sum?.length) params.sum = sum.join(",");
499
507
  if (limit) params.limit = limit;
500
- if (include_centroid) params.include_centroid = "true";
501
- if (where) params.where = Object.entries(where).map(([k, v]) => `${k}=${v}`).join(",");
508
+ if (include_centroid !== undefined) params.include_centroid = String(include_centroid);
509
+ // Each filter as its own ?col=val param so values may contain commas (the
510
+ // API splits a where= string on commas). Columns named like a reserved
511
+ // param must still travel inside where=.
512
+ const reservedWhere = [];
513
+ for (const [k, v] of Object.entries(where || {})) {
514
+ if (QUERY_RESERVED.has(k)) reservedWhere.push(`${k}=${v}`);
515
+ else params[k] = v;
516
+ }
517
+ if (reservedWhere.length) params.where = reservedWhere.join(",");
502
518
  return callApi(`/layers/${layer_id}/query`, params);
503
519
  }
504
520
 
@@ -608,7 +624,7 @@ async function handleTool(name, args) {
608
624
  }
609
625
 
610
626
  const server = new Server(
611
- { name: "bharatlas-mcp", version: "1.2.0" },
627
+ { name: "bharatlas-mcp", version: "1.3.0" },
612
628
  { capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS },
613
629
  );
614
630
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bharatlas-mcp",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "MCP server for India's open geo data. Query layers, locate points, find nearby features, filter and group data. Also authors collect maps: register a share link, moderate contributions, and publish to the catalog.",
5
5
  "keywords": ["mcp", "india", "geo", "geospatial", "gis", "boundaries", "parquet", "pmtiles", "llm", "claude", "bharatlas", "collect"],
6
6
  "repository": { "type": "git", "url": "git+https://github.com/urbanmorph/geodata.git", "directory": "mcp" },
package/server.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.sathya-sankaran/bharatlas-mcp",
4
4
  "description": "Query India's open geo data, and author collect maps: register a link, moderate, publish.",
5
- "version": "1.2.0",
5
+ "version": "1.3.0",
6
6
  "packages": [
7
7
  {
8
8
  "registryType": "npm",
9
9
  "identifier": "bharatlas-mcp",
10
- "version": "1.2.0",
10
+ "version": "1.3.0",
11
11
  "transport": { "type": "stdio" }
12
12
  }
13
13
  ]