Skip to main content
Glama

add_top_level

Insert top-level declarations such as functions, classes, or constants into a file, with control over placement at the top (after imports) or bottom.

Instructions

Insert top-level content into the file: a function, class, constant, type alias, or any other top-level statement. position controls placement:

  • "bottom" (default): append to end of file.

  • "top": insert after the preamble (package/imports/includes/leading comments, plus the Python module docstring if present) and before the first real declaration.

Use this when: You're adding any kind of top-level code. Use position="top" when inserting multiple declarations at the top of a file without the insert_before <target> reverse-order problem. Don't use this when: You need placement relative to a specific 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", position="top" content="MAX_CONNECTIONS = 10", position="top"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
contentYes
positionNobottom

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Explains position parameter behavior with definitions for 'top' and 'bottom'. Missing explicit statement about file mutation, but context implies it; still solid given no annotations.

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?

Concise and well-structured with clear sections and examples. Slightly verbose with example duplication but overall efficient.

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

Completeness5/5

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

Covers all needed aspects for a tool with output schema: usage, exclusions, examples, and behavioral nuances. No gaps.

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

Parameters5/5

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

With 0% schema coverage, description fully explains all three parameters: file_path (implied), content (examples), position (two values and respective effects).

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 inserts top-level content like functions, classes, constants. It distinguishes from siblings like add_method, add_field, etc., by specifying scope.

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 when to use (any top-level code) and when not, with specific alternatives (insert_before/insert_after, add_method, prepend_to_body).

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