Skip to content

Latest commit

 

History

History
144 lines (115 loc) · 5.63 KB

File metadata and controls

144 lines (115 loc) · 5.63 KB

Issue Fixes and Analysis

Issue #12: SAP OData Integration Not Showing Tools

Problem

SAP OData services were not generating tools properly. The MCP bridge only created a generic "odata_service_info_for_sap" tool instead of tools for each EntitySet.

Root Cause

The XML parser struct tags were missing the sap: namespace prefix for SAP-specific attributes. The code used xml:"creatable,attr" instead of xml:"sap:creatable,attr", causing these attributes to not be parsed correctly from SAP metadata.

Fix Applied

Updated the EntitySet struct in internal/metadata/parser.go to include the namespace prefix:

// SAP-specific attributes
Creatable  string `xml:"sap:creatable,attr"`
Updatable  string `xml:"sap:updatable,attr"`
Deletable  string `xml:"sap:deletable,attr"`
Searchable string `xml:"sap:searchable,attr"`
Pageable   string `xml:"sap:pageable,attr"`

Issue #13: --max-items 99999 Causing Startup Failure

Problem

Setting --max-items 99999 caused the MCP server to fail during startup.

Root Cause

No validation on the --max-items parameter allowed extremely large values that could cause memory allocation issues when processing responses. Large values could lead to excessive memory usage when arrays are pre-allocated or when responses are buffered.

Fix Applied

Added validation in cmd/odata-mcp/main.go to limit --max-items to a reasonable maximum of 10,000:

// Validate max-items parameter
if cfg.MaxItems > 10000 {
    return fmt.Errorf("--max-items value %d is too large (maximum: 10000). Large values can cause memory issues", cfg.MaxItems)
}
if cfg.MaxItems < 0 {
    return fmt.Errorf("--max-items value must be positive (got: %d)", cfg.MaxItems)
}

Issue #14: Multiple Services Causing Claude to Hang

Problem

When defining two OData services simultaneously in the configuration, Claude becomes unresponsive. The services work individually but not together.

Analysis

This appears to be a client-side (Claude) issue rather than an MCP bridge problem:

  1. Tool Count: The two services generate a combined total of ~485 tools (113 + 372)
  2. Process Isolation: Each MCP server runs as a separate process, so they don't directly interfere with each other
  3. Resource Constraints: Claude may have limitations on the total number of tools it can handle from multiple MCP servers

Recommendations

  1. Use --tool-shrink: This flag shortens tool names and can help reduce memory usage
  2. Filter Entities: Use --entities flag to limit tools to only necessary EntitySets
  3. Disable Unused Operations: Use --disable flag to remove unnecessary operation types
  4. Run Services Separately: Consider activating only one service at a time based on context

Example Configuration with Optimizations

{
  "mcpServers": {
    "odata-business-partner": {
      "command": "/path/to/odata-mcp",
      "args": [
        "--service", "https://example.com/API_BUSINESS_PARTNER",
        "--tool-shrink",
        "--entities", "BusinessPartner,Contact,Address",
        "--disable", "D",
        "--max-items", "50"
      ]
    }
  }
}

Testing Recommendations

  1. For SAP Services: Test with a real SAP OData service to verify that EntitySets with sap: attributes are now properly parsed
  2. For Max Items: Test with various --max-items values to ensure validation works correctly
  3. For Multiple Services: Monitor Claude's resource usage when multiple MCP servers are active

Commit Message

fix: Address critical issues with SAP metadata parsing and max-items validation

- Fix SAP OData metadata parsing by adding sap: namespace prefix to XML struct tags
- Add validation for --max-items parameter (max: 10000) to prevent memory issues  
- Document analysis for multiple service handling limitations in Claude

Fixes #12, #13, provides guidance for #14

Issue: SAP GUID Filtering Format

Problem

SAP OData services require GUID values in filter expressions to be formatted with the guid prefix:

  • ❌ Incorrect: ChemicalRevisionUUID eq '06023781-a5b8-1eec-bf88-402534c04747'
  • ✅ Correct: ChemicalRevisionUUID eq guid'06023781-a5b8-1eec-bf88-402534c04747'

Root Cause

The OData specification allows different formats for GUID values in filters. While standard OData accepts quoted GUIDs, SAP's implementation requires the guid prefix for proper type recognition.

Fix Applied

Added automatic GUID format transformation for SAP services:

  1. SAP Service Detection (isSAPService() function):

    • URL patterns (containing "sap", "s4hana", "odata.sap")
    • SAP-specific metadata attributes
    • Service namespace containing "sap"
    • Hints configuration with service_type containing "SAP"
  2. GUID Format Transformation (transformFilterForSAP() function):

    • Identifies all properties with type Edm.Guid in the entity type
    • Parses filter expressions to find GUID values
    • Automatically prefixes GUID values with guid for SAP compatibility
  3. Code Changes:

    • internal/bridge/bridge.go: Added transformation functions
    • internal/models/models.go: Added SAP-specific fields to EntitySet struct
    • internal/metadata/parser.go: Updated parser to capture SAP-specific attributes

Testing

The fix is automatically applied when:

  1. Service is detected as SAP
  2. Filter contains GUID field comparisons
  3. The GUID field is of type Edm.Guid in metadata

Usage

No changes required for end users. The transformation is automatic.

Users can ensure SAP detection with hints:

{
  "pattern": "*MY_SERVICE*",
  "service_type": "SAP OData Service",
  "field_hints": {
    "ChemicalRevisionUUID": {
      "type": "Edm.Guid"
    }
  }
}