Skip to main content
Glama

add_import

Add an import statement to a source file, skipping exact duplicates. Places new imports after existing ones or at the top if none exist.

Instructions

Add an import statement to a source file. Skips exact duplicates. Places new imports after existing ones, or at the top of the file if none exist.

Use this when: You need to import something the file does not already reference. Don't use this when: You're adding a single name to an existing multi-name import statement like from X import a, b -> use add_import_name.

Example: import_text="from typing import Optional" # Python import_text="import { readFile } from 'fs';" # JS/TS import_text="#include <stdlib.h>" # C/C++

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
import_textYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Discloses key behaviors: duplicate skipping, placement after existing imports, and supports multiple languages via examples. Lacks mention of file modification guarantee or permissions, but given no annotations, it is quite transparent.

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?

Well-structured with sections for when to use, when not, and examples. Could be slightly more concise, but overall efficient and easy to parse.

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?

Covers usage, behavior, and alternatives. With no output schema details in description but presence of output schema noted, the description is nearly complete. Could mention return behavior for completeness.

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 coverage is 0%, so description must explain parameters. While import_text is illustrated with examples, file_path is not explicitly described. The examples partially compensate, but direct parameter descriptions are missing.

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 adds import statements to source files, skips duplicates, and specifies placement. It explicitly distinguishes from the sibling add_import_name by describing when to use each.

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?

Provides explicit 'Use this when' and 'Don't use this when' guidelines, including a direct reference to the alternative tool add_import_name for multi-name imports. This helps the agent decide correctly.

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/ast-editor'

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