Skip to main content
Glama

Get Symbols Overview

get_symbols_overview
Read-only

Analyze code files to identify top-level symbols and their structure, providing a quick overview for understanding new codebases or files.

Instructions

Use this tool to get a high-level understanding of the code symbols in a file. This should be the first tool to call when you want to understand a new file, unless you already know what you are looking for. Returns a JSON object containing info about top-level symbols in the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relative_pathYesThe relative path to the file to get the overview of.
depthNoDepth up to which descendants of top-level symbols shall be retrieved (e.g. 1 retrieves immediate children). Default 0.
max_answer_charsNoIf the overview is longer than this number of characters, no content will be returned. -1 means the default value from the config will be used. Don't adjust unless there is really no other way to get the content required for the task.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The apply method implements the core logic of the 'get_symbols_overview' tool. It validates the file path, retrieves the symbol overview using the LanguageServerSymbolRetriever, converts to JSON, and limits the response length.
    class GetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead):
        """
        Gets an overview of the top-level symbols defined in a given file.
        """
    
        def apply(self, relative_path: str, depth: int = 0, max_answer_chars: int = -1) -> str:
            """
            Use this tool to get a high-level understanding of the code symbols in a file.
            This should be the first tool to call when you want to understand a new file, unless you already know
            what you are looking for.
    
            :param relative_path: the relative path to the file to get the overview of
            :param depth: depth up to which descendants of top-level symbols shall be retrieved
                (e.g. 1 retrieves immediate children). Default 0.
            :param max_answer_chars: if the overview is longer than this number of characters,
                no content will be returned. -1 means the default value from the config will be used.
                Don't adjust unless there is really no other way to get the content required for the task.
            :return: a JSON object containing info about top-level symbols in the file
            """
            symbol_retriever = self.create_language_server_symbol_retriever()
            file_path = os.path.join(self.project.project_root, relative_path)
    
            # The symbol overview is capable of working with both files and directories,
            # but we want to ensure that the user provides a file path.
            if not os.path.exists(file_path):
                raise FileNotFoundError(f"File or directory {relative_path} does not exist in the project.")
            if os.path.isdir(file_path):
                raise ValueError(f"Expected a file path, but got a directory path: {relative_path}. ")
            result = symbol_retriever.get_symbol_overview(relative_path, depth=depth)[relative_path]
            result_json_str = self._to_json(result)
            return self._limit_length(result_json_str, max_answer_chars)
  • The ToolRegistry automatically discovers and registers all subclasses of Tool in the serena.tools package, including GetSymbolsOverviewTool under the name 'get_symbols_overview'.
    for cls in iter_subclasses(Tool):
        if not any(cls.__module__.startswith(pkg) for pkg in tool_packages):
            continue
        is_optional = issubclass(cls, ToolMarkerOptional)
        name = cls.get_name_from_cls()
        if name in self._tool_dict:
            raise ValueError(f"Duplicate tool name found: {name}. Tool classes must have unique names.")
        self._tool_dict[name] = RegisteredTool(tool_class=cls, is_optional=is_optional, tool_name=name)
  • Generates FuncMetadata from the apply method's signature and docstring, which is used to define the MCP tool schema for input parameters and description.
    def get_apply_fn_metadata_from_cls(cls) -> FuncMetadata:
        """Get the metadata for the apply method from the class (static metadata).
        Needed for creating MCP tools in a separate process without running into serialization issues.
        """
        # First try to get from __dict__ to handle dynamic docstring changes
        if "apply" in cls.__dict__:
            apply_fn = cls.__dict__["apply"]
        else:
            # Fall back to getattr for inherited methods
            apply_fn = getattr(cls, "apply", None)
            if apply_fn is None:
                raise AttributeError(f"apply method not defined in {cls}. Did you forget to implement it?")
    
        return func_metadata(apply_fn, skip_names=["self", "cls"])
  • Derives the MCP tool name 'get_symbols_overview' from the class name 'GetSymbolsOverviewTool' by removing 'Tool' suffix and converting to snake_case.
    @classmethod
    def get_name_from_cls(cls) -> str:
        name = cls.__name__
        if name.endswith("Tool"):
            name = name[:-4]
        # convert to snake_case
        name = "".join(["_" + c.lower() if c.isupper() else c for c in name]).lstrip("_")
        return name
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false, indicating a safe read operation. The description adds valuable context beyond this by specifying that it returns 'a JSON object containing info about top-level symbols in the file,' which clarifies the output format. However, it doesn't mention potential limitations like rate limits or error conditions, leaving some behavioral aspects uncovered.

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?

The description is efficiently structured in three sentences: the first states the purpose, the second provides usage guidelines, and the third describes the return format. Each sentence adds essential value without redundancy, making it front-loaded and appropriately concise for the tool's complexity.

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?

Given the tool's moderate complexity, rich annotations (readOnlyHint, destructiveHint), 100% schema coverage, and the presence of an output schema, the description is complete enough. It covers purpose, usage context, and output format, leaving detailed parameter and return value documentation to the structured fields, which is appropriate for this setup.

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 fully documents all three parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain 'relative_path' context or 'depth' implications further). This meets the baseline of 3 since the schema carries the full burden, but the description doesn't compensate with extra insights.

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 ('get a high-level understanding of the code symbols in a file') and resource ('file'), distinguishing it from sibling tools like 'find_symbol' or 'read_file' by focusing on symbol overview rather than searching or raw content. It explicitly positions this as the first tool for understanding new files, making its purpose distinct and well-defined.

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?

The description provides explicit guidance on when to use this tool ('first tool to call when you want to understand a new file') and when not to ('unless you already know what you are looking for'), effectively differentiating it from alternatives like 'find_symbol' for targeted searches. This clear contextual advice helps the agent choose appropriately among siblings.

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/oraios/serena'

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