Skip to main content
Glama

SAP Commerce MCP Server

utils.py1.27 kB
"""Utility helpers shared across the MCP server.""" from __future__ import annotations from typing import Any, Mapping class OccApiError(RuntimeError): """Raised when the OCC API returns an error we cannot recover from.""" def __init__(self, message: str, *, status_code: int | None = None, payload: Any | None = None) -> None: super().__init__(message) self.status_code = status_code self.payload = payload def to_dict(self) -> dict[str, Any]: """Provide a JSON-serializable representation of the error.""" data: dict[str, Any] = {"message": str(self)} if self.status_code is not None: data["status_code"] = self.status_code if self.payload is not None: data["payload"] = self.payload return data def coalesce_fields(fields: str | None, default: str) -> str: """Return the provided fields value if present, otherwise fall back to the default.""" if fields and fields.strip(): return fields.strip() return default def clean_params(params: Mapping[str, Any]) -> dict[str, Any]: """Remove keys whose values are ``None`` while preserving falsy values like 0.""" return {key: value for key, value in params.items() if value is not None}

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/commerce-cloud-integrations/sap-commerce-mcp-server'

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