Install SEC API in LangChain
Use LangChain’s MCP adapters to register SEC API as a streamable HTTP tool server with anx-api-key header.
Prerequisites
- SEC API key. Sign up at secapi.ai. Set
SECAPI_API_KEY. - Python:
langchain-mcp-adapters,langchain,langgraph, and a model provider package. - JavaScript / TypeScript:
@langchain/mcp-adapters,@langchain/core,@langchain/langgraph, and a model provider package.
Python
JavaScript / TypeScript
Verify
Run either 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—x-api-keyis missing or wrong. Sanity check:curl https://api.secapi.ai/v1/limits -H "x-api-key: $SECAPI_API_KEY".429 Too Many Requests— rate limit hit. SeeGET https://api.secapi.ai/v1/billingfor your plan’s cap.- No tools returned — confirm the URL ends in
/mcp(not/sse); the SSE transport is deprecated as of MCP 2025-03-26. - Streaming notifications missing — if your adapter version does not support MCP progress events, tool calls can still complete while long-running progress updates are omitted.
Next
- Available tools — SEC + market data tools
- Give this prompt to your agent — canonical agent briefing for richer workflows