Skip to main content
If your agent supports MCP, use the hosted endpoint at https://stockcontext.com/mcp (setup). This page shows the plain HTTP function-calling pattern for agents or frameworks where you register tools yourself: expose each tool as a function that POSTs to /v1/tools/{name} and returns the parsed JSON.

The tool-selection policy

Start narrow. For a “tell me about X” question the first call is almost always stock_overview — it carries the latest financials, valuation, and growth in one payload. Add exactly one more call per dimension the question opens, and stop when it is answered. See Choose a tool for the full map.

Tool functions

Each tool is one function. The key lives in the X-API-Key header, server-side — never in a prompt or a client bundle.
agent_tools.py
Register these as function-calling tools with your model provider, with the same argument names the API uses.

A worked trace

User: Is Apple growing, and how is it priced? Call 1, stock_search — resolve the ticker and confirm coverage.
stock_search q=AAPL (trimmed)
coverage.financials: true, so fundamentals are served. The agent proceeds. Call 2, stock_overview — one call covers growth and valuation.
stock_overview symbol=AAPL (trimmed)
Two dimensions, one call. The agent has enough to answer. Final answer. Answer first, then the facts, then the provenance and clocks it stood on:
Apple grew revenue about 6.4% and net income about 19.5% year over year, and it trades at a trailing P/E of roughly 39.5 with a free-cash-flow yield near 2.3%. The growth figures come from SEC-filed financials (as_of.sec 2026-06-26). The P/E and FCF yield are computed_from_prices — a fundamentals input times a market close on 2026-07-01 — so they move with the price, not the filings. Calls used: stock_search, stock_overview. This is context, not advice.
That last paragraph is not optional. The instruction that produces it — answer first, cite provenance and the clock, never give buy/sell advice, never invent data the API refused — is in Agent instructions. Paste that block into your system prompt.

Where agents go wrong

  • Reading a refusal as a value. A field with unavailable has no value. Never substitute 0 or null; report the token (and look it up in the refusal_tokens catalog if needed).
  • Parsing magnitudes as floats. Exact values are decimal strings — use a decimal type so precision survives.
  • Blending the two clocks. A computed_from_prices multiple mixes an SEC-filed input with a market close. Do not present it as “the filing says,” and cite the price date.
  • Treating 13F as total ownership. stock_ownership is a tracked subset with exhaustive: false. Say “among tracked managers.”
  • Retrying non-retryable failures. invalid_api_key (401) and a 422 validation error do not change on retry — fix the cause. See Errors and retries.

Agent instructions

The operating rules to paste into your system prompt.