Skip to main content
Glama

read_enclosing

Read-only

Locate the function, method, or class that contains a given line number in a file. Supports nesting depth to retrieve parent definitions for better code navigation.

Instructions

Find the enclosing function or class for a specific line number.

Given a file and line number, returns the complete enclosing definition (function, method, class, struct, etc.) containing that line. Use depth=2 to get the parent definition (e.g., the class containing a method). Falls back to a centered context window for unsupported languages or top-level code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
absolute_file_pathYesAbsolute path to target file
lineYesLine number to find the enclosing function/class for
depthNoNesting depth: 1 = innermost definition, 2 = parent (e.g., class containing a method)
context_linesNoLines of context for fallback window when no enclosing definition is found
Behavior5/5

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

Annotations already indicate read-only and non-destructive. The description adds valuable behavioral details: the depth parameter's effect and the fallback to a centered context window for unsupported languages or top-level code. No contradictions.

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?

Three sentences, each earning its place. The first states the core purpose, the second provides usage details, and the third covers fallback behavior. No redundant information.

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?

While the purpose is clear, the description does not specify the return value format, and there is no output schema. For a tool that returns a 'complete enclosing definition', the agent would benefit from knowing what fields (e.g., name, type, line range) are included.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, and the description adds meaningful guidance beyond the schema: it explains the use of depth=2 for parent definitions and describes context_lines as fallback-related. This enriches the agent's understanding of parameter usage.

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 finds the enclosing function or class for a specific line number, with a specific verb ('Find') and resource ('enclosing function or class'). It distinguishes from siblings like read_content by focusing on code structure rather than raw file content.

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 explains when to use the tool (given a file and line), how to use depth for parent definitions, and the fallback behavior for unsupported languages. It does not explicitly explain when not to use this tool, but the context is clear enough.

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/peteretelej/largefile'

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