Skip to main content
Glama

GetPackageTree

Retrieve the complete hierarchical tree of an ABAP package, including all subpackages and objects with their names, types, and descriptions.

Instructions

[high-level] Retrieve complete package tree structure including subpackages and objects. Returns hierarchical tree with object names, types, and descriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYesPackage name (e.g., "ZMY_PACKAGE")
include_subpackagesNoInclude subpackages recursively in the tree. If false, subpackages are shown as first-level objects but not recursively expanded. Default: true
max_depthNoMaximum depth for recursive package traversal. Default: 5
include_descriptionsNoInclude object descriptions in response. Default: true
debugNoInclude diagnostic metadata in response (counts, types, hierarchy info). Default: false

Implementation Reference

  • Main handler function for GetPackageTree tool. Validates package_name, creates ADT client, verifies package existence via client.getPackage().read(), fetches hierarchical tree via utils.getPackageHierarchy(), and returns formatted response with package tree data.
    export async function handleGetPackageTree(
      context: HandlerContext,
      args: GetPackageTreeArgs,
    ) {
      const { connection, logger } = context;
      try {
        // Validate required parameters
        if (!args?.package_name) {
          return return_error(new Error('package_name is required'));
        }
    
        const packageName = args.package_name.toUpperCase();
        const includeSubpackages = args.include_subpackages !== false;
        const maxDepth = args.max_depth || 5;
        const includeDescriptions = args.include_descriptions !== false;
    
        logger?.info(
          `Fetching package tree for ${packageName} (include_subpackages: ${includeSubpackages}, max_depth: ${maxDepth}) using adt-clients`,
        );
    
        const client = createAdtClient(connection, logger);
        const utils = client.getUtils();
    
        // Verify package exists before building tree (fixes #38)
        try {
          const readResult = await client.getPackage().read({ packageName });
          if (!readResult || !readResult.readResult) {
            return return_error(new Error(`Package ${packageName} not found`));
          }
        } catch (readError: any) {
          if (readError.response?.status === 404) {
            return return_error(new Error(`Package ${packageName} not found`));
          }
          throw readError;
        }
    
        // Use the optimized and fixed hierarchy builder from adt-clients
        const packageTree = await utils.getPackageHierarchy(packageName, {
          includeSubpackages,
          maxDepth,
          includeDescriptions,
        });
    
        if (!packageTree) {
          return return_error(
            new Error(`Failed to fetch package tree for ${packageName}`),
          );
        }
    
        logger?.debug(`Package tree fetched successfully for ${packageName}`);
    
        // Format response
        const response = {
          package_name: packageName,
          tree: packageTree,
          metadata: {
            include_subpackages: includeSubpackages,
            max_depth: maxDepth,
            include_descriptions: includeDescriptions,
          },
        };
    
        return return_response({
          data: JSON.stringify(response, null, 2),
        } as any);
      } catch (error: any) {
        logger?.error('Failed to fetch package tree', error);
        return return_error(error);
      }
    }
  • Tool definition and input schema for GetPackageTree. Defines name 'GetPackageTree', availability in onprem/cloud, and input properties: package_name (required string), include_subpackages (boolean, default true), max_depth (integer, default 5), include_descriptions (boolean, default true), debug (boolean, default false).
    export const TOOL_DEFINITION = {
      name: 'GetPackageTree',
      available_in: ['onprem', 'cloud'] as const,
      description:
        '[high-level] Retrieve complete package tree structure including subpackages and objects. Returns hierarchical tree with object names, types, and descriptions.',
      inputSchema: {
        type: 'object',
        properties: {
          package_name: {
            type: 'string',
            description: 'Package name (e.g., "ZMY_PACKAGE")',
          },
          include_subpackages: {
            type: 'boolean',
            description:
              'Include subpackages recursively in the tree. If false, subpackages are shown as first-level objects but not recursively expanded. Default: true',
            default: true,
          },
          max_depth: {
            type: 'integer',
            description:
              'Maximum depth for recursive package traversal. Default: 5',
            default: 5,
          },
          include_descriptions: {
            type: 'boolean',
            description: 'Include object descriptions in response. Default: true',
            default: true,
          },
          debug: {
            type: 'boolean',
            description:
              'Include diagnostic metadata in response (counts, types, hierarchy info). Default: false',
            default: false,
          },
        },
        required: ['package_name'],
      },
    } as const;
  • TypeScript interface GetPackageTreeArgs defining the typed input arguments for the handler.
    interface GetPackageTreeArgs {
      package_name: string;
      include_subpackages?: boolean;
      max_depth?: number;
      include_descriptions?: boolean;
      debug?: boolean;
    }
  • Registration of GetPackageTree in SystemHandlersGroup. Maps the TOOL_DEFINITION (aliased as GetPackageTree_Tool) to the handleGetPackageTree handler within the getHandlers() method, which is later registered on the MCP server via BaseHandlerGroup.registerHandlers().
    // High-level handler for package tree
    {
      toolDefinition: GetPackageTree_Tool,
      handler: (args: any) => {
        return handleGetPackageTree(
          this.context,
          args as {
            package_name: string;
            include_subpackages?: boolean;
            max_depth?: number;
            include_descriptions?: boolean;
          },
        );
      },
    },
Behavior2/5

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

No annotations are provided, so the description must cover behavioral traits. It lacks mention of read-only nature, potential performance impact, error behavior for missing packages, or any side effects.

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?

Two succinct sentences, front-loaded with the core purpose. Every sentence adds value without unnecessary detail.

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 5 parameters and no output schema, the description gives a high-level return description but does not elaborate on tree structure or parameter effects. It is adequate but not thorough.

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 baseline is 3. The description adds no additional meaning to the parameters beyond what the schema already provides.

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 retrieves the complete package tree structure including subpackages and objects, using specific verbs and resource. It distinguishes from sibling tools like GetPackage and GetPackageContents by focusing on hierarchical tree.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. With related siblings like GetPackage and GetPackageContents, explicit usage context is missing.

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/fr0ster/mcp-abap-adt'

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