Skip to main content
Glama
Raistlin82

SAP OData to MCP Server

by Raistlin82

Get Entity Schema

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
NameRequiredDescriptionDefault
serviceIdYesThe SAP service ID
entityNameYesThe entity name

Implementation Reference

  • Zod input validation schema for the get-entity-schema tool defining serviceId, entityName, and optional flags
    export const EntitySchemaSchema = z.object({
      serviceId: serviceName,
      entityName: entitySetName,
      includeNavigations: z.boolean().optional(),
      includeConstraints: z.boolean().optional(),
    });
  • 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 schema
    private 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 retrieval
    private 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;
    }
  • Calls registerDiscoveryTools() on HierarchicalSAPToolRegistry which likely registers get-entity-schema and other discovery tools
    await this.toolRegistry.registerDiscoveryTools();
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it 'gets' information (implying a read operation) but doesn't cover critical aspects like authentication requirements, rate limits, error handling, or response format. For a tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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?

The description is a single, efficient sentence that front-loads the core purpose ('Get detailed schema information') and specifies the included details without redundancy. Every word earns its place, making it appropriately sized for a straightforward tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (2 required parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what the output looks like (e.g., JSON structure), error conditions, or dependencies on other tools (e.g., needing authentication first). For a schema retrieval tool in a SAP context, more context is needed for effective use.

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?

The schema description coverage is 100%, with both parameters (serviceId, entityName) clearly documented in the input schema. The description adds no additional parameter semantics beyond implying the entity is 'specific', which is already covered by the schema's required fields. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'detailed schema information for a specific entity', specifying what information is included (properties, types, keys, constraints). It distinguishes from siblings like 'discover-service-entities' (which likely lists entities) by focusing on schema details for a specific entity, though it doesn't explicitly name alternatives.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication), compare to siblings like 'discover-service-entities' (which might list entities before getting schemas), or specify use cases (e.g., for data modeling or query building).

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/Raistlin82/btp-sap-odata-to-mcp-server-optimized'

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