{"_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio","_rev":"8-4c2cc01a87d613e49021b35052d0bcd9","name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.0","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.0","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"feb3ef24eca59ce16a6f5867cb9c3323fe2d9ca2","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.0.tgz","fileCount":15,"integrity":"sha512-RYWFcnryOpgR5mZ48uO61QoOw2pt3PLJqAo53aaNwua+nEJSTJd/BiPXilfF1zs79qRrcEs9nOByftZwHWUW1Q==","signatures":[{"sig":"MEUCIQCtHnJEShLJKO/mMAHEqtMvbBRG5wsNI5OBjR0llLKrpwIgMKT+slsUNVE2ja6sVIc28wXqZJOSIb2XnSlV3bO8ibA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14374},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.0_1760111879462_0.7692049383349169","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.1","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.1","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"55606dd80f6281116ef87da3d996f4692bd3af6a","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.1.tgz","fileCount":15,"integrity":"sha512-H8NaEf3+ykjPST6kl5BZFibanLZ47whOQkTFkiUZNbPOdiyxgd6bsuD/jz8KIcJHsF7m53Ct7Hym6M3aRF2q/A==","signatures":[{"sig":"MEUCIQD6ecQ87W3LvSSeMjbTMwsRvEHgMxhEg4CWsoNwqTYVZQIgV2hF1pA+epCl70MObM/vp67CqIS726nI86GyUHr7les=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17683},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.1_1760114291229_0.8251729023823622","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.2","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.2","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"8ecc1faef79cee4a3b4bbeea7a710f8cdde73ba2","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.2.tgz","fileCount":15,"integrity":"sha512-2d6mZzvzGZMbJp/dHfzT79WhZI6zYdFDDVMIY9x7fh68ZueGNNOqYIP7U7MqZH/7VTodpGqKxG5F/GhUBuI5sA==","signatures":[{"sig":"MEYCIQD+gMbQZnOeMt5juqJa6Hk04sfRasaPyC5/8rHAo0oY+wIhALC+KZeXk1y/Ps2yD9ZmFWw9YsdHOOGMtUYJS2U6+NZg","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17768},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.2_1760119034770_0.20295263276129538","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.3","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.3","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"b2ae50739216d481c2f312145823927517c787fb","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.3.tgz","fileCount":15,"integrity":"sha512-4hf/mDCnRy3zr80sCa6NMWYw55g37Pjiqs0V7L7bZGKuogmmFpTs9iLvAaK9HkpIMkp8Sumr0aRCL+Te4yf28g==","signatures":[{"sig":"MEUCIQC0TL/SbDvp/yGqzr7NLqaRv+6nj06+rqgfIIKUOynRdwIgIrMiWP5qWax/eAyeqsOIXW6tLNn5byv4giJ54R5IJHs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18491},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.3_1760119408470_0.07181122716883537","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.4","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.4","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"be78e18ad4692a778b89a8d1250277afe32eea99","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.4.tgz","fileCount":17,"integrity":"sha512-yJfrK2OJdK9OTzVhhIMMI4dVAYi4YKVgUVbXzenGp0Cc0nDhnEAF8BdKHhIkOg8MhM2Ab29Ub3M0jUpnc6ul1w==","signatures":[{"sig":"MEUCIQCw4UALsabxfztA6DjkiXLMF/bgLyjd7u2RqPBzCApeZQIgHAix4Dd+yOjICJxyhBK9zhBZuWN7iHnFoe+1N64Q/0A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20331},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.4_1760121270227_0.8890959837225507","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.5","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.5","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"4668c856f0b5e8421d15493132e4e729ce562442","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.5.tgz","fileCount":17,"integrity":"sha512-gIx/vUUkWhTUS6Oue9KYzLEEQtZxWC0yCr9VKhoHJzTeN4+E8C/XRKL/cQF7135gSHPkm7fwHhrCsyUXmk6cpw==","signatures":[{"sig":"MEUCIQDx5DEQDKLLZXb2u1AnPmUizpkaWIBfZrfTwrxBecgVHQIgBQ7AwV+gZA0cyfsFbIMx2wnmISJI5c1czsc11RKCaeo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20450},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.5_1760123080932_0.4950363157897808","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.6","_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.6","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"bin":{"mcp-stock-analyzer":"dist/cli.js"},"dist":{"shasum":"018f40df8b219db0fb2fb34007aecc74219a30a5","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.6.tgz","fileCount":17,"integrity":"sha512-EO5zKDgXOpY3mzNTUln3Ruti9CgpAclSx3DgvC43EBhQEXyolE1BeW36G6HHKppnMpABfDEaCpcBoKIz6nPk9g==","signatures":[{"sig":"MEUCIGfSwtHx8zhIMCB8qa66O3q0yu7bfXd9NgpYm4XFXk4zAiEA8LkfEzKOQxrKNu5YfGYcNH+bYBuRjr7+OgdvogsiSIY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22712},"type":"module","engines":{"node":">=20"},"private":false,"scripts":{"dev":"tsc -w -p tsconfig.json","build":"tsc -p tsconfig.json","start":"node dist/cli.js"},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"_npmVersion":"11.5.1","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","directories":{},"_nodeVersion":"24.7.0","dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"_npmOperationalInternal":{"tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.6_1760124739554_0.5414292692423726","host":"s3://npm-registry-packages-npm-production"}},"1.0.7":{"name":"@bluebossa63/mcp-stock-analyzer-ts-stdio","version":"1.0.7","private":false,"type":"module","description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","bin":{"mcp-stock-analyzer":"dist/cli.js"},"scripts":{"build":"tsc -p tsconfig.json","start":"node dist/cli.js","dev":"tsc -w -p tsconfig.json"},"engines":{"node":">=20"},"dependencies":{"@modelcontextprotocol/sdk":"^1.20.0"},"devDependencies":{"typescript":"^5.6.3","@types/node":"^22.7.4"},"publishConfig":{"access":"public"},"_id":"@bluebossa63/mcp-stock-analyzer-ts-stdio@1.0.7","_nodeVersion":"24.7.0","_npmVersion":"11.5.1","dist":{"integrity":"sha512-h0OVpl+2mLihl+hNrCz/XPI2fl4lVdsRXrUB+fZ3ZCmPLjuIs/+/JFHh1ehMsXuShZdpUp4boQBoz0MdK5tifw==","shasum":"3927b38e0ba83c2bf132a2fcd5419eae7444bd5f","tarball":"https://registry.npmjs.org/@bluebossa63/mcp-stock-analyzer-ts-stdio/-/mcp-stock-analyzer-ts-stdio-1.0.7.tgz","fileCount":17,"unpackedSize":40756,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDbHBtlMiMy8p6Vx4e2S8wU+ov4mMpG8bU73zks8jRY6AIgUfP/6mCVycU69ssOMs6B/cbR4VMaS7WqzwBLMevRKQk="}]},"_npmUser":{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"},"directories":{},"maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp-stock-analyzer-ts-stdio_1.0.7_1760276933198_0.19731258717375133"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-10T15:57:59.362Z","modified":"2025-10-12T13:48:53.562Z","1.0.0":"2025-10-10T15:57:59.689Z","1.0.1":"2025-10-10T16:38:11.430Z","1.0.2":"2025-10-10T17:57:14.974Z","1.0.3":"2025-10-10T18:03:28.720Z","1.0.4":"2025-10-10T18:34:30.416Z","1.0.5":"2025-10-10T19:04:41.117Z","1.0.6":"2025-10-10T19:32:19.738Z","1.0.7":"2025-10-12T13:48:53.386Z"},"description":"MCP server (Node 20, STDIO-only) with Yahoo Finance, OpenAI-compatible sentiment, evaluation, and n8n Command Line integration.","maintainers":[{"name":"bluebossa63","email":"daniele.ulrich@niceneasy.ch"}],"readme":"# mcp-stock-analyzer-ts (STDIO)\n\nAn **MCP server** (Node 20+) that exposes stock-analysis utilities as Model Context Protocol tools.  \nDesigned to work smoothly with **n8n’s MCP Client (Command Line)** node and OpenAI-compatible LLMs.\n\n---\n\n## ✨ What’s inside (current state)\n\nPure **AI-driven** evaluation (no local math):\n- `defineSentiment` → calls your OpenAI-compatible endpoint to classify sentiment from headlines/text.\n- `evaluateWithAI` → passes **intraday time series** + **sentiment** to the model with an engineered prompt; returns **per-timeframe** decisions (and optional `overall` if requested).\n\nConvenience fetchers:\n- `fetchChart` → Yahoo Finance OHLCV (range/interval).\n- `fetchMultiIntraday` → pulls **1m**, **10m** (fallback **15m**), **60m** series.\n- `fetchNewsTitles` → Yahoo Finance RSS headlines.\n\nAI-only orchestration:\n- `getSentimentFromNews` → fetch headlines + run `defineSentiment`.\n- `evaluateScoreWithAI` → run the model on **your** provided `{intraday, sentiment}` (no fetching).\n- `pipelineEvaluateAI` → one-shot: fetch intraday + news → sentiment → model evaluation.\n\nDiagnostics:\n- `debug-env`, `debug-echo-openai`\n\n> **No local calculations** remain (e.g., SMA). All decisioning is model-driven when you call `evaluateWithAI`/`evaluateScoreWithAI` or the pipeline tool.\n\n---\n\n## 🧰 Tool reference\n\n| Tool | Purpose | Input (JSON) | Output (JSON, in `result.content[0].text`) |\n|---|---|---|---|\n| `fetchChart` | Single Yahoo series | `{ \"symbol\":\"AAPL\", \"range\":\"1mo\", \"interval\":\"1d\" }` | `{ symbol, currency?, points: [{t,c,o?,h?,l?,v?}] }` |\n| `fetchMultiIntraday` | 1m / 10m(→15m) / 60m | `{ \"symbol\":\"NVDA\" }` | `{ symbol, intraday: { \"1m\": PriceSeries, \"10m\": PriceSeries?, \"60m\": PriceSeries } }` |\n| `fetchNewsTitles` | Headlines (RSS) | `{ \"symbol\":\"NVDA\", \"max\": 10 }` | `{ symbol, titles: string[] }` |\n| `defineSentiment` | LLM sentiment | `{ \"articles\": [\"...\",\"...\"] }` | `{ sentiment: \"positive\"|\"neutral\"|\"negative\", confidence: number, reasoning?: string }` |\n| `getSentimentFromNews` | Headlines → sentiment | `{ \"symbol\":\"NVDA\", \"max\": 10 }` | `{ symbol, titles, sentiment }` |\n| `evaluateWithAI` | Model eval (compact series) | `{ \"symbol\":\"NVDA\", \"intraday\": { \"1m\":{points:[{t,c}]}, ... }, \"sentiment\": {...}, \"aggregate\": false }` | `{ perTimeframe: { \"<tf>\": { decision, reasoning } }, overall? }` |\n| `evaluateScoreWithAI` | Same as above (explicit name) | same as `evaluateWithAI` | same |\n| `pipelineEvaluateAI` | One-shot pipeline | `{ \"symbol\":\"NVDA\", \"maxNews\":10, \"aggregate\":false, \"perTimeframeMaxPoints\":200 }` | same as `evaluateWithAI` |\n\n### Yahoo ranges/intervals (validated combos)\n- 1d  → 1m\n- 5d  → 15m\n- 1mo → 60m\n- 3mo+ → 1d / 1wk / 1mo\n(Use `15m` instead of `10m` for 5-day intraday data.)\n\n## 🚀 Quick start\n\n### 1) Install & build\n```bash\nnpm ci\nnpm run build\n```\n\n### 2) Run as STDIO (for n8n MCP Client)\n```bash\nnpx -y @bluebossa63/mcp-stock-analyzer-ts-stdio\n```\n\n### 3) Environment (single variable friendly)\n\nThe n8n MCP node may only accept **one** env var. This server supports **blob hydration**:\n\n- **Preferred:** set one of the following in the node’s **Environment Variables** field:\n\n**Comma/newline blob**\n```\nMCP_ENV=OPENAI_BASE_URL=https://api.openai.com,OPENAI_API_KEY=sk-...,OPENAI_MODEL=gpt-4o-mini\n```\n\n**JSON blob**\n```\nMCP_ENV_JSON={\"OPENAI_BASE_URL\":\"https://api.openai.com\",\"OPENAI_API_KEY\":\"sk-...\",\"OPENAI_MODEL\":\"gpt-4o-mini\"}\n```\n\n**Base64 blob**\n```bash\nprintf 'OPENAI_BASE_URL=https://api.openai.com\\nOPENAI_API_KEY=sk-...\\nOPENAI_MODEL=gpt-4o-mini\\n' | base64\n# paste result as:\nMCP_ENV_B64=PD9...\n```\n\n- **Wrapper command alternative (bypasses env parsing):**\n  - Command: `sh`\n  - Arguments:\n    ```\n    -lc 'OPENAI_BASE_URL=https://api.openai.com OPENAI_API_KEY=sk-... OPENAI_MODEL=gpt-4o-mini npx -y @bluebossa63/mcp-stock-analyzer-ts-stdio'\n    ```\n\n### 4) Required env keys\n\n- `OPENAI_BASE_URL` (default `https://api.openai.com`)\n- `OPENAI_API_KEY`  (**required**)\n- `OPENAI_MODEL`    (default `gpt-4o-mini`)\n\nOptional (for webhooks):\n- `N8N_WEBHOOK_URL`\n- `N8N_AUTH_HEADER` (e.g., `x-api-key: abc123`)\n\n---\n\n## 🔌 n8n wiring patterns\n\n### A) News → Sentiment → Intraday → Evaluate (modular)\n\n1. **MCP: fetchNewsTitles** `{ \"symbol\":\"NVDA\", \"max\": 10 }`  \n2. **Function:** map titles → `{ \"articles\": [...] }`  \n3. **MCP: defineSentiment** (from step 2)  \n4. **MCP: fetchMultiIntraday** `{ \"symbol\":\"NVDA\" }`  \n5. **Function:** build `toolParameters` for `evaluateScoreWithAI`:\n   ```js\n   function parseMcp(item){ const raw=item?.json?.result?.content?.[0]?.text; return raw?JSON.parse(raw):null; }\n   const intradayObj = parseMcp(itemsFromNode('MCP: fetchMultiIntraday')[0]).intraday;\n   const sentimentObj = parseMcp(itemsFromNode('MCP: defineSentiment')[0]);\n   const symbol = parseMcp(itemsFromNode('MCP: fetchMultiIntraday')[0]).symbol || \"NVDA\";\n   return [{ json: { toolParameters: JSON.stringify({ symbol, intraday: intradayObj, sentiment: sentimentObj, aggregate: false, perTimeframeMaxPoints: 200 }) } }];\n   ```\n6. **MCP: evaluateScoreWithAI** with `toolParameters = {{$json.toolParameters}}`\n\n### B) One-shot\n- **MCP: pipelineEvaluateAI** `{ \"symbol\":\"NVDA\", \"maxNews\": 10, \"aggregate\": false, \"perTimeframeMaxPoints\": 200 }`\n\n### C) Post to n8n webhook (optional)\nIf you add the `postToN8N`/`evaluateAndPost` tools (see code snippets), you can push results to your own webhook.\n\n---\n\n## 🧪 Local smoke tests\n\nSentiment only:\n```bash\nOPENAI_BASE_URL=https://api.openai.com OPENAI_API_KEY=sk-... OPENAI_MODEL=gpt-4o-mini \\\nnode --input-type=module -e \"import('./dist/ai.js').then(async m => { const r = await m.defineSentimentFromTexts(['Strong datacenter demand','Analyst warns of volatility']); console.log(r) })\"\n```\n\nEvaluate with AI (provide your own small series):\n```bash\nnode --input-type=module -e \"import('./dist/ai.js').then(async m => {\n  const res = await m.evaluateWithAI({\n    symbol:'NVDA',\n    intraday: { '60m': { points: [ {t: 1710000000000, c: 100}, {t: 1710003600000, c: 102}, {t: 1710007200000, c: 101} ] } },\n    sentiment: { sentiment:'positive', confidence:0.75, reasoning:'…' },\n    aggregate:false, perTimeframeMaxPoints:120\n  });\n  console.log(JSON.stringify(res,null,2));\n})\"\n```\n\n---\n\n## 🛡️ Robustness & Troubleshooting\n\n- **Env hydration:** runs at the top of `ai.ts` so even if your MCP node collapses variables into one, parsing works.\n- **Yahoo compat:** `fetchMultiIntraday` transparently falls back `5d/10m → 5d/15m`. Use `fetchChart` for custom pairs.\n- **Network hiccups:** if you see `fetch failed`, consider adding to your env blob:\n  - `NODE_OPTIONS=--dns-result-order=ipv4first`\n  - corporate proxy/CA: `HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY`, `NODE_EXTRA_CA_CERTS`\n- **401:** check key with `debug-echo-openai` (shows base + prefix) and ensure Authorization is set (the code forces it).\n\n---\n\n## 🔒 Notes\n\n- Do not log secrets; `debug-echo-openai` masks the key.\n- Be mindful of token size; `evaluateWithAI` compacts each timeframe (default last 120 points). Tune via `perTimeframeMaxPoints`.\n\n---\n\n## License\n\nMIT © 2025\n","readmeFilename":"README.md"}