Skip to main content
Glama

use_function

Replace duplicate function bodies project-wide with calls to the selected function, using LSP coordinates and a dry-run preview to review changes before applying.

Instructions

Replace code that duplicates a function's body with calls to that function, across the whole project. Point at the name of a module-level function (0-based LSP line/character, UTF-16 units); statements matching its body pattern are rewritten into calls. Defaults to a Dry Run preview; set apply=true to write. Sites that cannot be proven to match are reported as uncertain_occurrences for you to adjudicate, never silently rewritten. Supply expected_symbol when edits may have intervened since your LSP answer, so a stale Position fails safely. Locate the function with your LSP first; this tool only changes code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
lineYes
rootNo
applyNo
characterYes
expected_symbolNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

With no annotations, the description carries full responsibility. It discloses the dry-run default, apply flag, project-wide scope, uncertain occurrence reporting, safe failure on stale positions, and the guarantee that sites are never silently rewritten. This is comprehensive behavioral disclosure.

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?

The description is a dense paragraph of six sentences, each adding meaningful details without redundancy. It is front-loaded with the core purpose and then explains safety mechanisms. Slightly long but appropriate for a complex tool.

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?

For a complex tool with 6 parameters and an output schema, the description covers the essential workflow, safety guarantees, and invocation details. The only minor omission is the 'root' parameter, but overall it is complete enough for an agent to use the tool correctly.

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?

The description explains the positional parameters (0-based LSP line/character, UTF-16 units), the apply flag, and expected_symbol's purpose. It does not explicitly describe 'root', leaving a small gap, but given 0% schema description coverage, it compensates well.

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 replaces duplicated function bodies with calls to that function across the project. It explicitly names the action and resource, and the closing 'this tool only changes code' distinguishes it from sibling refactoring tools.

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

Usage Guidelines4/5

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

The description provides clear context on when to use it (deduplication of matching code) and outlines the workflow: locate the function with LSP, point at it, dry run by default, apply to write. It does not explicitly list alternatives or when-not cases, but the context is sufficiently clear.

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/andrewesweet/ropey'

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