| name | sap-datasphere-plugin |
| description | SAP Datasphere plugin for Codex Co-Work (MarioDeFelipe/sap-datasphere-plugin-for-Codex-cowork). Reference for Datasphere spaces, views, and data federation — the MCP/plugin usage layer: connecting via datasphere-mcp, @sap/datasphere-cli operations, consuming views via OData/Open SQL, and monitoring task chains.
|
| trigger | {"keywords":["datasphere plugin","datasphere mcp","datasphere cli","dsphere","spaces list","dbusers","view consumption","odata consumption","task chain","hana cloud federation"],"intent":"Operating SAP Datasphere from Codex via the datasphere-mcp server or @sap/datasphere-cli — listing spaces, querying exposed views, managing database users, and running/monitoring task chains"} |
| prerequisites | ["SAP Datasphere tenant URL (e.g. https://<tenant>.us10.hcs.cloud.sap)","OAuth client created in Datasphere → System → App Integration (Purpose \"Interactive Usage\")","DSPHERE_HOST / DSPHERE_USER / DSPHERE_PASSWORD set in .env (consumed by datasphere-mcp)","Technical user assigned as member of each target space (DW Integrator/Viewer role)","Node.js 18+ for @sap/datasphere-cli and the MCP server"] |
SAP Datasphere Plugin (MCP + CLI Usage Layer)
Operational layer for driving SAP Datasphere from Codex: the datasphere-mcp server
(MarioDeFelipe/sap-datasphere-mcp) plus @sap/datasphere-cli. For data-modeling concepts
(Data Builder, analytical models, replication flows) use the sibling sap-datasphere skill.
1. Plugin / MCP setup
The repo ships a datasphere-mcp entry in .mcp.json (stdio, node dist/index.js) reading:
DSPHERE_HOST=https://<tenant>.us10.hcs.cloud.sap
DSPHERE_USER=<technical-user-or-oauth-client-id>
DSPHERE_PASSWORD=<password-or-oauth-client-secret>
npm run hc
OAuth prerequisite (one-time, in the Datasphere tenant):
- System → Administration → App Integration → Add a New OAuth Client
- Purpose: Interactive Usage (CLI login) — Authorization Grant: Authorization Code
- Note the Client ID, Client Secret, Authorization URL, Token URL
2. CLI login and space discovery
npm install -g @sap/datasphere-cli
datasphere config host set "https://<tenant>.us10.hcs.cloud.sap"
datasphere login --client-id "<CLIENT_ID>" --client-secret "<CLIENT_SECRET>"
datasphere spaces list
datasphere spaces read --space SALES --output sales_space.json
datasphere dbusers list --space SALES
3. Consume a view — OData
The view must have Expose for Consumption = ON in Data Builder (see Pitfall 4).
curl -H "Authorization: Bearer $TOKEN" \
"https://<tenant>.us10.hcs.cloud.sap/api/v1/dwc/consumption/relational/SALES/V_SALES_KPI/V_SALES_KPI?\$top=10"
curl -H "Authorization: Bearer $TOKEN" \
"https://<tenant>.us10.hcs.cloud.sap/api/v1/dwc/consumption/analytical/SALES/AM_SALES/AM_SALES?\$select=Revenue"
4. Consume a view — SQL (Open SQL schema)
Database users unlock direct SQL access on HANA Cloud port 443.
datasphere dbusers list --space SALES
hdbsql -n "<tenant-hana-host>:443" -e -u "SALES#TECH_USER" -p "<password>" \
'SELECT TOP 10 * FROM "SALES"."V_SALES_KPI";'
5. Data federation basics
Federation = remote tables over a connection (S/4HANA via ODP/CDS, HANA Cloud via
SDA, Azure SQL, BW/4HANA). Queries execute at the source — no copy, always fresh.
Connection (S4HANA_PRD) → Remote Table (federated, default) → View → Expose → OData/SQL
└─ optional: switch to Replicated (snapshot/real-time)
- Check state: Data Integration Monitor → Remote Tables → Federation vs Replicated
- Heavy analytical reads on S/4? Switch the remote table to replicated (see Pitfall 3)
- Model federation details (virtual tables, VDM layers) live in the
sap-datasphere skill
6. Task chains — run and monitor
datasphere tasks list --space SALES
datasphere tasks chains run --space SALES --object TC_DAILY_LOAD
datasphere tasks list --space SALES --status RUNNING
Pitfalls
- CLI login fails with invalid_client → Cause: OAuth client created without Purpose "Interactive Usage" (e.g. API Access only). Solution: recreate the OAuth client in App Integration with Purpose = Interactive Usage, Authorization Grant = Authorization Code.
spaces list returns empty / 403 on space objects → Cause: technical user authenticated but not a member of the space. Solution: Space Management → SPACE_ID → Members → add user with DW Viewer (read) or DW Integrator (run tasks).
- "Fresh" data is stale or source is overloaded → Cause: remote table replication vs federation confusion — replicated tables serve snapshots; federated tables push every query to the source. Solution: check Data Integration Monitor → Remote Tables; use federation for freshness, replication to offload heavy reads from S/4HANA.
- View returns 404 on the consumption API → Cause: view not exposed — "Expose for Consumption" toggle is OFF. Solution: Data Builder → open view → toggle Expose for Consumption ON → deploy, then retry the OData/SQL query.
- hdbsql connection refused → Cause: client IP not in the Datasphere IP allowlist. Solution: System → Configuration → IP Allowlist → add the client's public IP.
Verification
npm run hc
datasphere spaces list
curl -s -H "Authorization: Bearer $TOKEN" \
"https://<tenant>.us10.hcs.cloud.sap/api/v1/dwc/consumption/relational/SALES/V_SALES_KPI/V_SALES_KPI?\$top=1"
datasphere tasks list --space SALES
Related
- sap-datasphere skill — modeling layer: spaces, Data Builder, analytical models, replication flows, VDM
- datasphere-mcp in
.mcp.json — MarioDeFelipe/sap-datasphere-mcp (DSPHERE_HOST/USER/PASSWORD)
- sap-hana-cli skill — hdbsql and HANA Cloud client tooling for Open SQL schema access
- sap-sac-* skills — SAC consumes exposed Datasphere analytical models