Skip to main content
Glama

Optimize Source Code

generate-code-optimization

Use this when the user supplies source code and asks for an optimized or refactored version. After authorization, this state-changing action consumes AI credits, creates a generation, and returns the revised code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoOptional custom name used to identify the optimized code in generation history
filenameYesThe full file path of the file being optimized (e.g., src/utils/helper.ts)
source_codeYesThe source code to optimize
optimization_focusNoFocus area for optimization (default: Performance)
additional_instructionsNoAdditional instructions for code optimization

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Beyond the annotations (readOnlyHint=false, destructiveHint=false), the description discloses that the action is state-changing, consumes AI credits, creates a generation, and returns revised code. It also mentions 'After authorization,' adding a prerequisite. This provides valuable behavioral context not covered by annotations, though it does not detail error handling or reversibility, which are minor gaps.

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

Conciseness5/5

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

The description is two sentences long, with the usage condition front-loaded in the first sentence and behavioral details in the second. There is no filler or redundancy; every clause adds value. It is appropriately sized and structured.

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

Completeness4/5

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

For a tool with five parameters and no output schema, the description covers key aspects: when to use, side effects (credits, generation creation), and return value (revised code). It does not explicitly mention the format of the return or potential failure modes, but the schema covers parameters and the description gives enough context for an agent to invoke it correctly. Given the complexity, it is mostly complete.

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

Parameters3/5

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

Schema description coverage is 100%, with all parameters already described meaningfully (e.g., source_code, filename, optimization_focus). The tool description does not add any extra parameter semantics beyond what the schema provides. Since the schema covers parameters thoroughly, the baseline of 3 is appropriate.

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?

The description clearly states the tool's purpose: to generate an optimized or refactored version of supplied source code. It uses a specific verb ('optimize') and resource ('source code'), and explicitly distinguishes it from sibling tools by specifying the trigger condition: when the user asks for optimization/refactoring. This sets it apart from code-comments, tests, and documentation generators.

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?

The description opens with 'Use this when the user supplies source code and asks for an optimized or refactored version,' providing a clear condition for when to invoke it. It also mentions 'After authorization,' implying a prerequisite. However, it does not explicitly mention alternative tools or when not to use it, though the trigger is specific enough to avoid ambiguity among siblings.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources