GetTypeInfo
Retrieve ABAP type metadata for domains, data elements, table types, and structures, including field definitions and value ranges.
Instructions
[read-only] Retrieve ABAP type information for domains (DOMA), data elements (DTEL), table types, and structures. Returns field definitions, value ranges, fixed values, and DDIC metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type_name | Yes | Name of the ABAP type | |
| include_structure_fallback | No | When true (default), tries DDIC structure lookup only if type lookup returns 404/empty. |
Implementation Reference
- Main handler function for GetTypeInfo tool. Accepts type_name and optional include_structure_fallback, tries multiple ADT endpoint lookups (domain, data element, table type, repository info system), and falls back to structure lookup. Returns JSON content with type metadata.
export async function handleGetTypeInfo(context: HandlerContext, args: any) { const { connection, logger } = context; const includeStructureFallback = args?.include_structure_fallback !== false; try { if (!args?.type_name) { throw new McpError(ErrorCode.InvalidParams, 'Type name is required'); } } catch (error) { logger?.error('Invalid parameters for GetTypeInfo', error as any); // MCP-compliant error response: always return content[] with type "text" return { isError: true, content: [ { type: 'text', text: `ADT error: ${String(error)}`, }, ], }; } try { const typeName = args.type_name; const encodedTypeName = encodeSapObjectName(typeName); const uri = encodeURIComponent( `/sap/bc/adt/ddic/domains/${typeName.toLowerCase()}`, ); const lookups: Array<{ label: string; url: string; parseFn: (xml: string) => any; }> = [ { label: 'domain', url: `/sap/bc/adt/ddic/domains/${encodedTypeName}/source/main`, parseFn: parseTypeInfoXml, }, { label: 'data element', url: `/sap/bc/adt/ddic/dataelements/${encodedTypeName}`, parseFn: parseTypeInfoXml, }, { label: 'table type', url: `/sap/bc/adt/ddic/tabletypes/${encodedTypeName}`, parseFn: parseTypeInfoXml, }, { label: 'repository information system', url: `/sap/bc/adt/repository/informationsystem/objectproperties/values?uri=${uri}`, parseFn: parseTypeInfoXml, }, ]; for (const lookup of lookups) { logger?.debug(`Trying ${lookup.label} lookup for ${typeName}`); const result = await tryLookup(connection, lookup.url, lookup.parseFn); if (result.status === 'ok') { const mcpResult = { isError: false, content: [{ type: 'json', json: result.payload }], }; objectsListCache.setCache(mcpResult); return mcpResult; } } if (includeStructureFallback) { logger?.debug( `Type lookups returned 404/empty for ${typeName}, trying structure fallback`, ); const structureResult = await tryLookup( connection, `/sap/bc/adt/ddic/structures/${encodedTypeName}`, parseStructureInfoXml, ); if (structureResult.status === 'ok') { const mcpResult = { isError: false, content: [{ type: 'json', json: structureResult.payload }], }; objectsListCache.setCache(mcpResult); return mcpResult; } } return { isError: true, content: [ { type: 'text', text: `Type ${typeName} was not found as domain, data element, table type, or structure.`, }, ], }; } catch (error) { logger?.error( `Failed to resolve type info for ${args.type_name}`, error as any, ); return { isError: true, content: [ { type: 'text', text: `ADT error: ${String(error)}`, }, ], }; } } - TOOL_DEFINITION export containing the tool name 'GetTypeInfo', description, and inputSchema with type_name (required string) and include_structure_fallback (optional boolean, default true).
export const TOOL_DEFINITION = { name: 'GetTypeInfo', available_in: ['onprem', 'cloud'] as const, description: '[read-only] Retrieve ABAP type information for domains (DOMA), data elements (DTEL), table types, and structures. Returns field definitions, value ranges, fixed values, and DDIC metadata.', inputSchema: { type: 'object', properties: { type_name: { type: 'string', description: 'Name of the ABAP type', }, include_structure_fallback: { type: 'boolean', description: 'When true (default), tries DDIC structure lookup only if type lookup returns 404/empty.', default: true, }, }, required: ['type_name'], }, } as const; - src/lib/handlers/groups/SystemHandlersGroup.ts:122-127 (registration)Registration of GetTypeInfo within SystemHandlersGroup.getHandlers(). Maps GetTypeInfo_Tool definition to handler wrapped with context.
getHandlers(): HandlerEntry[] { return [ { toolDefinition: GetTypeInfo_Tool, handler: (args: any) => handleGetTypeInfo(this.context, args), }, - src/lib/handlers/groups/SystemHandlersGroup.ts:61-64 (registration)Import of TOOL_DEFINITION (as GetTypeInfo_Tool) and handleGetTypeInfo from the handler file.
import { TOOL_DEFINITION as GetTypeInfo_Tool, handleGetTypeInfo, } from '../../../handlers/system/readonly/handleGetTypeInfo'; - Helper functions parseTypeInfoXml and parseStructureInfoXml that parse ADT XML responses for domains, data elements, table types, and structures.
function parseTypeInfoXml(xml: string) { const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: '', parseAttributeValue: true, trimValues: true, }); const result = parser.parse(xml); // Data Element (DTEL/DE) if (result['blue:wbobj']?.['dtel:dataElement']) { const wb = result['blue:wbobj']; const dtel = wb['dtel:dataElement']; return { name: wb['adtcore:name'], objectType: 'data_element', description: wb['adtcore:description'], dataType: dtel['dtel:dataType'], length: parseInt(dtel['dtel:dataTypeLength'], 10), decimals: parseInt(dtel['dtel:dataTypeDecimals'], 10), domain: dtel['dtel:typeName'], package: wb['adtcore:packageRef']?.['adtcore:name'] || null, labels: { short: dtel['dtel:shortFieldLabel'], medium: dtel['dtel:mediumFieldLabel'], long: dtel['dtel:longFieldLabel'], heading: dtel['dtel:headingFieldLabel'], }, }; } // Domain (DOMA/DD) via repository informationsystem if (result['opr:objectProperties']?.['opr:object']) { const obj = result['opr:objectProperties']['opr:object']; return { name: obj.name, objectType: 'domain', description: obj.text, package: obj.package, type: obj.type, }; } // Table Type (not implemented, fallback) return { raw: result }; } function parseStructureInfoXml(xml: string) { const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: '', parseAttributeValue: true, trimValues: true, }); const result = parser.parse(xml); const wb = result['blue:wbobj'] || {}; return { name: wb['adtcore:name'] || null, objectType: 'structure', description: wb['adtcore:description'] || null, package: wb['adtcore:packageRef']?.['adtcore:name'] || null, resolved_as: 'structure_fallback', raw: result, }; }