Make one direct tool call first
Install the adapter and your chosen model integration: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 discoveredtools 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.429and temporary503: honorRetry-After, reduce concurrency, and retry a bounded number of times.mcp_tool_timeout: reduce filters or result limits before retrying.
error.data.code, and request ID. Read the
Error code catalog before turning retries on globally.

