Overview
Context provides a remote MCP server that exposes the entire marketplace (Query, Execute, and Discover) through the Model Context Protocol. Any agent that supports Streamable HTTP MCP servers can connect in under a minute. Five tools are available:| Tool | What it does |
|---|---|
context_query | Run an agentic Q&A query against the marketplace. Quick jobs return a grounded answer; long jobs return a jobId |
context_query_start | Start a complex query and return a jobId immediately |
context_query_status | Poll a query job until it completes or fails |
context_execute | Call a specific marketplace tool method directly and get the structured result |
context_discover | Search the marketplace for available tools before querying or executing |
The MCP server wraps the same Query and Execute APIs that the TypeScript and Python SDKs use. Authentication is the same
sk_live_... API key you already have.Prerequisites
Before connecting, complete setup at ctxprotocol.com:Endpoint
Authorization: Bearer sk_live_... header on every request.
Setup by Agent
Cursor
Add to your project’s.cursor/mcp.json (or your global MCP settings):
context_query_status is missing after a deploy, refresh or restart the MCP server before testing long jobs.
Claude Code
OpenClaw / Claw Code
Add to your project’smcp.json or pass via CLI:
Any MCP Client (Generic)
Any client that supports Streamable HTTP transport can connect by pointing to:- URL:
https://www.ctxprotocol.com/api/mcp - Transport: Streamable HTTP
- Auth header:
Authorization: Bearer sk_live_YOUR_KEY
Mcp-Session-Id header after initialization. Clients that support session persistence should send it back on subsequent requests.
Tools Reference
context_query
Ask a natural-language question and get a grounded answer powered by the full marketplace.| Parameter | Type | Required | Description |
|---|---|---|---|
question | string | Yes | The question to answer (1–4000 chars) |
agentModelId | string | No | Advanced: choose the main librarian agent model for the merged execution/final-response loop |
responseShape | string | No | answer_with_evidence (default) or evidence_only. See Answer vs evidence |
toolIds | string[] | No | Restrict query to specific tool UUIDs (Manual Mode). Omit for Auto Mode discovery and selection |
favoritesOnly | boolean | No | Override the account-level Favorites-Only Auto Mode for this request |
includeData | boolean | No | Include bounded execution data inline. Large payloads return a preview plus full-data references |
includeDataUrl | boolean | No | Persist the full execution data and return a URL, keeping large payloads out of your context window. Defaults to true in the ctxprotocol MCP tool |
includeDeveloperTrace | boolean | No | Include a machine-readable runtime trace (tool selection, retries, loops) for debugging |
The runtime auto-selects execution depth and the internal tool-selection model per request.
agentModelId is optional and controls the main librarian loop only; most callers can omit it. MCP clients can inspect the agentModelId schema enum to see valid slugs. When omitted, the managed default is kimi-k2.6-model (same as DEFAULT_AGENT_MODEL_ID in the SDK).Use the context_query tool to answer: “What are the top Polymarket markets by volume right now?”The response includes the answer text, structured evidence, and metadata. For long jobs,
context_query may return a jobId before the answer is ready. Poll context_query_status with that exact jobId; do not call context_query again for the same question unless you want to start a duplicate paid query.
If the API key owner enables Favorites-Only Auto Mode in Settings,
context_query and context_discover inherit that account default automatically. Pass favoritesOnly: true or favoritesOnly: false on a single MCP call to override it. If you pass explicit toolIds to context_query, manual tool selection wins and favorites filtering is ignored.Auto Mode vs Manual Mode
context_query is the default one-call product surface:
- Auto Mode: omit
toolIds. The runtime runs marketplace discovery, selects tools with its managed selector, executes the librarian loop, and returns grounded output. - Named-provider Auto Mode: if a normal natural-language question names providers or venues, keep those names in the
questiontext and still omittoolIds. For example, “using Crypto Positioning and Crypto Data” should usually stay Auto Mode unless the user explicitly asks to pin tools. - Manual Mode: pass
toolIdsfromcontext_discoveronly when you explicitly want to pin/inspect tools or bypass broad marketplace selection. The runtime skips broad marketplace selection and runs the same librarian loop using only those tools. - Agent-driven mode: use
context_discover+context_executeonly when your host agent wants to drive exact method calls and synthesis itself.
Async Query Jobs
Some marketplace questions are slow: multi-tool analysis, chart generation, long historical windows, large data exports, and code-interpreter post-processing can exceed an MCP host’s direct tool-call window. Context handles this with durable query jobs: the backend librarian runtime keeps running discovery, tool calls, Python/code-interpreter work, chart generation, grounding, and synthesis after the initial MCP call returns ajobId.
This is the same managed Query runtime, not a lightweight background fetch. The jobId is just the handle your MCP client uses while Context continues the long-running work server-side.
| Tool | When to use | Next step |
|---|---|---|
context_query | Default natural-language workflow | If it returns an answer, use it. If it returns jobId, call context_query_status |
context_query_start | You know the job is complex and want a handle immediately | Call context_query_status |
context_query_status | You have a jobId | Poll until completed or failed |
Answer vs evidence
responseShape controls whether Context adds a prose synthesis layer on top of the grounded result. Both shapes run the same managed runtime (discover, select, execute, ground); they differ only in what comes back.
| Shape | Returns | Use when |
|---|---|---|
answer_with_evidence (default) | A written answer plus structured evidence, summary, artifacts, freshness, confidence, and usage | You want a ready-to-read answer, or chat-parity output |
evidence_only | Bounded evidence, optional bounded data, computedArtifacts, and full-data references with no prose | Your own agent (Cursor, Claude Code) is the synthesizer and wants grounded facts plus artifact/data handles |
evidence_only, unbounded raw data is not returned inline by default. Use the default evidence envelope and computedArtifacts inline, then fetch the full dataset from dataUrl/artifacts.canonicalDataRef when needed. If you set includeData: true, large payloads are still capped and returned as a truncation preview.
The full machine-readable payload is always in the MCP
structuredContent field. The text content mirrors it, so hosts that only forward text still receive the evidence. If the response includes chart artifacts, the text content also includes markdown image links so agents can surface the charts to users.Ambiguity And Capability Misses
When a request is ambiguous, the runtime answers with its best grounded assumption rather than blocking and may includeassumptionMade in structuredContent. If no marketplace tool can satisfy the request, the response uses outcomeType: "capability_miss" with a typed capabilityMiss payload and suggested rewrites.
context_execute
Call a specific tool method with explicit arguments. Useful when your agent already knows which tool it wants. Usecontext_discover with mode: "execute" before calling context_execute. Methods surfaced by context_query grounding or query-mode discovery are not necessarily direct-execute eligible.
| Parameter | Type | Required | Description |
|---|---|---|---|
toolId | string (UUID) | Yes | The marketplace tool ID |
toolName | string | Yes | The method name to call |
args | object | No | Arguments for the method |
sessionId | string (UUID) | No | Execution session for spend tracking |
maxSpendUsd | string | No | Cap spend for this session |
closeSession | boolean | No | Close the execution session after this call |
context_discover
Search the marketplace to find tools before querying or executing.context_discover is free marketplace retrieval. It returns tool IDs plus mcpTools method metadata, but it does not run the managed selector used by context_query Auto Mode. Use it for catalog inspection, Manual Mode pinning, or direct execution prep. Do not call it first for a normal question just because the question mentions a provider name.
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | No | Search term |
limit | number | No | Max results (1–20, default 10) |
mode | "query" | "execute" | No | Filter by mode |
favoritesOnly | boolean | No | Override the account-level Favorites-Only Auto Mode for this request |
Example Workflows
Simple Q&A (Auto Mode)
Tell your agent:Use context_query to find out which Kalshi markets have the highest open interest today.The runtime discovers relevant tools, handles execution end-to-end, and returns a complete answer.
Pinned Tools (Manual Mode)
For more control, first callcontext_discover, choose the relevant tool IDs, then call context_query with toolIds. Context still handles execution, grounding, and response assembly, but it stays within your pinned tool shortlist.
Use this only when pinning is intentional. If the user simply asks “using Crypto Positioning and Crypto Data” as part of a natural-language analysis request, put that provider constraint in the question and keep Auto Mode.
Recurring Agent Routine
For daily reports, alerts, and repeated analyst jobs:- Start with Auto Mode
context_queryto find a good question shape. - Capture a Routine Recipe from the terminal structured result, including the exact question, assumptions, and
toolsUsednames and IDs. Do not fetchdataUrljust to find tool IDs. - Switch to
responseShape: "evidence_only"andincludeDataUrl: truewhen your host agent writes the report. - Pin saved
toolsUsedIDs astoolIdsincontext_querywhen the routine should stay within the same tool shortlist. - Use
context_executeonly ifcontext_discoverwithmode: "execute"returns an eligible method.
examples/client/src/agent-routine.ts in the examples/client package.
For Crypto Data order-flow routines, it is normal for Execute discovery to return no eligible methods. In that case, keep the routine on pinned Query with responseShape: "evidence_only" and includeDataUrl: true.
Discovery -> Execute (agent-driven loop)
For full control, your agent can:- Call
context_discoverwith a search query - Inspect the returned tools and methods
- Call
context_executewith the chosen tool and arguments - Synthesize the structured result into an answer
Pricing
MCP requests use the same pricing as the SDK:- Query: pay-per-response (selector model + agent model + invoked tool costs)
- Execute: pay-per-call (method-level pricing set by tool builders)
- Discover: free
Troubleshooting
401 Unauthorized
401 Unauthorized
Tools not appearing in Cursor
Tools not appearing in Cursor
Check that
mcp.json is valid JSON and the url field points to https://www.ctxprotocol.com/api/mcp. Restart Cursor after saving.Session expired
Session expired
Sessions expire after 30 minutes of inactivity. Your MCP client will re-initialize automatically on the next request.
Query returns capability_miss
Query returns capability_miss
No marketplace tool can satisfy the request. Rephrase to target a supported venue or capability, or check the suggested rewrites in the response.

