Skip to main content
Glama

add_method

Add a method to an existing class in code files using AST-based editing for precise modifications.

Instructions

Add a new method at the end of a class body.

Use this when: You're adding a method to an existing class. Don't use this when: You're adding a field/attribute -> use add_field. You're adding a top-level function (not inside a class) -> use add_top_level.

Example: class_target="LRUCache" content=' def clear(self):\n self.items.clear()'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
class_targetYes
contentYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior3/5

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

No annotations are provided, so the description carries full burden. It describes the action (adding a method to a class) and placement ('at the end'), but lacks details about permissions, error handling, or what happens if the class doesn't exist. The example helps but doesn't fully compensate for missing behavioral context.

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?

Well-structured with purpose statement, usage guidelines, and example in just a few sentences. Every sentence adds value without redundancy. The information is front-loaded with the core purpose immediately stated.

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?

Given 3 parameters with 0% schema coverage and no annotations, the description does well with usage guidelines and example, but lacks full parameter documentation and behavioral details. The presence of an output schema helps, but more context about the mutation's effects would improve completeness.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate. The example illustrates usage of class_target and content parameters, providing semantic meaning beyond the schema's titles. However, file_path parameter remains unexplained in the description.

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 specific action ('Add a new method') and resource ('at the end of a class body'), distinguishing it from siblings like add_field and add_top_level. It precisely defines what the tool does without being vague or tautological.

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

Usage Guidelines5/5

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

Explicitly provides 'Use this when' and 'Don't use this when' guidance with named alternatives (add_field, add_top_level). This gives clear context for when to select this tool versus other available options.

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/kambleakash0/agent-skills'

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