Skip to main content
Glama
handleGetPackage.tsâ€ĸ2.26 kB
import { McpError, ErrorCode, AxiosResponse } from '../lib/utils'; import { makeAdtRequestWithTimeout, return_error, return_response, getBaseUrl } from '../lib/utils'; import convert from 'xml-js'; import { writeResultToFile } from '../lib/writeResultToFile'; import * as z from 'zod'; export const TOOL_DEFINITION = { name: "GetPackage", description: "Retrieve ABAP package details.", inputSchema: { package_name: z.string().describe("Name of the ABAP package") } } as const; export async function handleGetPackage(args: any) { try { if (!args?.package_name) { throw new McpError(ErrorCode.InvalidParams, 'Package name is required'); } const nodeContentsUrl = `${await getBaseUrl()}/sap/bc/adt/repository/nodestructure`; const nodeContentsParams = { parent_type: "DEVC/K", parent_name: args.package_name, withShortDescriptions: true }; const package_structure_response = await makeAdtRequestWithTimeout(nodeContentsUrl, 'POST', 'default', undefined, nodeContentsParams); const result = convert.xml2js(package_structure_response.data, {compact: true}); const nodes = result["asx:abap"]?.["asx:values"]?.DATA?.TREE_CONTENT?.SEU_ADT_REPOSITORY_OBJ_NODE || []; const extractedData = (Array.isArray(nodes) ? nodes : [nodes]).filter(node => node.OBJECT_NAME?._text && node.OBJECT_URI?._text ).map(node => ({ OBJECT_TYPE: node.OBJECT_TYPE._text, OBJECT_NAME: node.OBJECT_NAME._text, OBJECT_DESCRIPTION: node.DESCRIPTION?._text, OBJECT_URI: node.OBJECT_URI._text })); const finalResult = { isError: false, content: [{ type: 'text', text: JSON.stringify(extractedData, 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) }] }; } }

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