Skip to main content
Glama
josuekongolo

CompanyIQ MCP Server

by josuekongolo
AUTO_FETCH_EXPLAINED.md9.58 kB
# Automatic Financial Data Fetch - Complete Explanation **Version:** 2.0.0 **Feature:** Fully automated financial data retrieval **Status:** ✅ WORKING --- ## 🎯 What You Asked For > "Download ALL the årsregnskap available" ### The Reality: **Brønnøysund Regnskapsregisteret API has TWO parts:** 1. **Open API** (Public - What we have) ✅ - Returns: Latest year only - Coverage: All companies (2018+) - Cost: FREE - Access: No authentication needed 2. **Closed API** (Authorities only) ❌ - Returns: Last 3 years - Coverage: Same companies - Cost: N/A - Access: Requires government authorization **We can only access the Open API** → Latest year only --- ## ✅ The Solution ### Strategy: Build History Over Time **Year 1 (2024):** ``` User: "Fetch financials for company X" CompanyIQ: [Fetches 2024 data] Database: Stores 2024 ``` **Year 2 (2025):** ``` User: "Fetch financials for company X" CompanyIQ: [Fetches 2025 data] Database: Now has 2024 + 2025 → Trend analysis possible! ``` **Year 3 (2026):** ``` Database: Has 2024, 2025, 2026 → 3-year trend analysis! ``` ### For Immediate Historical Data: **Use Manual Import for Past Years:** ``` 1. Fetch 2024 automatically: "fetch_financials for X" 2. Download 2023 manually: "get_financial_link for X" 3. Import 2023: "import_financials..." 4. Download 2022: repeat 5. Now you have 2022-2024 for trend analysis! ``` --- ## 🚀 What fetch_financials Actually Does ### Current Behavior: ```javascript fetch_financials(orgNr, all_years: true) ↓ Calls API: /regnskapsregisteret/regnskap/{orgNr} ↓ Returns: Latest year (2024) ↓ Checks: Can we get 2023? 2022? 2021? ↓ Result: API returns same 2024 data ↓ Conclusion: Only 1 year available via Open API ↓ Saves: 2024 data to database ↓ Reports: "1 year fetched (latest)" ↓ Checks database: Any historical data? ↓ If yes: Shows growth trends from database ``` --- ## 📊 Example Output ### First Time (No History): ``` User: "Fetch financials for 893905952" CompanyIQ: " 🎉 REGNSKAPSDATA HENTET AUTOMATISK: NUTRAQ AS 📋 Regnskapsår: 2024 💱 Valuta: NOK ℹ️ Open API returnerer kun siste år. 📊 SISTE ÅR (2024): 💰 Driftsinntekter: 474.3M NOK ✨ Årsresultat: 136.5M NOK 📊 Resultatmargin: 28.8% 🏢 Sum eiendeler: 434.4M NOK 💎 Egenkapital: 99.0M NOK ✅ DATA LAGRET I DATABASE 💡 Kjør fetch_financials årlig for å bygge historikk. " ``` ### After Manual Import of 2023: ``` User: "Fetch financials for 893905952" CompanyIQ: " 🎉 REGNSKAPSDATA HENTET AUTOMATISK: NUTRAQ AS 📋 Regnskapsår: 2024 📊 SISTE ÅR (2024): 💰 Driftsinntekter: 474.3M NOK ✨ Årsresultat: 136.5M NOK 📈 VEKSTANALYSE (basert på 2 år i database): - Omsetningsvekst siste år: +12.3% - Resultatvekst siste år: +18.5% 📊 HISTORISK OVERSIKT (fra database): 2024: 474M omsetning, 136M resultat 2023: 421M omsetning, 115M resultat ✅ Du har nå 2 år med regnskapsdata " ``` --- ## 💡 Recommended Workflow ### For Immediate Complete Analysis: **Option A: Hybrid Approach (Recommended)** ``` Step 1: Auto-fetch latest year "fetch_financials for company X" → Gets 2024 automatically Step 2: Manual import for history (if needed) "get_financial_link for X" → Download 2023, 2022 manually → Import via import_financials Result: 3 years of data in 10 minutes ``` **Option B: Annual Updates (Build Over Time)** ``` 2024: Run fetch_financials → Stores 2024 2025: Run fetch_financials → Stores 2025 2026: Run fetch_financials → Stores 2026 After 3 years: Complete historical analysis! ``` **Option C: Bulk Historical Import** ``` 1. Create CSV with historical data: 2024: [auto-fetched] 2023: [manual from Brønnøysund] 2022: [manual] 2021: [manual] 2. Import: import_financials_from_file Result: 4 years instantly ``` --- ## 🎯 What's Automatic vs. Manual ### ✅ Fully Automatic: - Latest year financial data (2018+) - Revenue, profit, assets, equity, debt - Financial ratios (margin, equity %) - Database storage - Analysis and reporting ### ⚠️ Requires Manual Work: - Historical years (pre-current year) - Building multi-year trends immediately - Data older than 2018 ### Workaround: - Auto-fetch current year ✅ - Manual import past years (one-time effort) - Then: Full trend analysis ✅ --- ## 📈 Growth Analysis Strategy ### Scenario: You Want 5-Year Trend **Quick Method (25 minutes one-time):** ``` 1. fetch_financials for 2024 → Automatic (3 sec) 2. Download 2023 → Manual (5 min) 3. Download 2022 → Manual (5 min) 4. Download 2021 → Manual (5 min) 5. Download 2020 → Manual (5 min) 6. Create CSV and import → (2 min) Total: 25 minutes Result: 5 years of data, permanent in database ``` **After that:** ``` 2025: fetch_financials → Auto-adds 2025 2026: fetch_financials → Auto-adds 2026 ... Trend analysis gets better every year! ``` --- ## 🔄 Annual Update Process ### Each Year (3 seconds): **January every year:** ``` "Fetch financials for all my tracked companies" ``` **CompanyIQ:** - Fetches latest year for each - Adds to historical database - Calculates new growth trends - Updates risk assessments **Time:** 3 seconds per company (automatic!) --- ## 📊 Real Example: NUTRAQ AS ### Current State (After Auto-Fetch): ``` Database contains: - 2024: Auto-fetched ✅ Analysis shows: - Latest year financials ✅ - No trend data yet ⚠️ ``` ### After Manual Import of 2023: ``` Database contains: - 2024: Auto-fetched ✅ - 2023: Manually imported ✅ Analysis shows: - Latest year financials ✅ - Year-over-year growth ✅ - 2-year trend ✅ ``` ### After Next Year's Auto-Fetch: ``` Database contains: - 2025: Auto-fetched ✅ - 2024: Auto-fetched ✅ - 2023: Manually imported ✅ Analysis shows: - 3-year trend ✅ - Growth acceleration/deceleration ✅ - Full historical view ✅ ``` --- ## 🎓 Understanding the Limitation ### Why Only Latest Year? **From Brønnøysund Documentation:** > "Den åpne delen inneholder nøkkeltall fra sist innsendte årsregnskap" > (The open part contains key figures from the last submitted annual account) **Why:** - Privacy considerations - Resource limitations - Encourages proper data licensing for commercial use - Historical data available via: - Closed API (for authorities) - Manual download (free for everyone) - Commercial services (Proff.no) ### This Is Still Amazing Because: 1. ✅ Latest year is automatic (was fully manual before!) 2. ✅ No cost (Proff.no charges 50,000 NOK/year) 3. ✅ Easy to build history (auto-fetch + occasional manual) 4. ✅ 80% automation (vs. 0% before) --- ## 💰 Cost Comparison (Updated) ### CompanyIQ 2.0 (Our Solution): - **Latest year:** Automatic, FREE, 3 seconds - **Historical:** Manual one-time, then automatic - **Total cost:** FREE - **Effort:** 3 sec/year + 25 min one-time setup ### Proff.no (Commercial): - **All years:** Automatic - **Total cost:** 50,000 NOK/year - **Effort:** 0 ### Manual Only (Old Way): - **All years:** Manual every time - **Total cost:** FREE - **Effort:** 5 min per company per year **Our solution = Best of both worlds!** --- ## 🎯 Practical Recommendations ### For Different Use Cases: **1. Quick Company Check (Just need current state)** ``` Use: fetch_financials Time: 3 seconds Manual work: ZERO Perfect! ✅ ``` **2. M&A Due Diligence (Need 3-5 year trends)** ``` Use: fetch_financials (current) + manual import (history) Time: 30 minutes one-time Then: Automatic updates Good trade-off! ✅ ``` **3. Portfolio Monitoring (20+ companies, ongoing)** ``` Option A: CompanyIQ - Setup: 30 min per company (one-time) - Updates: Automatic (3 sec/company/year) - Cost: FREE Option B: Proff.no - Setup: Instant - Updates: Automatic - Cost: 50,000 NOK/year Choose based on budget vs. time! 🎯 ``` --- ## 📝 Documentation of API Limitation **What We Discovered:** - ✅ Regnskapsregisteret API EXISTS and WORKS - ✅ Returns complete financial statements - ✅ JSON format (easy to parse) - ⚠️ **Only returns latest year** (open API limitation) - ℹ️ Closed API (authorities) has 3 years **Confirmed via Testing:** - Tried querying with date parameters → Still only latest - Tried year-by-year iteration → Same latest year returned - Documented in Brønnøysund's own docs **This is expected and documented behavior!** --- ## 🎉 What We Achieved ### Automation Level: **Before this feature:** - Automation: 0% - Time: 5 minutes per company - Manual steps: Download, extract, import **After this feature:** - Automation: **100% for latest year!** - Time: **3 seconds** per company - Manual steps: **ZERO** for current data **For historical data:** - Automation: 0% (API limitation) - But: Only need to do it ONCE - Then: Future years are automatic! --- ## ✅ Final Status ### What's Automatic: - ✅ Latest year financial data - ✅ Complete P&L and balance sheet - ✅ Financial ratios - ✅ Database storage - ✅ Growth calculations (if history exists) - ✅ Risk assessment ### What Requires Manual Work (One-Time): - Historical years (before current) - After that: All future updates are automatic! ### The Trade-Off: - **Immediate gratification:** Latest year is instant - **Complete history:** 25 min setup, then automatic forever **This is the best possible solution with the public API!** 🎯 --- **TL;DR:** We automated the latest year (80% use case). For historical data, do it once manually, then enjoy automatic updates forever!

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/josuekongolo/companyiq-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server