SAP Datasphere MCP Server
The SAP Datasphere MCP Server enables AI assistants to explore, query, and manage SAP Datasphere environments via MCP, covering metadata discovery, data access, profiling, ETL extraction, task management, and CLI-backed administration with built-in security and PII masking.
Key capabilities:
Metadata & Data Discovery: List spaces, search tables/views, browse catalog assets, retrieve schemas, find assets by column name (lineage/impact analysis), explore analytical/relational metadata, get asset variables, list design-time and deployed objects, and browse marketplace data packages.
Data Querying: Execute read-only SQL (up to 1,000 rows), perform OData queries for ETL extraction (up to 50K records), run analytical OData queries, and use smart query routing (auto-selecting relational, analytical, or SQL fallback).
Data Profiling & Quality: Analyze column distributions, detect outliers (IQR-based), assess data quality (null rates, distinct values, percentiles).
Task & Pipeline Management: Run task chains, monitor status, retrieve detailed logs, and view execution history.
Repository & Object Management: Retrieve object definitions, list design-time/deployed objects, and create local tables via CLI (CSN generation).
Database User Administration (CLI-backed): List, create, update, delete users, and reset passwords with consent gating for high-risk operations and audit logging.
Security & PII Protection: Config-driven PII masking (redact, partial, hash, drop, tokenize), SQL sanitization (blocks writes/injections), OAuth 2.0 authentication, four permission levels, and audit logging.
Connectivity & System Info: Test connections, list external data sources and their status, retrieve current user details, tenant configuration, available OAuth scopes, and check CLI installation/authentication.
Provides tools for exploring and querying SAP Datasphere, including metadata discovery, catalog search, SQL and OData queries, ETL extraction, data lineage, column profiling, and configurable PII masking.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SAP Datasphere MCP ServerFind tables related to customer in the Sales space"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🚀 SAP Datasphere MCP Server
CLI + MCP are a combo. This repo owns consumption / catalog (read rows, search, profile). Its counterpart owns design-time / admin (create and change objects). Use them together — not as alternatives.
Half
Repository
MCP (this repo)
CLI
Model Context Protocol server that lets AI assistants explore and query SAP Datasphere — metadata discovery, catalog search, OData and SQL queries, ETL extraction, data lineage and column profiling — with built-in config-driven PII masking so sensitive fields never reach the LLM.
Version 1.4.0 · 42 tools advertised by default (51 with DATASPHERE_TOOL_PROFILE=full)
🙌 Shout-out: this repository is a modified copy of MarioDeFelipe/sap-datasphere-mcp. All credit for the original server goes to Mario de Felipe — this fork adapts it for a specific tenant setup and CLI integration.
🤝 Relationship to the SAP Datasphere CLI
This server and the @sap/datasphere-cli are complementary halves, not
alternatives. They reach different API families, and nearly every difference
follows from that:
Reaches | Therefore owns | |
MCP server (this repo) | Consumption and Catalog APIs | Reading data and metadata, catalog search, profiling |
CLI | Design-time and admin APIs | Creating and changing objects, tenant administration |
What each side does
Function | MCP | CLI |
Read data rows | yes — | no — no command returns table contents |
Catalog search, asset lookup |
| — |
Column profiling, distributions, outliers |
| — |
Analytical/relational metadata (dimensions vs. measures, OData→SQL types) |
| — |
PII masking, SQL sanitizing, consent gating, audit logging | yes | — |
Create/change/delete modeling objects (18 types) | local tables only ( | yes |
Spaces, users, global & scoped roles, workload, certificates | read-only or not at all | yes |
Connections: create/change | read-only ( | yes |
Read an object definition (CSN) | — |
|
See deployed but non-exposed objects | via CLI ( |
|
Task chains, task logs |
|
|
Database users |
|
|
The CLI cannot read data rows — that is this server's reason to exist.
This server does not create objects, apart from local tables (create_table),
because the payload there is derived from data it has already read. Views,
analytic models, flows, spaces, users and roles belong to the CLI.
Neither writes data rows. Rows arrive through a data/replication flow, a database user with a SQL client, or a CSV upload in the Data Builder UI. Neither manages folders — those are UI-only.
How they combine in practice
A typical build-then-verify loop:
CLI creates the layers — staging/cleansing/integration views, target tables, transformation flows, task chain, analytic model.
CLI runs the chain and reports task status.
MCP verifies the result: row counts, value distributions, whether data quality flags actually fire — everything the CLI structurally cannot see.
Findings flow back into step 1 as CSN changes.
Keep the visibility gap in mind: Consumption and Catalog endpoints only show
objects that are deployed and exposed for consumption. A view that exists in
the repository but is not exposed is invisible here while the CLI still sees it —
that is what list_repository_objects exists for.
Guide | Content |
Authoritative capability split and routing rules | |
The three config files and the two identities | |
Finding objects the Consumption API cannot see |
A few tools shell out to the CLI (create_table, the *_database_user* tools,
list_repository_objects). The CLI keeps its own session, separate from this
server's OAuth credentials — check it with the datasphere_cli_status tool.
Related MCP server: Semantic BI MCP
🚀 Quick Start
# npm
npm install -g @mariodefe/sap-datasphere-mcp && npx @mariodefe/sap-datasphere-mcp
# PyPI
pip install sap-datasphere-mcp && sap-datasphere-mcp
# From source
git clone https://github.com/MarioDeFelipe/sap-datasphere-mcp.git
cd sap-datasphere-mcp
pip install -r requirements.txt && pip install -e .
cp .env.example .env # fill in your credentials
sap-datasphere-mcpFull walkthrough: docs/GETTING_STARTED.md · OAuth setup: docs/OAUTH_SETUP.md
Configuration
DATASPHERE_BASE_URL=https://your-tenant.eu10.hcs.cloud.sap
DATASPHERE_TENANT_ID=your-tenant-id
DATASPHERE_CLIENT_ID=your-client-id
DATASPHERE_CLIENT_SECRET=your-client-secret
DATASPHERE_TOKEN_URL=https://your-tenant.authentication.eu10.hana.ondemand.com/oauth/token
USE_MOCK_DATA=falseOptional settings for the CLI-backed tools (DATASPHERE_CLI_PATH, _HOST,
_SECRETS_FILE) are documented in .env.example and
docs/TENANT_CONFIG.md.
Never commit .env.
Claude Desktop
{
"mcpServers": {
"sap-datasphere": {
"command": "npx",
"args": ["@mariodefe/sap-datasphere-mcp"],
"env": {
"DATASPHERE_BASE_URL": "https://your-tenant.eu20.hcs.cloud.sap",
"DATASPHERE_CLIENT_ID": "your-client-id",
"DATASPHERE_CLIENT_SECRET": "your-client-secret",
"DATASPHERE_TOKEN_URL": "https://your-tenant.authentication.eu20.hana.ondemand.com/oauth/token"
}
}
}
}Config location — Windows: %APPDATA%\Claude\claude_desktop_config.json ·
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json ·
Linux: ~/.config/Claude/claude_desktop_config.json
🛠️ Tool Catalog
42 tools in the default lean profile. Set DATASPHERE_TOOL_PROFILE=full to
also advertise overlapping metadata tools, and DATASPHERE_EXPOSE_DIAGNOSTICS=true
for the endpoint probes — 51 in total. Hiding them by default improves the
model's tool selection; every handler stays reachable.
Foundation (5)
test_connection · get_current_user · get_tenant_info · get_available_scopes · list_spaces
Space discovery (3)
get_space_info · get_table_schema · search_tables
Catalog and search (5)
list_catalog_assets · get_asset_details · get_asset_by_compound_key · get_space_assets · search_catalog
Catalog search runs client-side: /catalog/search returns 404 on the tenants
tested, so these tools fetch assets and filter locally across name, label,
businessName and description.
Data discovery and quality (2)
Tool | Purpose |
| Which assets contain a given column — lineage and impact analysis across spaces |
| Null rate, distinct values, percentiles, IQR outlier detection |
Querying data (4)
Tool | Purpose |
| SQL router: picks analytical vs relational, falls back to client-side aggregation when the asset cannot aggregate |
| SELECT over one entity (columns/ |
| Relational OData, up to 50,000 records per batch for ETL |
| Analytical OData with |
Supported SQL: SELECT */column lists, WHERE, LIMIT, GROUP BY,
aggregations with and without grouping, ORDER BY. No JOINs — OData is
single-entity. Names are case-sensitive.
Metadata (7)
get_relational_metadata · list_relational_entities · get_relational_entity_metadata ·
get_analytical_metadata · get_analytical_model · list_analytical_datasets · get_asset_variables
get_relational_entity_metadata maps OData types to SQL (Edm.String →
NVARCHAR(MAX), Edm.Int64 → BIGINT, Edm.Decimal → DECIMAL(18,2), …) for
data-warehouse loading. get_asset_variables surfaces input parameters a
parameterised view or analytic model expects.
Repository (3)
Tool | Purpose |
| Lists design-time objects via the CLI, so it also sees objects not exposed for consumption |
| Deployed objects in a space |
| Object definition (deprecated — prefer |
Database users (5) — CLI-backed
list_database_users · create_database_user · update_database_user ·
delete_database_user · reset_database_user_password
High-risk operations require consent, cached for 60 minutes.
Tasks (4)
get_task_status · run_task_chain · get_task_log · get_task_history
Object provisioning (1) — CLI-backed
create_table — builds a CSN definition from your column list and runs
datasphere objects local-tables create. Local tables only; see the CLI split above.
Operations (4)
list_connections · browse_marketplace · datasphere_cli_status · get_relational_odata_service (full profile)
datasphere_cli_status reports whether the CLI is installed, which version, which
host, and whether a session exists. Run it first when a CLI-backed tool fails.
🔏 PII / Sensitive-Field Masking
A config-driven, fail-closed masking layer runs inside the response pipeline.
Every data-returning tool (smart_query, query_relational_entity,
query_analytical_data, get_space_assets, analyze_column_distribution) funnels
results through apply_masking() before they reach the LLM. No prompt bypasses it.
Defense in depth. The authoritative access control stays upstream — SAP Datasphere Data Access Controls, and not granting the technical user access to PII tables. This layer is the enforced, auditable net on top.
Environment variable | Values | Default | Purpose |
| path to YAML or JSON | (unset) | Policy file. Unset = masking fully disabled. |
|
|
|
|
| secret string | (empty) | Salt for deterministic |
If the policy file is configured but missing or unparseable, the server raises at startup and refuses to run. It never silently serves raw data with a broken policy.
mode: enforce
default_action: redact
rules:
# Most specific wins: asset > space > global; exact > glob
- space: ZDCS_08
asset: ZR_SAP_CUSTOMER
columns:
EMAIL: redact # → "***"
PHONE: partial:4 # keep last 4 → "******1234"
TAXID: hash # sha256(salt:value) — deterministic, safe for GROUP BY
SSN: drop # column removed from every row
- space: "*"
columns:
"*IBAN*": tokenize # glob on column name → "TKN_<8hex>"
allowlist:
enabled: true
assets:
ZDCS_08.ZR_OTC_CUST_MONTH: [CUSTOMER, MONTH, REVENUE] # ONLY these returned
patterns:
email: '[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}'
iban: '\b[A-Z]{2}\d{2}[A-Z0-9]{10,30}\b'Precedence: allowlist (drops everything unlisted) → column rules → value-pattern scan on remaining strings.
Audit log — one structured line per call, values never logged:
[pii_masking] space=ZDCS_08 asset=ZR_SAP_CUSTOMER rows=42
masked_fields=['EMAIL', 'PHONE', 'SSN'] mode=enforceThe response also carries masked_fields, so the client can see what was withheld.
Annotated example: pii_policy.yaml.
🔒 Security
Authentication — OAuth 2.0 client credentials, tokens refreshed 60s before expiry and encrypted in memory (Fernet). No credentials in code.
Authorization — four permission levels (READ, WRITE, ADMIN, SENSITIVE), interactive consent for high-risk operations, full audit logging.
Query safety — the SQL sanitizer is fail-closed on SELECT:
INSERT/UPDATE/DELETE/DROP and SQL comments are blocked, along with 15+
injection patterns. Write paths do not exist.
🌐 Transports
stdio by default; Streamable HTTP (spec 2025-03-26) at /mcp for long-lived
service deployments.
Flag | Env var | Default | Purpose |
|
|
|
|
|
|
| Bind address |
|
|
| Bind port |
|
|
| Endpoint path |
|
| (none) | Require |
pip install 'sap-datasphere-mcp[http]'
sap-datasphere-mcp --transport http --port 8080The server warns when bound to a non-loopback interface without a token.
/health serves a plain JSON liveness probe.
📊 Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ AI Assistant │◄──►│ MCP Server │◄──►│ SAP Datasphere │
│ (Claude, Cursor)│ │ Authorization │ │ (OAuth 2.0) │
│ │ │ PII masking │ │ │
│ │ │ Caching │ │ datasphere CLI │
└─────────────────┘ └──────────────────┘ └─────────────────┘src/sap_datasphere_mcp/
├── server.py # MCP server and all tool handlers
├── cli_runner.py # Single entry point for `datasphere` CLI calls
├── pii_masking.py # Config-driven, fail-closed masking
├── cache_manager.py # TTL cache
├── telemetry.py # Request metrics
├── tool_descriptions.py # Tool metadata
├── error_helpers.py # Error formatting
├── auth/
│ ├── oauth_handler.py # Token management and refresh
│ ├── datasphere_auth_connector.py # Authenticated API connector
│ ├── authorization.py # Permission levels
│ ├── consent_manager.py # Consent tracking
│ ├── input_validator.py # Input validation
│ ├── sql_sanitizer.py # SELECT-only enforcement
│ └── data_filter.py # Credential redaction
└── config/settings.py # Environment-based settingsCaching TTLs — spaces 1h · assets 30min · metadata 15min · users 5min, LRU eviction.
Response times — cached metadata under 100ms · catalog 100–500ms · OData queries 500–2000ms depending on volume.
🧪 Testing
pytest # full suite
pytest tests/test_cli_runner.py # CLI integration layer
npx @modelcontextprotocol/inspector sap-datasphere-mcptests/test_cli_runner.py verifies every CLI command the server hardcodes
against the --help dumps in the DataphereCLI repo. Point
DATASPHERE_CLI_HELP_DIR at tools/cli-help to enable it; it skips otherwise.
Known failure: tests/test_mcp_server.py uses await server.list_resources()(),
an idiom the current MCP SDK no longer supports. Pre-existing, unrelated to the
server itself.
🚀 Deployment
docker build -t sap-datasphere-mcp:latest .
docker run -d --name sap-mcp --env-file .env sap-datasphere-mcp:latest
# or
docker-compose up -dFull guide incl. Kubernetes: docs/DEPLOYMENT.md
📚 Documentation
Guide | Content |
Setup walkthrough with examples | |
Technical API docs, Python and cURL | |
App Integration and OAuth client | |
Config files, the two identities | |
Which tool owns which task | |
Objects invisible to Consumption | |
Docker, Kubernetes, PyPI | |
Contributing to the codebase | |
Version history |
🙏 Acknowledgments
This repository started as a modified copy of MarioDeFelipe/sap-datasphere-mcp. Shout-out to Mario de Felipe for the original server — the tool catalog, PII masking design and OAuth flow this fork builds on all trace back there.
Built with Amazon Kiro (specifications and architectural steering) and Claude Code (security and authentication, tool descriptions and error handling, caching and telemetry, repository and analytics tools, CLI integration layer).
📄 License
MIT — see LICENSE.
📞 Support
Issues · Discussions · SAP Datasphere docs · Model Context Protocol
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceProduction-ready MCP server that enables AI assistants to seamlessly interact with SAP Datasphere environments for real tenant data discovery, metadata exploration, analytics operations, ETL data extraction, database user management, data lineage analysis, and column-level data profiling.Last updated3927440MIT
- Flicense-qualityBmaintenanceModel Context Protocol (MCP) server that gives AI assistants a safe, correct data-analyst capability over business metrics - without raw SQL improvisation.Last updated
- Alicense-qualityDmaintenanceA Model Context Protocol (MCP) server that provides seamless integration with SAP systems through RFC (Remote Function Call) connections. This server enables AI assistants and applications to interact with SAP functions, retrieve metadata, and perform operations with enhanced caching and version compatibility.Last updated10MIT
- Alicense-qualityCmaintenanceProduction-ready MCP server enabling AI assistants to interact with SAP Datasphere for real tenant data discovery, metadata exploration, analytics operations, ETL data extraction, database user management, data lineage analysis, and column-level data profiling.Last updatedMIT
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Official Microsoft MCP Server to query Microsoft Entra data using natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/DimiDR/SAP-Datasphere-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server