Skip to main content
Glama

replace_docstring

Add or update Python docstrings for functions and classes without modifying the code body. This tool works exclusively with Python files by using AST-based editing to replace or insert documentation strings.

Instructions

Replace or insert a Python docstring on a function or class. Python-only. The new_docstring should be a valid Python string literal including its surrounding triple quotes.

Use this when: You want to add or update a Python docstring without touching the function body. Don't use this when: You're editing a # comment above the symbol -> use replace_leading_comment. You're in a non-Python file -> no equivalent tool.

Example: target="LRUCache.get" new_docstring=(triple-quoted string, e.g. with three double-quotes before and after the summary text)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
targetYes
new_docstringYes

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 core behavior (replacing/inserting docstrings) and mentions the Python-only constraint, but doesn't disclose potential side effects, error conditions, or what happens if the target doesn't exist. It provides basic behavioral context but lacks depth for a mutation tool.

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 four sentences. Every sentence adds value: the first states what it does, the second clarifies parameter format, the third/fourth provide clear usage boundaries. No wasted words.

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 mutation tool with no annotations, 3 parameters, and 0% schema coverage, the description does well with purpose, guidelines, and some parameter clarification. The existence of an output schema means return values don't need explanation. However, as a mutation tool, it could better address potential risks or error cases.

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. It explains 'target' with an example ('LRUCache.get') and clarifies that 'new_docstring' should be 'a valid Python string literal including its surrounding triple quotes' with an example. However, it doesn't mention 'file_path' at all, leaving one parameter undocumented.

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 ('Replace or insert'), resource ('Python docstring on a function or class'), and scope ('Python-only'). It distinguishes from sibling tools like 'replace_leading_comment' by specifying it's for docstrings, not comments.

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, naming the alternative tool ('replace_leading_comment') and specifying language constraints ('non-Python file -> no equivalent tool'). This gives clear context for when to choose this tool over others.

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