get-entity-schema
Retrieve detailed schema information for SAP OData entities, including properties, types, keys, and constraints to understand data structure.
Instructions
Get detailed schema information for a specific entity including properties, types, keys, and constraints.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serviceId | Yes | The SAP service ID | |
| entityName | Yes | The entity name |
Implementation Reference
- Zod input validation schema for the get-entity-schema tool defining serviceId, entityName, and optional flagsexport const EntitySchemaSchema = z.object({ serviceId: serviceName, entityName: entitySetName, includeNavigations: z.boolean().optional(), includeConstraints: z.boolean().optional(), });
- src/middleware/mcp-auth.ts:560-567 (registration)get-entity-schema registered as public discovery tool that does not require authentication (requiresAuth returns false)'get-entity-schema', // System tools 'sap_service_discovery', 'sap_metadata', 'sap_health_check', 'system_info', ];
- Core helper function to fetch and parse service $metadata XML, used by get-entity-schema to retrieve full entity schemaprivate async getServiceMetadata(service: ODataService): Promise<ServiceMetadata> { try { const destination = await this.sapClient.getDestination({ type: 'design-time', operation: 'discovery', }); const response = await executeHttpRequest(destination, { method: 'GET', url: service.metadataUrl, headers: { Accept: 'application/xml', }, }); return this.parseMetadata(response.data, service.odataVersion); } catch (error) { this.logger.error(`Failed to get metadata for service ${service.id}:`, error); throw error; } }
- Extracts EntityType details including properties, keys, and capabilities from $metadata XML - core logic for entity schema retrievalprivate extractEntityTypes( xmlDoc: Document, entitySets: Array<{ [key: string]: string | null }> ): EntityType[] { const entityTypes: EntityType[] = []; const nodes = xmlDoc.querySelectorAll('EntityType'); nodes.forEach((node: Element) => { const entitySet = entitySets.find( entitySet => entitySet.entitytype?.split('.')[1] === node.getAttribute('Name') ); const entityType: EntityType = { name: node.getAttribute('Name') || '', namespace: node.parentElement?.getAttribute('Namespace') || '', entitySet: entitySet?.name, creatable: entitySet?.creatable?.toLowerCase() === 'true', updatable: entitySet?.updatable?.toLowerCase() === 'true', deletable: entitySet?.deletable?.toLowerCase() === 'true', addressable: entitySet?.addressable?.toLowerCase() === 'true', properties: [], navigationProperties: [], keys: [], }; // Extract properties const propNodes = node.querySelectorAll('Property'); propNodes.forEach((propNode: Element) => { entityType.properties.push({ name: propNode.getAttribute('Name') || '', type: propNode.getAttribute('Type') || '', nullable: propNode.getAttribute('Nullable') !== 'false', maxLength: propNode.getAttribute('MaxLength') ?? undefined, }); }); // Extract keys const keyNodes = node.querySelectorAll('Key PropertyRef'); keyNodes.forEach((keyNode: Element) => { entityType.keys.push(keyNode.getAttribute('Name') || ''); }); entityTypes.push(entityType); }); return entityTypes; }
- src/mcp-server.ts:78-78 (registration)Calls registerDiscoveryTools() on HierarchicalSAPToolRegistry which likely registers get-entity-schema and other discovery toolsawait this.toolRegistry.registerDiscoveryTools();