GetPackageContents
Retrieve objects inside an ABAP package as a flat list. Supports recursive traversal of subpackages with configurable depth and inclusion of descriptions.
Instructions
[read-only] Retrieve objects inside an ABAP package as a flat list. Supports recursive traversal of subpackages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package_name | Yes | Name of the ABAP package (e.g., "ZMY_PACKAGE") | |
| include_subpackages | No | Include contents of subpackages recursively (default: false) | |
| max_depth | No | Maximum depth for recursive package traversal (default: 5) | |
| include_descriptions | No | Include object descriptions in response (default: true) |
Implementation Reference
- Main handler function for the GetPackageContents tool. Validates input (package_name required), creates an ADT client, calls getPackageContentsList with the provided parameters (including subpackages, max depth, descriptions), and returns the result as JSON text.
export async function handleGetPackageContents( context: HandlerContext, args: GetPackageContentsArgs, ) { const { connection, logger } = context; try { if (!args?.package_name) { throw new McpError(ErrorCode.InvalidParams, 'Package name is required'); } const client = createAdtClient(connection, logger); const utils = client.getUtils(); // Use the optimized list method from adt-clients 0.3.13 const items = await utils.getPackageContentsList( args.package_name.toUpperCase(), { includeSubpackages: args.include_subpackages, maxDepth: args.max_depth, includeDescriptions: args.include_descriptions, }, ); const finalResult = { isError: false, content: [ { type: 'text', text: JSON.stringify(items, null, 2), }, ], }; if (args.filePath) { writeResultToFile(JSON.stringify(finalResult, null, 2), args.filePath); } return finalResult; } catch (error) { return { isError: true, content: [ { type: 'text', text: error instanceof Error ? error.message : String(error), }, ], }; } } - Schema/tool definition for GetPackageContents. Defines tool name, availability (onprem, cloud, legacy), description, and input schema with zod validators for package_name (required), include_subpackages (optional boolean), max_depth (optional number), and include_descriptions (optional boolean).
export const TOOL_DEFINITION = { name: 'GetPackageContents', available_in: ['onprem', 'cloud', 'legacy'] as const, description: '[read-only] Retrieve objects inside an ABAP package as a flat list. Supports recursive traversal of subpackages.', inputSchema: { package_name: z .string() .describe('Name of the ABAP package (e.g., "ZMY_PACKAGE")'), include_subpackages: z .boolean() .optional() .describe('Include contents of subpackages recursively (default: false)'), max_depth: z .number() .optional() .describe('Maximum depth for recursive package traversal (default: 5)'), include_descriptions: z .boolean() .optional() .describe('Include object descriptions in response (default: true)'), }, } as const; - src/lib/handlers/groups/ReadOnlyHandlersGroup.ts:57-60 (registration)Import of the GetPackageContents tool definition and handler into the ReadOnlyHandlersGroup.
import { TOOL_DEFINITION as GetPackageContents_Tool, handleGetPackageContents, } from '../../../handlers/package/readonly/handleGetPackageContents'; - src/lib/handlers/groups/ReadOnlyHandlersGroup.ts:153-156 (registration)Registration of GetPackageContents as a handler entry in the ReadOnlyHandlersGroup, wiring the tool definition to the handler function with context injection.
{ toolDefinition: GetPackageContents_Tool, handler: (args: any) => handleGetPackageContents(this.context, args), },