elfa_reload_env
Reload environment configuration files to update settings for crypto market analysis tools that combine sentiment data with technical indicators.
Instructions
Reload .env files from common locations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp-server.js:144-156 (handler)Handler function that reloads environment variables using loadEnvMulti, rebuilds authentication and base URL from env vars, and returns the current configuration status."elfa_reload_env": async () => { loadEnvMulti(); ELFA_AUTH = buildAuthFromEnv(); ELFA_BASE = (process.env.ELFA_BASE || ELFA_BASE).replace(/\/+$/,""); return { content: textContent({ ok: true, base: ELFA_BASE, loaded: ENV_INFO.loaded, from: ENV_INFO.from, vars: ENV_INFO.vars, auth: { headerName: ELFA_AUTH.headerName || "", scheme: ELFA_AUTH.scheme || "", key: maskKey(ELFA_AUTH.key) } }) }; },
- mcp-server.js:276-280 (registration)Tool registration entry in the tools array, providing name, description, empty input schema (no parameters), and annotations.{ name:"elfa_reload_env", description:"Reload .env files from common locations.", inputSchema:{ type:"object", properties:{} }, annotations:{ title:"ELFA: Reload .env", readOnlyHint:false, openWorldHint:false } },
- mcp-server.js:32-58 (helper)Key helper function called by the handler to load .env files from multiple possible locations (cwd, __dirname, parent dirs), updates ENV_INFO, and logs the result.function loadEnvMulti() { ENV_INFO = { loaded: false, from: [], vars: [] }; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const candidates = [ path.join(process.cwd(), ".env"), path.join(__dirname, ".env"), path.join(path.dirname(__dirname), ".env"), // one level up path.join(path.dirname(path.dirname(__dirname)), ".env") // two up ]; const seen = new Set(); for (let i = 0; i < candidates.length; i++) { const p = candidates[i]; if (seen.has(p)) continue; seen.add(p); if (fs.existsSync(p)) { dotenv.config({ path: p, override: false }); ENV_INFO.loaded = true; ENV_INFO.from.push(p); } } // Capture which ELFA_* we actually have const known = ["ELFA_API_KEY","ELFA_HEADER","ELFA_AUTH_TYPE","ELFA_BASE"]; for (let i = 0; i < known.length; i++) { if (process.env[known[i]] !== undefined) ENV_INFO.vars.push(known[i]); } console.info(`[dotenv] loaded=${ENV_INFO.loaded} from=${JSON.stringify(ENV_INFO.from)} vars=${JSON.stringify(ENV_INFO.vars)}`); }
- mcp-server.js:65-75 (helper)Helper function to build ELFA authentication object from environment variables, preferring x-elfa-api-key header.function buildAuthFromEnv() { const envKey = process.env.ELFA_API_KEY || ""; let header = (process.env.ELFA_HEADER || "x-elfa-api-key").toLowerCase(); // default to x-elfa-api-key if (header !== "x-elfa-api-key" && header !== "authorization") { header = "x-elfa-api-key"; } if (header === "authorization") { return { headerName: "Authorization", scheme: "Bearer", key: envKey }; } return { headerName: "x-elfa-api-key", scheme: "", key: envKey }; }