Workflow · Production

Cursor's dynamic context discovery reduces agent token usage by 46.9% for MCP tool runs

The problem

Coding agents using static context include all tool descriptions and long tool responses regardless of relevance, causing context bloat, potential data loss from truncation, and quality degradation after lossy summarization.

First attempt

Truncating long tool responses causes data loss, and statically including all MCP tool descriptions bloats the context window even though most tools go unused in any given run.

Workflow diagram · grounded in source
1
Long tool output written to file
integration
“we instead write the output to a file and give the agent the ability to read it. The agent calls tail to check the end, and then read more if it needs to.”
2
Chat history referenced post-summarization
ai_action
“we use the chat history as files to improve the quality of summarization. After the context window limit is reached, or the user decides to summarize manually, we give the agent a reference to the history file. If the agent knows that it…”
3
Agent Skills dynamically discovered
ai_action
“The agent can then do dynamic context discovery to pull in relevant skills, using tools like grep and Cursor's semantic search.”
4
MCP tools loaded on demand
ai_action
“we support dynamic context discovery for MCP by syncing tool descriptions to a folder. The agent now only receives a small bit of static context, including names of the tools, prompting it to look up tools when the task calls for it.”
5
Terminal sessions synced as files
integration
“Cursor now syncs the integrated terminal outputs to the local filesystem. Since terminal history can be long, the agent can grep for only the relevant outputs”
Reported outcome

Dynamic context discovery reduced total agent tokens by 46.9% for runs that called an MCP tool and resulted in fewer unnecessary summarizations, while giving the agent the ability to recover details from chat history after summarization.

Reported metrics
total agent tokens reduced for MCP tool runs46.9%
Unnecessary summarizationsfewer unnecessary summarizations
Reported stack
CursorMCPAgent Skillsgreptailsemantic search
Source
https://cursor.com/blog/dynamic-context-discovery
Read source ↗

Frequently asked questions

What did this team achieve with this AI workflow?

Dynamic context discovery reduced total agent tokens by 46.9% for runs that called an MCP tool and resulted in fewer unnecessary summarizations, while giving the agent the ability to recover details from chat history…

What tools did this team use?

Cursor, MCP, Agent Skills, grep, tail, semantic search.

What results were reported?

total agent tokens reduced for MCP tool runs: 46.9%; Unnecessary summarizations: fewer unnecessary summarizations (source-reported, not independently verified).

What failed first in this deployment?

Truncating long tool responses causes data loss, and statically including all MCP tool descriptions bloats the context window even though most tools go unused in any given run.

How is this workflow AI workflow structured?

Long tool output written to file → Chat history referenced post-summarization → Agent Skills dynamically discovered → MCP tools loaded on demand → Terminal sessions synced as files.