> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-in-ai/concepts/token-efficiency.md).

# Token Efficiency

Managing token usage and MCP tool context to reduce cost and improve agent performance.

Token efficiency is the practice of controlling how many tokens your agent sends to the LLM on each interaction. Efficient token usage reduces cost, speeds up responses, and improves answer quality.

## Why Tokens Accumulate in Agent Sessions

LLMs are stateless. When you work with an agent, the agent sends the full session context to the LLM. The full session context includes message history, tool definitions, and injected system data.

For more on why context composition matters, see [Context Engineering](https://docs.umbraco.com/umbraco-in-ai/concepts/context-engineering.md).

Each tool added to an MCP server contributes to this context. By default, every registered tool adds its schema, description, and metadata to every request. A large tool set inflates token usage and drives up cost.

## Active Context Management

Some platforms address this problem with active context management. The platform loads only the tools needed for the current task, rather than all registered tools.

Claude Code applies this pattern with its MCP tool search feature. The agent queries to find tools relevant to the current task, then loads only those tools into the active context.

## Manual Tool Management

If your platform does not support active context management, you **must manually engineer** the context to get the most efficient session. You do this through environment variables when starting the MCP server, choosing which tools are exposed to the agent.

The environment variables are the same across all Umbraco MCP servers. See [Tool Filtering](https://docs.umbraco.com/umbraco-in-ai/mcp/custom-mcp-server/sdk/tool-filtering.md) for the full list of filtering options.

{% hint style="warning" %}
If your platform does not manage context and you do not filter tools, token usage grows quickly. Costs rise and subscription limits are reached sooner.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-in-ai/concepts/token-efficiency.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
