A Claude Code skill for querying SAP OData endpoints with secure logging, configurable output, and comprehensive error handling.
- Secure Logging: Automatic masking of passwords, tokens, and sensitive data
- Configurable Output: Store results in custom directories with JSON or pretty-print format
- Error Handling: Automatic retry with exponential backoff, detailed error logging
- TypeScript: Full type safety and modern async/await patterns
- Claude Integration: Automatically activates when Claude detects SAP-related queries
- Multiple Commands: Query data, fetch metadata, list services, test connections
# Clone the repository
git clone https://github.com/one-kash/sap-odata-explorer.git
cd sap-odata-explorer
# Install dependencies
npm install
# Build TypeScript
npm run buildCopy the example environment file and configure your SAP credentials:
cp .env.example .envEdit .env with your SAP system details:
# Required
SAP_HOST=your-sap-host:port
SAP_USER=your-username
SAP_PASSWORD=your-password
SAP_CLIENT=001
SAP_LANGUAGE=EN
# OData Configuration
ODATA_BASE_PATH=/sap/opu/odata/sap
ODATA_SERVICE=sepmra_shop
ODATA_ENTITY=Products
# Output Configuration
OUTPUT_DIR=./output
OUTPUT_FORMAT=jsonThis skill automatically activates when you ask Claude questions about your SAP data. Simply ask in natural language - no commands to memorize!
Product Queries:
- "Show me products from SAP"
- "What are the 10 most expensive products?"
- "Find products under $20"
- "Show me products with low inventory"
Business Data:
- "Get business partners from SAP"
- "Show me sales orders"
- "What customers are in the system?"
Filtered Searches:
- "Find office chairs in the SAP system"
- "Show products from supplier XYZ"
- "Get items in the Filing & Archiving category"
Data Analysis:
- "Which products are out of stock?"
- "Show highly-rated products"
- "What are the cheapest office supplies?"
- You ask Claude a question about SAP data
- This skill automatically activates
- The skill queries your SAP OData service
- Results are returned to Claude
- Claude explains the data in natural language
- Raw data is saved to the
output/directory for reference
You: "Show me the 5 cheapest products from SAP"
Claude: I'll query your SAP system...
[Results]
Claude: Here are the 5 cheapest products:
- Natural Rubber Eraser: $0.23
- Plastic Ruler (Red): $0.42
- Plastic Ruler (Green): $0.42
- Pencil Sharpener: $0.65
- Ballpoint Pen: $0.89
Would you like more details about any of these?
src/
├── lib/
│ ├── types.ts # TypeScript type definitions
│ ├── config.ts # Environment configuration
│ ├── secure-logger.ts # Secure logging with credential masking
│ ├── error-handler.ts # Retry logic and error management
│ ├── file-writer.ts # File output handling
│ └── odata-client.ts # Core OData HTTP client
├── query.ts # Query entity CLI
├── metadata.ts # Fetch metadata CLI
├── list-services.ts # List services CLI
└── test-connection.ts # Connection test utility
- Automatic Masking: Passwords, tokens, and API keys never appear in logs
- URL Sanitization: Credentials stripped from URLs before logging
- Header Redaction: Authorization headers masked in console output
- Configurable Patterns: Customize which fields to mask via
LOG_MASK_FIELDS
- Retry Logic: Automatic retry with exponential backoff (3 attempts)
- Detailed Logging: Errors logged to separate file (
errors.log) - Safe Failures: Graceful degradation with informative error messages
- Connection Timeouts: Configurable request timeouts
SAP_HOST- SAP system hostname and port (required)SAP_USER- SAP username (required)SAP_PASSWORD- SAP password (required)SAP_CLIENT- SAP client number (default:001)SAP_LANGUAGE- Language code (default:EN)SAP_USE_SSL- Use HTTPS (default:true)
ODATA_BASE_PATH- Base path for OData services (e.g.,/sap/opu/odata/sap)ODATA_SERVICE- Default service nameODATA_ENTITY- Default entity name
OUTPUT_DIR- Output directory path (default:./output)OUTPUT_FORMAT- Output format:jsonorpretty(default:json)
LOG_LEVEL- Log level:debug,info,warn,error(default:info)LOG_MASK_FIELDS- Comma-separated field names to mask (default:password,passwd,token,authorization,secret,key,apikey,api_key)ERROR_LOG_FILE- Error log file path (default:${OUTPUT_DIR}/errors.log)
MAX_RETRIES- Maximum retry attempts (default:3)RETRY_DELAY_MS- Initial retry delay in milliseconds (default:1000)RETRY_BACKOFF_MULTIPLIER- Backoff multiplier for retries (default:2)
REQUEST_TIMEOUT_MS- Request timeout in milliseconds (default:30000)
If you get connection errors, verify:
- SAP system is reachable:
ping your-sap-host - Port is accessible:
telnet your-sap-host port - Credentials are correct in
.env - Firewall allows outbound connections
- Verify
ODATA_BASE_PATHis correct (usually/sap/opu/odata/sap) - Check service name spelling
- Ask Claude: "List available SAP services"
- Double-check username and password in
.env - Verify SAP client number is correct
- Ensure user has permissions to access OData services
For comprehensive examples of questions you can ask Claude, see EXAMPLES.md.
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT License - see LICENSE file for details
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.