Blog · 2026-09-12

How to Build an AI Stock Research Agent on SEC Data (2026)

An AI agent connected over MCP to an Edgrapi server that returns clean JSON from SEC filings, including insider trades, 13F holdings, and activist stakes
An AI stock research agent reads the filing over MCP. It doesn't guess from training data.

Ask ChatGPT what NVIDIA's insiders bought last quarter. It will guess.

An AI stock research agent is an LLM wired to real SEC filing data through tools it can call, so it answers questions about a company from the actual record instead of its training data. The useful ones don't stop at prices and 10-K text. They reach the smart-money layer: who's buying (Form 4 insider trades), which funds added (13F holdings), and who just crossed 5% (13D/13G activist stakes). You build one by pointing an agent at a data server over MCP.

That last part is what changed in 2026. You no longer wire this by hand.

Key takeaway: An AI stock research agent is an LLM wired to real SEC filings through tools it can call over MCP, so it answers from the record instead of its training data. The useful ones reach the smart-money layer, insider Form 4 trades, 13F fund holdings, and 13D/13G activist stakes, not just prices. With a hosted MCP server you build one in about 15 minutes and never parse XBRL yourself.

What makes an AI stock research agent actually useful, not just a demo?

A stock research agent earns its keep when it pulls the filings a human analyst would open, not the numbers a free quote API already lists. The bar is the smart-money layer: insider buys, fund holdings, activist stakes, 8-K events. Most demos wire an LLM to Yahoo Finance for prices and call that a research agent. Prices are the commodity. The edge lives in the filings nobody wants to parse.

Here's the test I use.

Ask the agent: "Which hedge funds added to their position in this stock last quarter, and did any insiders buy on the open market?"

A prices-only agent can't answer that. The data isn't in a quote feed. It's in 13F filings and Form 4s on SEC EDGAR.

The top-ranked "build a stock agent" tutorials skip this entirely. Stack AI's 2026 guide wires an agent to web search and Yahoo Finance, with no SEC filings, no insider data, and no MCP connection at all. It's a news summarizer, not a research agent.

The difference isn't the model. GPT-4 and Claude are both fine at reasoning over filings. The difference is what data you feed them and how clean it is.

Why does my AI agent hallucinate financial numbers?

Your agent hallucinates because it's guessing from training data instead of reading a filing, and because raw SEC data is easy to misread. A 2026 analysis compiled by IntuitionLabs found GPT-4-Turbo with retrieval incorrectly answered or refused 81% of curated SEC-filing questions. The same review found structured XBRL data cut financial-extraction errors 74 times over raw HTML, from 8.16% to 0.11%. The fix is grounding the agent in clean, pre-parsed data.

Think about what an LLM does with a raw 10-K.

It reads HTML. It sees a number like 1,234 and has to decide: thousands or millions? Is that a loss, so it needs a minus sign? Which of five revenue line items is "revenue"?

Get one wrong and the answer is confidently, precisely incorrect. The model doesn't flag it. It hands you a fabricated number with the same tone it would use for a real one.

XBRL, the SEC's structured financial format, fixes most of this. But it's not a free lunch. That same 2026 research found LLMs hit only 17% accuracy when they have to link concepts across the 18,000-element US-GAAP taxonomy themselves.

So the reliable pattern is: don't make the agent parse. Give it data that's already normalized into one clean schema, where revenue is revenue and a loss is negative. Then the agent reasons, it doesn't decode.

That's the entire argument for a data layer between your agent and EDGAR.

Which AI model is best for reading SEC filings, GPT or Claude?

The model matters less than whether it's grounded in real filing data. Naked LLMs top out around 79% accuracy on SEC-filing questions even with the document in context, and fall off a cliff without it. Wire the same model to a data tool over MCP and accuracy jumps past 94%. So pick the model you already like, GPT or Claude, and spend your effort on the data connection, not the model choice.

The benchmarks make this concrete. On FinanceBench, even GPT-4-Turbo handed the full filing in context answers only about 79% of questions correctly, a wide gap from what you'd trust for a real decision. Strip the filing out and make it recall from training, and one evaluation put a naive GPT-4-Turbo at 19% on the same benchmark.

Now ground it. Daloopa's open benchmark measured Claude wired to a financial-data tool over MCP at 94.2% exact-match accuracy, about 30 points over ungrounded ChatGPT, and 97.2% with a 1% tolerance. Same class of model, completely different reliability, and the only thing that changed was the data connection.

That's the pattern across all of these studies. GPT-5, Claude, and Gemini all reason fine over a filing that's in front of them. None of them reliably remembers the exact number from training. The accuracy you care about comes from the retrieval layer, so the real question isn't "GPT or Claude," it's whether the agent is reading the filing or guessing at it.

Practical version: use whatever model your MCP client runs, and make sure the data tool hands back clean, parsed numbers. A weaker model on clean data beats a stronger model on raw HTML.

How do you connect an AI agent to SEC data over MCP?

You connect an agent to SEC data by pointing it at an MCP server that exposes filing data as callable tools. MCP (Model Context Protocol) is Anthropic's open standard for giving an LLM a live data connection. Instead of uploading files, you register a server once and the agent queries it on demand. For SEC data, a hosted MCP server is the cleanest path, so you skip running and parsing anything yourself.

Two ways to do this.

Self-hosted: you run an open-source SEC MCP server on your own machine. Free, but it's yours to operate.

Hosted: you paste a URL and a key, and the server runs for you. No infrastructure.

For Edgrapi's hosted server, the whole setup is a config block your MCP client reads:

{
  "mcpServers": {
    "edgrapi": {
      "url": "https://api.edgrapi.com/mcp",
      "headers": { "Authorization": "Bearer edgr_your_key" }
    }
  }
}

Drop that into Claude Desktop, Cursor, Cline, or any MCP-capable client. Authenticate with OAuth 2.1 (PKCE) or a bearer key. The agent now has 14 tools, including get_insider, get_holdings for 13F portfolios, get_activist for 13D/13G stakes, and get_fundamentals.

No parsing. No rate-limit handling. The agent just calls a tool and gets clean JSON back.

How do you build an AI stock research agent in about 15 minutes?

You can stand up a working SEC research agent in roughly 15 minutes using a hosted MCP server and any MCP client. There's no code in the basic version. You get a key, add one config block, and start asking questions in plain English. The agent picks the right tool, calls it, and answers from the filing. Here's the full path.

Step 1: Get a data key. Sign up for a hosted SEC data provider with an MCP server. Edgrapi's free tier is 100 credits a month, no card, and an empty result (a company with no matching filings) doesn't cost a credit. Copy the edgr_ key.

Step 2: Add the MCP server to your client. Open Claude Desktop, Cursor, or Cline. Paste the config block from the section above, with your key in the Authorization header. Restart the client so it picks up the server.

Step 3: Confirm the tools loaded. Ask the agent, "What SEC tools do you have?" It should list the filing tools, insider trades, 13F holdings, and activist stakes among them. If it does, the connection works.

Step 4: Ask a real research question. Try: "What did NVIDIA insiders buy or sell recently, and how fast is revenue growing?" The agent calls get_insider and get_fundamentals, then answers from the filings, not its training data.

Step 5: Go deeper. Chain it. "Now show me which funds that hold NVIDIA added last quarter." That's get_holdings, diffed against the prior 13F. This is the loop a one-off script never gives you, because the agent calls the server again on every follow-up.

That's the whole build. The reasoning is the model's job. The data is the server's job.

Get a free API key and wire your agent to SEC filings in a minute, no card required.

Hosted vs self-hosted SEC MCP: which should you use?

Use self-hosted if you want zero cost and don't mind running a server; use hosted if you want the smart-money data and no infrastructure. The leading free option, sec-edgar-mcp, is self-hosted, ships with no authentication ("use only on private networks," per its own docs), and covers 10-K, 10-Q, 8-K, XBRL, and insider forms, but not 13F holdings or 13D/13G activist stakes. That gap is the deciding factor for most research agents.

Here's the honest comparison.

Edgrapi (hosted)sec-edgar-mcp / EdgarTools (self-hosted)Alpha Vantage MCP
SetupPaste URL + bearer keyRun Docker/pip yourselfAPI key
Insider trades (Form 4)YesYesLimited
13F fund holdingsYes (get_holdings)NoNo
Activist stakes (13D/13G)Yes (get_activist)NoNo
HostingHosted, no infraYou run it; private networks onlyHosted
Free tier100 credits/month, empty results freeFree (you self-run)25 requests/day
Data shapePre-parsed clean JSONXBRL basicsClean JSON

If all you need is 10-K text and financials, the free self-hosted servers are great. Run one.

The moment you want "what are insiders and funds actually doing," the free EDGAR servers stop short. They parse filings, not the smart-money layer. That's where a hosted server with get_holdings and get_activist earns the credit.

And there's the rate limit. SEC EDGAR caps every user at 10 requests per second across all its domains, regardless of how many machines you use, and rejects any request without a User-Agent header, per the SEC's own access guidance. A self-hosted server makes that your problem. A hosted one absorbs it.

What can the agent actually answer once it's wired up?

Once connected, the agent answers the questions a research analyst asks, grounded in filings. Who's buying (insider Form 4s via get_insider). Which funds added this quarter (get_holdings, diffed against the prior 13F). Who just crossed 5% (get_activist for 13D/13G). How the financials are trending (get_fundamentals, get_ratios). Every answer traces to a filing you can open and check.

A few prompts that work well:

"Show me every open-market insider buy over $1M in the last month." The agent hits the insider feed and filters by transaction code and value.

"Compare Berkshire's top 10 holdings this quarter versus last." That's a 13F diff, the exact thing a fund's own 13F filing hides in raw form.

"Did anyone file a 13D on this company recently?" A 13D lands within days of an activist crossing 5%, far ahead of the quarterly 13F.

The agent isn't predicting any of this. It's reading it.

What to watch out for before you trust it with money

Treat the agent as a research accelerator, not an oracle. SEC filing data is factual, but it carries timing and coverage caveats. A 13F is filed up to 45 days after quarter-end, so a fund's holdings can be months stale when you read them. None of this is investment advice, and an agent that pulls a real number can still reason badly on it. Verify anything you'd trade on against the source filing.

Three specific traps.

13F lag. The holdings are real but late. A fund can buy in January, sell in March, and you still see the position in the mid-February filing. Read 13F for conviction and consensus, not for timing.

Confident wrong answers. Even with clean data, the model can misread context. When it gives you a number that would move a decision, ask it for the filing URL and check.

Coverage edges. Foreign private issuers file 20-F, not 10-K. Funds don't file income statements. A good agent tells you when data doesn't exist instead of inventing it, which is another reason empty-result handling matters.

Wire the smart-money layer first

Don't start with prices. Start with the data an LLM can't guess and a free feed won't give you: paste the MCP config into Claude or Cursor, then ask it what insiders and funds bought this week. If it answers from the filings, you've built the agent. If it guesses, you've built a chatbot.

Frequently asked questions

Why does my AI agent keep hallucinating financial data, and how do I fix it?

Because it's answering from training data or misreading raw filings. A 2026 review found GPT-4-Turbo with retrieval got 81% of SEC-filing questions wrong or refused them, and that structured XBRL cut extraction errors 74 times versus raw HTML. The fix is grounding: connect the agent to a data source that returns clean, pre-parsed numbers so the model reasons instead of decoding, then verify anything decision-critical.

Is there a hosted SEC EDGAR MCP server so I don't have to run one myself?

Yes. Most SEC MCP servers, like sec-edgar-mcp and EdgarTools, are self-hosted and free but you run and maintain them, and their own docs say to use them only on private networks. Hosted options like Edgrapi expose the same filing data at a URL with a bearer key, so you skip Docker, parsing, and the SEC rate limit. You trade a free-but-DIY setup for a metered-but-managed one.

Does the free SEC EDGAR MCP cover 13F holdings and activist stakes?

No, and this is the common gap. The leading free servers (sec-edgar-mcp, EdgarTools) cover 10-K, 10-Q, 8-K, XBRL financials, and insider forms, but not 13F fund holdings or 13D/13G activist stakes. If your agent needs to answer which funds added this quarter or who crossed 5%, you need a server with dedicated holdings and activist tools, which today means a hosted provider.

How accurate is ChatGPT or Claude on 10-K numbers?

Poor, unless you ground it. Left to its training data, an LLM guesses figures and states them confidently; one 2026 benchmark put GPT-4-Turbo's SEC-filing error-or-refusal rate at 81%. Accuracy jumps when you feed it structured data instead of raw text, since parsing XBRL correctly is itself hard (LLMs score about 17% on US-GAAP taxonomy linking alone). Give the model the parsed number, not the document.

What's the best financial-data MCP server for an AI agent?

It depends on what you're building. For prices and broad market data, Alpha Vantage's MCP is common, though its free tier is capped at 25 requests a day. For SEC filings only, the free self-hosted servers work. For a stock research agent that needs insider trades, 13F holdings, and activist stakes together over a hosted connection, pick a server that exposes those as dedicated tools rather than making you assemble them.

Do I need to write code to build the agent?

No, not for the basic version. If your MCP client is Claude Desktop, Cursor, or Cline, the entire build is pasting a config block and asking questions in plain English. You only write code when you want a custom agent loop, in which case frameworks like LangGraph or CrewAI wrap the same MCP tools programmatically.

Get a free API key