elfa_query
Query ELFA sentiment and trending token data via API calls to support crypto market analysis with technical indicators.
Instructions
Generic ELFA proxy. Call any ELFA path with method/query/body. Returns JSON.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ELFA path like /v2/... | |
| method | No | HTTP method | |
| query | No | Query params map | |
| body | No | JSON body for non-GET |
Implementation Reference
- mcp-server.js:170-182 (handler)The primary handler function for the 'elfa_query' tool. It validates the input path, constructs the request options, calls the elfaFetch helper to perform the HTTP request to the ELFA API, handles progress notifications, and returns the response or error."elfa_query": async (args, meta) => { const path = args && args.path; if (!path || typeof path !== "string") return { content: textContent({ error:true, message:"Missing required 'path' (string)" }), isError:true }; const method = (args.method || "GET").toUpperCase(); const query = args.query || undefined; const body = args.body || undefined; progressNotify(meta && meta.progressToken, 1, 3, "Calling ELFA"); const { ok, status, data } = await elfaFetch(path, { method, query, body }); progressNotify(meta && meta.progressToken, 2, 3, "Formatting result"); if (!ok) return { content: textContent({ error:true, status, data }), isError:true, _meta:{ status } }; progressNotify(meta && meta.progressToken, 3, 3, "Done"); return { content: textContent({ ok:true, status, data }) }; },
- mcp-server.js:286-295 (registration)The tool registration entry in the 'tools' array, which defines the name, description, input schema, and annotations for the 'elfa_query' tool. This is returned by the tools/list method.{ name:"elfa_query", description:"Generic ELFA proxy. Call any ELFA path with method/query/body. Returns JSON.", inputSchema:{ type:"object", properties:{ path:{type:"string", description:"ELFA path like /v2/..."}, method:{type:"string", description:"HTTP method"}, query:{type:"object", description:"Query params map"}, body:{type:"object", description:"JSON body for non-GET"} }, required:["path"] }, annotations:{ title:"ELFA: Generic Query", readOnlyHint:true, openWorldHint:true } },
- mcp-server.js:288-293 (schema)The input schema definition for the 'elfa_query' tool, specifying the expected parameters: path (required string), method (string), query (object), body (object).inputSchema:{ type:"object", properties:{ path:{type:"string", description:"ELFA path like /v2/..."}, method:{type:"string", description:"HTTP method"}, query:{type:"object", description:"Query params map"}, body:{type:"object", description:"JSON body for non-GET"} }, required:["path"] },
- mcp-server.js:98-120 (helper)Core helper function that executes the fetch request to the ELFA API base URL, applies authentication headers, handles query parameters and body serialization, parses JSON response, and returns structured result with ok/status/data.async function elfaFetch(pathname, options){ const o = options || {}; const method = (o.method || "GET").toUpperCase(); const query = o.query || null; const body = o.body || null; const url = new URL(pathname, ELFA_BASE); if (query && typeof query === "object") { for (const k of Object.keys(query)) { const v = query[k]; if (v !== undefined && v !== null) url.searchParams.set(k, String(v)); } } const headers = { "Accept": "application/json" }; applyAuth(headers); if (body && method !== "GET") headers["Content-Type"] = "application/json"; const res = await fetch(url, { method, headers, body: body && method !== "GET" ? JSON.stringify(body) : undefined }); const raw = await res.text(); let data; try { data = raw ? JSON.parse(raw) : null; } catch { data = { raw }; } return { ok: res.ok, status: res.status, data }; }
- mcp-server.js:89-95 (helper)Helper function to apply ELFA authentication to request headers, using configurable header name and scheme.function applyAuth(headers){ const h = ELFA_AUTH || {}; if (!h.key) return headers; const name = (h.headerName || "x-elfa-api-key"); headers[name] = h.scheme ? `${h.scheme} ${h.key}` : h.key; // empty scheme for ELFA return headers; }