Skip to main content
Glama

optimize_context_tool

When you need to understand how something works in a codebase, this tool returns only the essential source code relevant to your question, respecting a token budget to reduce context size.

Instructions

Return the most relevant REAL source code for a question, within a token budget.

Use this FIRST for any "how does X work / where is Y" question about the codebase, and prefer it over reading files or grepping. Call it ONCE per question: the returned optimized_context contains the relevant code — answer directly from it and do NOT separately read the files it came from (that defeats the whole point of the token savings).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codebase_pathYes
queryYes
token_budgetNo
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description does a good job disclosing behavior: it returns relevant code within a token budget, warns against separate file reading, and implies a read-only operation. It does not mention authorization needs or rate limits, but for a read-only tool, the transparency is adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (about 60 words) and front-loaded with the main purpose. Each sentence adds value: purpose, usage guidance, and a prohibition. No unnecessary words, though it could be structured slightly better.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers the main functionality and usage well, but lacks parameter descriptions, return format details beyond mentioning optimized_context, and differentiation from several very similar sibling tools (optimize_context_batch, stream, structured). Given no output schema, some return info would help.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning no parameter descriptions exist. The description mentions 'token budget' but does not explain the parameters (codebase_path, query, token_budget) beyond their names. It adds minimal value beyond the schema parameter names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it returns the most relevant source code within a token budget, uses a specific verb ('Return'), and distinguishes from alternatives like reading files or grepping. It also provides context about when to use it (for 'how does X work / where is Y' questions).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly instructs to use this tool first for codebase questions, prefer it over file reading/grepping, and call it once per question. It also tells the assistant not to separately read the files. However, it does not compare with similar sibling tools like optimize_context_batch or optimize_context_structured.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/likhithreddy/fittok'

If you have feedback or need assistance with the MCP directory API, please join our Discord server