@opendata.cat/mcp-server 0.0.12 → 0.0.13
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 +18 -0
- package/dist/index.js +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,24 @@ Usuari → LLM → MCP opendata.cat → API opendata.cat (cataleg)
|
|
|
193
193
|
|
|
194
194
|
No emmagatzema ni fa de proxy de dades. Cada consulta va directament a la font oficial.
|
|
195
195
|
|
|
196
|
+
## API REST
|
|
197
|
+
|
|
198
|
+
A mes del servidor MCP, opendata.cat ofereix una API REST publica per accedir al cataleg de datasets:
|
|
199
|
+
|
|
200
|
+
| Endpoint | Descripcio |
|
|
201
|
+
|----------|-----------|
|
|
202
|
+
| `GET /api/datasets.php?q=...` | Cerca datasets per text lliure |
|
|
203
|
+
| `GET /api/dataset.php?id=...` | Detall complet d'un dataset |
|
|
204
|
+
| `GET /api/categories.php` | Categories i portals amb comptadors |
|
|
205
|
+
| `GET /api/portals.php` | Portals de transparencia (1.769) |
|
|
206
|
+
| `GET /api/stats.php` | Estadistiques agregades |
|
|
207
|
+
| `GET /api/mcp-stats.php` | Metriques d'us del MCP |
|
|
208
|
+
| `POST /api/mcp` | Servidor MCP (Streamable HTTP) |
|
|
209
|
+
|
|
210
|
+
Documentacio interactiva (Swagger): **[opendata.cat/api/docs.html](https://opendata.cat/api/docs.html)**
|
|
211
|
+
|
|
212
|
+
Especificacio OpenAPI: [`opendata.cat/api/openapi.json`](https://opendata.cat/api/openapi.json)
|
|
213
|
+
|
|
196
214
|
## Sobre opendata.cat
|
|
197
215
|
|
|
198
216
|
[opendata.cat](https://opendata.cat) es una associacio catalana sense anim de lucre fundada el 2012 (registre 47468) dedicada a promoure la transparencia i l'acces a la informacio publica. Treballa en tres eixos: **estandarditzacio** de formats i protocols, **formacio** especialitzada per a professionals i administracions, i **collaboracio** publico-privada per a l'obertura de dades.
|
package/dist/index.js
CHANGED
|
@@ -92,6 +92,26 @@ server.tool("query_dataset", "Executa una consulta contra un dataset i retorna f
|
|
|
92
92
|
}
|
|
93
93
|
else if (dataset.api_type === "opendatasoft") {
|
|
94
94
|
const data = await queryOpendatasoft(dataset.api_endpoint, filters, search, limit, offset);
|
|
95
|
+
// Detect GTFS-RT protobuf files
|
|
96
|
+
const first = data.records[0];
|
|
97
|
+
const fileField = first?.file;
|
|
98
|
+
if (fileField?.filename?.endsWith(".pb") || fileField?.filename?.endsWith(".pbf")) {
|
|
99
|
+
const dsMatch = dataset.api_endpoint.match(/dataset=([^&]+)/);
|
|
100
|
+
const baseMatch = dataset.api_endpoint.match(/(https?:\/\/[^/]+)/);
|
|
101
|
+
const infoUrl = baseMatch ? `${baseMatch[1]}/explore/dataset/${dsMatch?.[1] ?? ""}/information/` : dataset.api_endpoint;
|
|
102
|
+
return {
|
|
103
|
+
content: [{
|
|
104
|
+
type: "text",
|
|
105
|
+
text: JSON.stringify({
|
|
106
|
+
dataset: dataset.name,
|
|
107
|
+
format: "Protocol Buffers (GTFS-RT)",
|
|
108
|
+
message: "Aquest dataset conté dades en format Protocol Buffers (.pb), un format binari per a transport públic en temps real (GTFS Realtime). No es pot llegir directament com a text/JSON. Per usar-lo cal un decoder GTFS-RT (ex: gtfs-realtime-bindings).",
|
|
109
|
+
filename: fileField.filename,
|
|
110
|
+
download_url: infoUrl,
|
|
111
|
+
}, null, 2),
|
|
112
|
+
}],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
95
115
|
results = data.records;
|
|
96
116
|
}
|
|
97
117
|
else {
|