如何透過 MCP 為 AI 智能體接入即時 SEC Form 4 內部人交易資料
How to give your AI agent live SEC insider-trading data (Form 4) via MCP
文章示範如何透過 MCP 將 SEC Form 4 內部人交易資料接入 AI 智能體,讓模型以工具呼叫取得可整理的交易紀錄。免費方案可直接使用 SEC EDGAR,但需自行處理 CIK 映射、XML 解析及請求速率限制;Apify 上的 SEC Insider Trades actor 會回傳平面 JSON 資料列,收費為每 1,000 筆交易 $1.50。
Ask a chat model "Which Nvidia insiders sold stock in the last 3 months, and for how much?" and you usually get one of two answers: a polite refusal ("I don't have real-time data") or, worse, a confident paragraph with made-up names and numbers.
The real answer is public. Every time an officer, director or 10% owner of a US-listed company buys or sells, they must file a Form 4 with the SEC, usually within two business days. The problem is getting that data into your agent in a shape it can actually reason over.
This post shows how to wire SEC Form 4 data into Claude Desktop, Cursor (or any MCP client) and into plain Python, with one tool call per question.
Disclosure: I built this actor (HenryCrawl). I'll also show the free, official route so you can decide which one fits.
The problem: Form 4 is public, but not agent-friendly
Insider filings are useful context for an agent doing company research: did the CFO just sell? Was it a planned 10b5-1 sale or an open-market purchase? Did a director buy with their own money?
But raw Form 4 data has a few hurdles:
- You look up filings by CIK, not ticker.
- Each filing is a separate XML document. One filing can contain several transactions, split between Table I (common stock) and Table II (options/RSUs).
- Transactions use single-letter codes (P, S, A, M, F, G...) that an LLM will happily misinterpret.
- SEC asks automated clients to send a declared User-Agent and stay under 10 requests per second.
An LLM can't do that crawl inside a chat turn. It needs a tool that returns one clean row per trade.
Option A: the free official route (EDGAR)
If you want zero cost and full control, go straight to SEC EDGAR:
- Map ticker to CIK (SEC publishes a ticker/CIK mapping file).
- Fetch the company's filing list from EDGAR's submissions endpoint and filter for form
4(and4/Aif you want amendments). - Download each filing's XML and parse
nonDerivativeTableandderivativeTable. - Translate transaction codes, compute value = shares x price, handle footnotes and indirect ownership.
- Respect the User-Agent and rate-limit rules.
This is a good weekend project and the data is free. If you only need one ticker once, do this. Where it hurts is when you want it as a reliable agent tool across many tickers without maintaining a parser.
Option B: a ready-made Form 4 tool over MCP
The SEC Insider Trades actor on Apify does steps 1 to 5 and returns flat JSON rows. Because Apify exposes actors through a hosted MCP server, any MCP client can call it as a tool.
Pricing is pay-per-result: $1.50 per 1,000 transaction rows, no start fee, and error rows (unknown ticker, no match) are free. maxResults caps your spend per run.
Claude Desktop / Cursor config
Add the remote MCP server with your Apify API token as a Bearer header:
{
"mcpServers": {
"sec-insider-trades": {
"url": "https://mcp.apify.com/?tools=henrycrawl/sec-insider-trades",
"headers": {
"Authorization": "Bearer <APIFY_TOKEN>"
}
}
}
}
If your client only supports stdio servers, you can bridge the remote URL with mcp-remote:
{
"mcpServers": {
"sec-insider-trades": {
"command": "npx",
"args": [
"-y", "mcp-remote",
"https://mcp.apify.com/?tools=henrycrawl/sec-insider-trades",
"--header", "Authorization: Bearer <APIFY_TOKEN>"
]
}
}
}
Restart the client, then ask:
Which Nvidia insiders sold stock since September 1, and for how much? Only open-market sales.
The agent fills in the input (ticker NVDA, transactionCodes: ["S"], a dateFrom) and gets back rows it can sum, sort and quote.
Input fields
| Field | What it does |
|---|---|
tickers |
US tickers (AAPL, NVDA) or issuer CIK numbers |
dateFrom / dateTo
|
Filing date range (YYYY-MM-DD) |
maxFilingsPerTicker |
Newest-first cap per ticker (default 50; 0 = no limit) |
transactionCodes |
e.g. P purchase, S sale, A award, M option exercise, F tax withholding, G gift. Empty = all |
includeDerivative |
Include options/RSU rows from Table II (default true) |
includeAmendments |
Also read Form 4/A (default true) |
maxResults |
Hard cap on rows for the whole run (default 100) |
Using it from Python
Same thing without an agent, e.g. for a nightly job that feeds a RAG index or a Slack alert:
from apify_client import ApifyClient
client = ApifyClient("<APIFY_TOKEN>")
run_input = {
"tickers": ["AAPL", "NVDA"],
"dateFrom": "2025-01-01",
"maxFilingsPerTicker": 10,
"transactionCodes": ["P", "S"], # open-market buys and sells only
"includeDerivative": False, # common stock only
"maxResults": 30, # caps cost
}
run = client.actor("henrycrawl/sec-insider-trades").call(run_input=run_input)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
if row.get("status") != "OK":
continue # error rows are free and carry no trade
print(
row["ticker"], row["transactionDate"], row["insiderName"],
row["relationship"], row["transactionCode"],
row["shares"], row["pricePerShare"], row["transactionValue"],
)
What a row looks like
Example shape, built from the documented output fields (values are illustrative):
{
"ticker": "NVDA",
"issuerCik": "1045810",
"issuerName": "NVIDIA Corp",
"insiderName": "DOE JANE",
"insiderCik": "0000000000",
"relationship": "Officer",
"officerTitle": "EVP",
"isDirector": false,
"isOfficer": true,
"isTenPercentOwner": false,
"securityTitle": "Common Stock",
"isDerivative": false,
"transactionDate": "2026-10-15",
"transactionCode": "S",
"transactionDescription": "Open market or private sale",
"acquiredOrDisposed": "D",
"shares": 10000,
"pricePerShare": 180.5,
"transactionValue": 1805000,
"sharesOwnedAfter": 250000,
"directOrIndirect": "D",
"rule10b5_1Plan": true,
"form": "4",
"filingDate": "2026-10-17",
"accessionNumber": "...",
"filingIndexUrl": "...",
"xmlUrl": "...",
"type": "result",
"status": "OK"
}
A few fields matter a lot for agents:
-
transactionDescriptionspells out the code, so the model doesn't confuse anF(shares withheld for tax) with a real sale. -
rule10b5_1Plantells you whether a sale was pre-planned (when reported). "CEO sold under a 10b5-1 plan" and "CEO sold" are very different stories. -
sharesOwnedAfterlets the agent say "sold 4% of their holding" instead of just a raw share count. -
filingIndexUrl/xmlUrllet the agent cite the source filing, which is what you want from any finance answer.
Prompt tips
- Tell the agent to exclude codes A, M, F, G when you ask about "selling pressure"; awards and tax withholding are noise for that question.
- Ask it to group by insider and sum
transactionValue; that turns 40 rows into a readable answer. - Always ask it to link the filing for each claim.
When to pick which
- One ticker, once, or you enjoy parsing XML: use EDGAR directly. It's free.
- An agent that answers insider questions on demand, or a scheduled job across many tickers: a tool that already returns clean rows saves you the parser and the rate-limit handling, for about $0.0015 per trade row.
Not investment advice; insider trades are one signal among many.
If you try it and a field is missing or wrong, tell me in the comments or on the actor page (Issues tab). I'm the author (HenryCrawl) and I read them.
來源:DEV Community · dev.to