Install SEC API in LlamaIndex
Use LlamaIndex’s MCP tooling to register SEC API as a streamable HTTP server. The example passes auth through a customhttpx.AsyncClient.
Prerequisites
- SEC API key. Sign up at secapi.ai. Set
SECAPI_API_KEY. llama-index-tools-mcp,llama-index-core,llama-index-llms-anthropic, andhttpx.
Install
Verify
Run the snippet. The agent should call thefilings.latest tool with ticker: AAPL, form: 8-K and print the filing URL plus a short summary.
Troubleshooting
401 Unauthorized— thehttpx.AsyncClientheaders didn’t reach the server. Verify the env var is set in the same shell that runs Python:echo $SECAPI_API_KEY.429 Too Many Requests— rate limit hit. SeeGET https://api.secapi.ai/v1/billingfor your plan’s cap.AttributeError: BasicMCPClienthas no attributeheaders— if your installed version does not acceptheaders=, wrap auth in a customhttpx.AsyncClientas shown above.- Connection timeout — verify the URL ends in
/mcp(note the/mcpsuffix, not/sse).
OAuth alternative
For longer-lived workflows that need rotating credentials, swapBasicMCPClient(...) for BasicMCPClient.with_oauth(...) and follow the OAuth-protected-resource metadata at https://api.secapi.ai/.well-known/oauth-protected-resource.
Next
- Available tools — SEC + market data tools
- Give this prompt to your agent — canonical agent briefing for richer workflows