cerca_articoli
Search Solematica's Italian solar blog by category or keyword to retrieve article titles, dates, categories and descriptions. No API key required.
Instructions
Cerca articoli nel blog di Solematica per categoria o keyword. Restituisce titolo, slug, categoria, data e meta description. Non richiede API key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| categoria | No | Filtro per categoria (es. 'fotovoltaico', 'incentivi', 'risparmio') | |
| limit | No | Numero massimo di risultati (default 10, max 50) |
Implementation Reference
- index.js:150-164 (handler)The handler implementation for 'cerca_articoli' tool. Builds URL query parameters from arguments (categoria, limit), calls the /blog API endpoint, maps the response to a simplified article format with titolo, slug, categoria, data, descrizione, and url fields, and returns formatted JSON.
case "cerca_articoli": { const params = new URLSearchParams(); if (args.categoria) params.set("categoria", args.categoria); params.set("limit", String(Math.min(args.limit || 10, 50))); const data = await apiFetch(`/blog?${params.toString()}`); const articles = (data.articles || []).map((a) => ({ titolo: a.titolo, slug: a.slug, categoria: a.categoria, data: a.pubblicato_at?.slice(0, 10), descrizione: a.meta_description, url: `https://www.solematica.it/blog/${a.slug}`, })); return JSON.stringify({ totale: data.total, articoli: articles }, null, 2); } - index.js:87-98 (schema)The input schema definition for 'cerca_articoli' tool. Defines the tool's metadata including name, description (search blog articles by category or keyword), and inputSchema with optional 'categoria' (string filter) and 'limit' (number, default 10, max 50) parameters.
{ name: "cerca_articoli", description: "Cerca articoli nel blog di Solematica per categoria o keyword. Restituisce titolo, slug, categoria, data e meta description. Non richiede API key.", inputSchema: { type: "object", properties: { categoria: { type: "string", description: "Filtro per categoria (es. 'fotovoltaico', 'incentivi', 'risparmio')" }, limit: { type: "number", description: "Numero massimo di risultati (default 10, max 50)" }, }, }, }, - index.js:177-179 (registration)Registration of all tools with the MCP server via ListToolsRequestSchema handler. Returns the TOOLS array containing all tool definitions including 'cerca_articoli'.
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS, })); - index.js:13-22 (helper)Helper function 'apiFetch' used by the cerca_articoli handler to make authenticated HTTP requests to the Solematica API. Handles authorization headers, JSON parsing, and error handling.
async function apiFetch(path, options = {}) { const headers = { "Content-Type": "application/json" }; if (API_KEY) headers["Authorization"] = `Bearer ${API_KEY}`; const res = await fetch(`${API_BASE}${path}`, { ...options, headers }); if (!res.ok) { const err = await res.text().catch(() => ""); throw new Error(`API ${res.status}: ${err.slice(0, 200)}`); } return res.json(); }