MCP
MCP is powered by insight search, so your agent can query your production data with natural language and use that context to find root causes, fix issues, and optimize your agent.
Prerequisites#
- A Context Company account with at least one project sending data
- An MCP-compatible IDE or tool (Cursor, Claude Code, Windsurf, or any client that supports MCP)
Setup#
One-click install via OAuth — no API key needed. For CI, programmatic, or headless setups, see Advanced: API key below.
Claude Code:
claude mcp add --transport http context-company https://api.thecontext.company/mcpThen run claude, type /mcp, select context-company, and press Enter to complete the OAuth sign-in.
Cursor / other MCP clients:
{
"mcpServers": {
"context-company": {
"url": "https://api.thecontext.company/mcp"
}
}
}Sign in through your client's MCP connection UI to complete the OAuth flow.
Try it out:
Use The Context Company MCP to show me my last 5 production agent runs, including their status and cost.
Advanced: API key#
For CI, programmatic, or headless setups where OAuth isn't practical, authenticate with a read-only API key instead.
Cursor may ignore
Authorizationheaders when the MCP server advertises OAuth discovery — the OAuth flow above is recommended for Cursor. API keys still work for Claude Code, CI, and other programmatic or headless MCP clients.
Generate a read-only API key from the Access Data page in your dashboard (prefixed tcc_key, cannot ingest traces), choosing a Dev only / Prod only / Dev + Prod scope. Then:
claude mcp add --transport http context-company \
https://api.thecontext.company/mcp \
--header "Authorization: Bearer <your-api-key>"Available tools#
For most questions, insight_search is the right choice — a multi-step analytics agent with full SQL access to your telemetry that synthesizes evidence across runs, sessions, patterns, failures, and costs. The other tools fetch raw traces and lists, best used when you already have a specific ID or want a filtered list.
insight_search#
Ask natural-language questions about your production data including metrics, patterns, failures, sessions, costs, and more.
Insight search queries production data only and requires a Pro or Enterprise plan.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | Yes | A natural-language analytics question |
get_agent_runs#
Fetch a filtered raw list of runs for dev or prod. summary (default) returns compact runs with prompt/response previews; full_trace includes all steps and tool calls.
| Parameter | Type | Required | Description |
|---|---|---|---|
source |
dev | prod |
Yes | Data source to query |
timeRange |
string | No | last_5_minutes, last_hour, last_day, last_two_weeks, last_month, last_two_months |
from / to |
string | No | ISO 8601 timestamps, alternative to timeRange |
onlyErrored |
boolean | No | Return only errored runs |
metadata |
object | No | Exact custom metadata key/value filters |
agent |
string | No | Exact agent name filter |
userId |
string | No | Exact external user ID filter |
orgId |
string | No | Exact external org ID filter (customer's ID in your system, not TCC's) |
failureContains |
string | No | Substring match against error_class/status_message |
returnType |
summary | full_trace |
No | Level of detail |
session_id |
string | No | Filter to a specific session |
limit |
number | No | 1–25, default 10 |
get_agent_sessions#
Fetch a filtered list of sessions — same filters as get_agent_runs, matches when any run in the session qualifies.
get_agent_run#
Fetch the full raw trace of a single run by ID, including all steps and tool calls.
get_agent_session#
Fetch a specific production session by session ID. return_type: conversation (default, prompt/response only) or full_trace.
Example prompts#
Frustration debugging
Find the biggest reason users have been frustrated in my runs this past week. Look at my codebase to find the root cause and fix it.
Tool failure chains
Find runs where a tool call failed right after another tool succeeded. What's the most common pattern, and what in my code is causing it?
Cost optimization
Find my most expensive runs from the past week. Figure out which prompts or tool loops are driving up cost and suggest code changes to reduce token usage.
Redundant tool loops
Find runs where my agent called the same tool more than 3 times in a row. Is there a loop in my code causing redundant calls? Fix it.
Task failure improvement
Show me runs with task failure patterns. Compare what the user asked for vs what the agent did, and suggest how to improve my system prompt.
