Multi-Year Financial Analysis with Claude Code and SEC Data

Claude Code can reason about numbers well, but it needs real numbers to reason about. With AgentPatch’s SEC Company Financials tool, you can pull five years of official filing data for any public company and have Claude Code analyze trends, calculate margins, and flag anomalies — all in one session.

Why This Matters

Financial trend analysis is one of those tasks that sounds simple but has a lot of friction. You need to find the data, make sure it’s from a reliable source, get it into a format you can work with, and then actually do the analysis. Usually that means bouncing between EDGAR, a spreadsheet, and maybe a Python script.

With AgentPatch connected, Claude Code handles the whole pipeline. It pulls data directly from SEC EDGAR XBRL filings — the same source analysts use — and then analyzes it on the spot. Every number comes from an official 10-K or 10-Q filing, not an estimate or a third-party aggregation.

The tool returns the default facts (Revenues, NetIncomeLoss, Assets, Liabilities, StockholdersEquity, EarningsPerShareBasic, OperatingIncomeLoss, CashAndCashEquivalentsAtCarryingValue), or you can pass a custom list of XBRL facts if you need something specific. Each data point includes the reporting period, filing date, and form type. It costs 75 credits per call.

Setup

Install the AgentPatch CLI (zero dependencies, Python 3.10+):

pip install agentpatch

Set your API key:

export AGENTPATCH_API_KEY=your_api_key

Then use it:

ap search "web search"
ap run agentpatch google-search --input '{"query": "test"}'

Get your API key from the AgentPatch dashboard.

Run this command to add AgentPatch as an MCP server:

claude mcp add -s user --transport http agentpatch https://agentpatch.ai/mcp \
  --header "Authorization: Bearer YOUR_API_KEY"

Replace YOUR_API_KEY with your actual key from the AgentPatch dashboard. Claude Code discovers all AgentPatch tools automatically.

Example

You’re preparing a financial overview for a board meeting and want to understand how Alphabet has performed over the last five years. You tell Claude Code:

“Pull Alphabet’s financials from SEC for the last 5 years. Analyze the revenue growth trajectory, net income margins, and operating leverage. Flag anything unusual.”

Claude Code runs the research:

Searching SEC for "Alphabet"...
Found: Alphabet Inc, CIK 0001652044

Pulling financials for CIK 0001652044 (5 years)...

Alphabet Inc — 5-Year Financial Analysis:

Revenue Growth:
  2020: $182.5B
  2021: $257.6B (+41.2% — post-COVID ad recovery)
  2022: $282.8B (+9.8% — growth deceleration)
  2023: $307.4B (+8.7%)
  2024: $350.0B (+13.9% — Cloud and AI acceleration)

  CAGR (2020-2024): 17.7%

Net Income Margin:
  2020: 21.2%  |  2021: 29.5%  |  2022: 21.2%
  2023: 24.7%  |  2024: 28.6%

  Notable: 2022 margin compression from hiring + datacenter spend,
  followed by recovery through 2023 cost cuts.

Operating Income:
  Grew from $41.2B (2020) to $100.5B (2024).
  Operating margin expanded from 22.6% to 28.7%.

Flag: The 2021 revenue spike (+41%) was an outlier driven by pandemic
ad-spend recovery. Underlying organic growth rate is closer to 10-14%.

Flag: Cash position grew from $26.5B to $24.5B despite massive buybacks,
suggesting strong free cash flow generation.

All data from official SEC 10-K filings.

Claude Code pulled real data, calculated growth rates and margins, identified the COVID-driven outlier in 2021, and flagged the margin compression story in 2022. That’s a first-draft analyst note generated from an agent prompt.

Wrapping Up

With AgentPatch, Claude Code becomes a capable financial research tool. Pull SEC filings, analyze trends, and generate reports — all from your terminal. Combine it with other marketplace tools for broader research: Google Search for news context, Google Trends for demand signals, or email to share your findings. Visit agentpatch.ai to see the full toolkit.