Skip to main content
Use LangChain’s MCP adapters when your application, worker, or backend owns the agent. The adapter loads SEC API’s remote tool definitions over streamable HTTP and returns LangChain tools. Put the API key in that server runtime’s secret manager; browser bundles and client-side routes should not receive it.

Make one direct tool call first

Install the adapter and your chosen model integration:
Then verify tool discovery and a single filing call before constructing an agent:
LangChain documents http as the streamable HTTP transport and supports custom headers in the connection configuration. Its MCP adapter documentation is the version-specific source for package and transport changes. Load SECAPI_API_KEY only in the process that invokes this code. For a web application, call this from a server route, worker, or backend service; do not return the key or a reusable MCP client configuration to the browser.

Add tools only after the proof call works

After the direct call succeeds, pass the discovered tools to your LangChain agent. Keep the tool loading near the agent lifecycle: rebuild or refresh it on process startup and after a deliberate integration upgrade, rather than serializing an old copied schema into your application. Give the agent narrow defaults for issuer, form, date range, and list limits before allowing it to plan multi-tool work.

Return the source record with the answer

filings.latest returns a filing record with accessionNumber, filingDate, and filingUrl; the MCP response envelope carries requestId and traceparent. Store those with the answer. Search, section, and analytical tools may include provenance, freshness, or source fields: carry them through your agent state and final output. A model’s prose is not a substitute for the source filing identity.

Errors and bounded retries

Handle tool errors before model-level retry loops:
  • 401: repair or rotate the server-side key.
  • 402: resolve plan, credit, billing, or budget state; do not retry unchanged.
  • 429 and temporary 503: honor Retry-After, reduce concurrency, and retry a bounded number of times.
  • mcp_tool_timeout: reduce filters or result limits before retrying.
Record the JSON-RPC error, SEC API error.data.code, and request ID. Read the Error code catalog before turning retries on globally.

Next step

Add the verified tool set to your LangChain agent, then require every filing answer to include accession number, filing URL, and request metadata.