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

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/5.0
Behavior4/5

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

Beyond the annotations (readOnlyHint=false, destructiveHint=false), it discloses that authorization is required, that AI credits are consumed, that a generation is created as a persistent side effect, and that revised code is returned. It does not say whether the generation is produced synchronously or must be fetched later via get-generation, which is a meaningful gap given the surrounding generation-lifecycle siblings.

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?

Two sentences, zero waste. The usage trigger is front-loaded and the behavioral facts are packed into the second sentence rather than spread across filler.

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?

With no output schema, the description correctly names the return value ("returns the revised code"), and the side effect plus credit cost are stated. It leaves open the async/polling question and any reversibility of the created generation, which an agent may need given archive-generation and get-generation siblings.

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%, so the schema already documents all five parameters including optimization_focus and additional_instructions. The description adds no parameter-level meaning beyond that, so the baseline 3 applies.

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

Purpose4/5

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

The description states a specific trigger and outcome: source code in, optimized/refactored code out. That distinguishes it from siblings like generate-code-comments, generate-code-tests, and generate-language-conversion, though it never names a sibling explicitly.

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?

"Use this when the user supplies source code and asks for an optimized or refactored version" gives a clear use condition. It does not state when NOT to use it or which sibling to prefer for overlapping requests (e.g., language conversion), so it stops short of full routing guidance.

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.