Skip to main content
Glama

add_top_level

Append top-level code like functions, classes, or constants to the end of a file using AST-based editing for precise modifications.

Instructions

Append arbitrary top-level content to the end of the file: a function, class, constant, type alias, or any other top-level statement.

Use this when: You're adding any kind of top-level code at the end of a module. Don't use this when: You need placement relative to another symbol -> use insert_before/insert_after. You're adding to a class body -> use add_method/add_field. You're adding a line inside an existing function body -> use prepend_to_body/append_to_body.

Example: content="def parse_version(text):\n return tuple(int(x) for x in text.split('.'))" content="class Logger:\n pass" content="MAX_CONNECTIONS = 10"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
contentYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

With no annotations provided, the description carries full burden. It clearly indicates this is a write operation ('Append'), specifies the location ('end of the file'), and describes what gets modified. However, it doesn't mention potential side effects like file creation if non-existent, error handling, or formatting behavior, leaving some behavioral aspects uncovered.

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 efficiently structured with a clear purpose statement, usage guidelines, and concrete examples. Every sentence adds value: the first defines the tool, the next two provide usage rules, and the examples illustrate parameter usage without redundancy.

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 this is a write operation with no annotations and 0% schema description coverage, the description does well by explaining purpose, usage context, and parameter semantics through examples. However, since there's an output schema (which handles return values), the description appropriately focuses on behavioral context rather than output details, making it reasonably complete for the tool's complexity.

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?

Schema description coverage is 0%, so the description must compensate. It provides meaningful context for the 'content' parameter through examples showing valid content types (function, class, constant definitions). However, it doesn't explain the 'file_path' parameter's format or constraints, leaving one of the two parameters only documented in the schema's basic type information.

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 ('Append arbitrary top-level content to the end of the file') and resource ('file'), with explicit examples of what constitutes top-level content (function, class, constant, type alias). It distinguishes this tool from siblings by contrasting with insert_before/insert_after for relative placement and add_method/add_field for class bodies.

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?

The description provides explicit 'Use this when' and 'Don't use this when' guidance, naming specific alternative tools (insert_before/insert_after, add_method/add_field, prepend_to_body/append_to_body) for different scenarios. This gives clear context for when to choose this tool versus its siblings.

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