Overview
Context lets coding agents start with a natural-language question, then turn the working answer into a recurring data routine. The common path is:- Ask naturally with
context_query. - Capture the routine recipe from the successful result: question template, assumptions,
toolsUsedIDs, artifacts, and data policy. - Switch to
evidence_onlyplusincludeDataUrlwhen your own agent writes the report. - Pin saved
toolsUsedIDs astoolIdsfor repeatable managed Query runs. - Use
context_executeonly when execute discovery confirms an exact method is available. - Move custom signal logic into your own script when you want deterministic computation over the returned data.
Use
context_query for the managed data product: discovery, execution, grounding, chart generation, and evidence packaging. Use context_execute only for direct method calls that your agent will orchestrate itself.Fast Path: One-Prompt Autopilot
Some users want to explore each stage manually. Others want to fill out one config, click run, and let a strong coding agent work through the stages. Use Autopilot when you want the agent to:- run the exploratory query
- capture the recipe
- rerun as evidence-only
- propose pinned tool IDs
- test pinned Query
- test Execute only if eligible
- produce a client-side routine starter
- Use context_query_poll so waiting happens inside one MCP tool call. If you are writing normal program code, poll after roughly 30 seconds, then every 60-120 seconds for large historical windows.
- Do not start a duplicate paid query while a
jobIdis running. - A 60-day, 1h, multi-tool crypto routine can take several minutes.
Filled Example: BTC Order-Flow Routine
Use this as a placeholder config when you want to test the full Autopilot path before writing your own routine:- The agent starts with Auto Query and captures
toolsUsed. - The agent writes a Routine Recipe before changing tool selection.
- The agent reruns with
responseShape: "evidence_only"andincludeDataUrl: true. - If Auto
evidence_onlyfails, the agent retries once with pinnedtoolsUsedIDs and records the recovery. - The agent tests pinned Query with useful
toolsUsedIDs if the first run found them. - The agent tests direct Execute only if execute discovery returns an eligible method.
- The agent returns a TypeScript starter plan or script for fetching
dataUrland applying the signal policy.
Stage 1: Explore
Start with Auto Mode. Let Context discover tools and return a human-readable answer. Tell your agent:
Use context_query in Auto Mode. Ask: “Using Crypto Data for BTC futures/order-flow rows over the last 60 days at 1h resolution, analyze buy/sell flow, CVD, funding, open interest, and liquidations. Do recent signals favor long, short, or neutral high-timeframe bias? Use complementary tools only if they improve evidence.”
For this first run:
- Omit
toolIds. - Use the default
answer_with_evidence. - Include named providers in the question text if you care about them, for example “using Crypto Positioning and Crypto Data”.
- If the result returns
jobId, callcontext_query_polluntil terminal.
toolsUsed in the structured payload. Those tool IDs are the starting point for a repeatable routine.
Where to look:
- Direct
context_queryresult:structuredContent.toolsUsed - Completed
context_query_pollorcontext_query_statusresult:structuredContent.result.toolsUsed - Text-only hosts: look for “Routine recipe tool candidates from toolsUsed”
Stage 2: Capture The Routine Recipe
Before changing response shapes or pinning tools, ask your agent to save the recipe from the successful run. The recipe should include:questionTemplate: the exact question to run againtoolsUsed: tool names and IDs from the terminalcontext_queryresultassumptions: venue names, asset symbols, time window, interval, and any interpretation choicesresponseShape: usuallyevidence_onlyfor scheduled routinesincludeDataUrl: usuallytruefor full-data handoffreportTemplate: the fields your agent should produce every runsignalPolicy: any local thresholds, prior-run comparison, or “long/short/neutral” decision rule
Stage 3: Let Your Agent Write The Report
Once the question shape is right, switch toevidence_only and request a full-data handle.
Tell your agent:
evidence_only still runs the managed Query runtime. It skips the prose synthesis layer so your own agent can synthesize the result, compare against prior runs, or apply a custom decision rule.
includeDataUrl: true keeps large payloads out of the model context. The result includes a public, fetchable data handle such as dataUrl and often artifacts.canonicalDataRef.
For dense routines such as 60-day, 1h Crypto Data order-flow analysis, treat evidence_only as the reliable routine shape. Use prose answers to inspect whether the tool and question are plausible, not as the durable machine-readable handoff.
Stage 4: Pin For Repeatability
Auto Mode is the easiest way to discover the right data. For a routine that should behave similarly every day, pin the tool shortlist. Pinned Query means: pass a saved list of marketplacetoolIds to context_query so the managed runtime only uses those tools. Context still handles execution, grounding, charting, and evidence packaging; it just stops broad Auto Mode tool selection from changing the provider shortlist.
Use the prior successful run as the source of truth:
- Read
toolsUsedfrom the completed Stage 1 or Stage 3context_queryresult. - Save the
idandnamefor each tool that actually contributed useful evidence. - Optionally call
context_discoverin query mode to inspect those tools again or search the same domain for nearby alternatives. - Call
context_querywith the savedtoolIds, the same question template,responseShape: "evidence_only", andincludeDataUrl: true. - Store the question template, selected
toolIds, and any local signal thresholds in your repo.
Stage 5: Direct Execute When Available
Use direct execution only after execute discovery proves a method exists.- Call
context_discoverwithmode: "execute". - Inspect returned
mcpTools, schemas, and execute prices. - Call
context_executewith the exacttoolId,toolName, andargs. - Reuse
sessionIdandmaxSpendUsdfor related calls. - Synthesize or compute the final answer in your own agent or script.
- Query mode asks Context to manage the workflow. Tools are selected by
toolIdsor Auto Mode, and Context decides which methods to call internally. - Execute mode asks your agent or script to call one exact method with explicit arguments and pay per call.
context_query grounding into context_execute. Query grounding shows what the managed runtime used or considered; it is not the direct-execute contract.
For the Crypto Data BTC order-flow routine in this guide, an empty execute discovery is acceptable. It means the routine should remain on pinned Query until Crypto Data exposes an execute-eligible method that covers the needed rows and metrics.
If execute discovery returns no methods, keep the routine on pinned context_query. That is still a repeatable, production-worthy workflow.
Stage 6: Move Signal Logic Client-Side
When the routine is stable, put the deterministic part in code:- Fetch the terminal query result.
- Read bounded evidence from
structuredContent. - Fetch
dataUrlonly when full rows are needed. Use a real HTTP client for large blobs. - Compute local indicators, thresholds, and prior-run diffs.
- Store the final signal and the Context data reference.
- spot vs perp CVD divergence
- flow z-scores against 30-day and 60-day baselines
- open interest or funding confirmation
- bias:
long,short, orneutral - confidence and invalidation conditions
Copy-Paste Routine Prompt
Use this prompt in Claude Code, Cursor, OpenClaw, or another MCP-capable coding agent:Choosing The Right Level
Use Auto Query when you are exploring a question or want the fastest path to a good answer. Capture a Routine Recipe when the Auto Query result is good enough to preserve. The important field istoolsUsed: those IDs become your first pinned tool candidates.
Use evidence-only Query with dataUrl when your coding agent writes the report, compares against prior runs, or computes a custom signal.
Retry evidence-only with pinned tools when Auto answer_with_evidence worked but Auto evidence_only fails without invoking marketplace tools.
Use pinned Query when you want recurring runs to stay within the same provider/tool shortlist while still using Context’s managed runtime.
Use direct Execute when you already know the exact method and arguments, and execute discovery confirms that method is eligible.
Use your own script when the final decision rule needs deterministic state, thresholds, backtesting, or storage across scheduled runs.
