Skip to main content
Glama

extract_interface

Extract an interface from a Java class by choosing public methods, then generate the interface file and an edit adding an implements clause to the class.

Instructions

Extract an interface from a class containing selected public methods.

Returns the text for a new interface file and edits to add 'implements' clause to the original class. The interface imports each type its signatures name that it cannot see unimported, a member type by its canonical name (import pkg.Outer.Inner).

USAGE: Position on class, provide interface name, optionally specify methods OUTPUT: Interface file content and class modification edit

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

Input Schema

NameRequiredDescriptionDefault
lineYesZero-based line number of class declaration
columnYesZero-based column number
filePathYesPath to source file containing the class
methodNamesNoSpecific method names to include (default: all public non-static methods)
interfaceNameYesName for the new interface

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.4
  2. Removedv1.3.3
  3. First observedv1.2.0

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden and does so well: it discloses that a new interface file is produced and that the original class is edited with an 'implements' clause, plus import-handling rules and zero-based coordinates. It is slightly ambiguous about whether the class edit is applied automatically or merely returned.

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?

Purpose is front-loaded, then cleanly segmented with USAGE, OUTPUT, and IMPORTANT markers. The import-handling sentence is somewhat dense but earns its place by describing real behavior.

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?

For a refactoring tool with no annotations and no output schema, the description covers output shape ('Interface file content and class modification edit'), prerequisite, and coordinate convention. Only the apply-vs-return ambiguity for the class edit keeps it from being fully complete.

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 100%, so the schema already documents all five parameters including the default for methodNames. The description reinforces positioning and the default but adds no syntax or format detail beyond the schema, making the baseline 3 appropriate.

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?

States a specific verb+resource ('Extract an interface from a class containing selected public methods') and distinguishes itself from refactoring siblings like extract_method and extract_superclass. An agent can tell exactly what artifact is produced without opening the schema.

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 USAGE line gives concrete positioning ('Position on class, provide interface name, optionally specify methods') and the prerequisite 'Requires load_project to be called first' is spelled out. It does not name an explicit alternative refactoring to choose over this one, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.