Skip to main content
Glama

get_enclosing_element

Identify the enclosing Java method, type, and package at a specific code position to understand code structure and context during analysis.

Instructions

Get the enclosing element at a position.

USAGE: Position anywhere in code OUTPUT: Enclosing method, type, and package info

IMPORTANT: Uses ZERO-BASED coordinates.

Requires load_project to be called first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to source file
lineYesZero-based line number
columnYesZero-based column number
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the zero-based coordinate system and the prerequisite of load_project. However, it doesn't mention error handling, performance implications, or what happens with invalid positions, leaving gaps in behavioral understanding for a tool with no annotation support.

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 well-structured with clear sections (purpose, usage, output, important note, prerequisite) and uses bullet-like formatting. Every sentence adds value, but it could be slightly more front-loaded by merging the first two lines. No wasted words, but minor structural tweaks could improve flow.

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

Completeness3/5

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

Given the tool's moderate complexity (position-based query with prerequisites), no annotations, and no output schema, the description does an adequate job. It covers purpose, usage, output format, coordinate system, and prerequisites. However, it lacks details on error cases, return format specifics, or performance notes, making it minimally complete but with room for improvement.

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 description coverage is 100%, so the schema already documents all three parameters (filePath, line, column) with descriptions. The description adds value by clarifying that coordinates are zero-based, which is crucial semantic context not in the schema. However, it doesn't explain parameter interactions or provide examples, so it meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get the enclosing element at a position' with additional context about what it returns ('method, type, and package info'). It distinguishes itself from siblings like get_field_at_position and get_method_at_position by focusing on the enclosing element rather than a specific element type. However, it doesn't explicitly contrast with all similar siblings, keeping it from a perfect score.

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 explicit usage context: 'Position anywhere in code' and 'Requires load_project to be called first.' This gives clear prerequisites and positional guidance. It doesn't explicitly state when NOT to use it or name alternatives among siblings (e.g., get_field_at_position for fields), so it falls 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.

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/pzalutski-pixel/javalens-mcp'

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