Skip to content

SAP-samples/cap-agentic-engineered

MCP-Grounded SAP Development -- CAP + Fiori Elements Reference Application

REUSE status

A reference application showing how AI coding agents produce higher-quality SAP applications when grounded by SAP MCP servers. The app was built entirely by Claude Code following specs generated by GSD, a spec-driven development tool. The AGENTS.md and skills/ provided the SAP-specific guardrails, routing the agent to the right MCP server (CAP, Fiori, UI5) for each task.

What you get:

  • A working Financial Risk Analyzer as concrete evidence of the methodology
  • A reusable AGENTS.md and skills that tell AI coding agents which MCP server to query for each SAP artifact — portable across Claude Code, Cursor, Copilot, and other MCP-capable tools
  • The spec/ folder with the specs that drove the build — project roadmap, phased requirements, success criteria, and execution logs
  • Test suite covering service behavior, annotations, i18n, and manifest correctness

The Application

The Financial Risk Analyzer classifies General Ledger transactions as normal or anomalous using 24 engineered financial features. It exposes an OData V4 service with a Fiori Elements List Report and an unbound action that triggers batch ML inference via SAP AI Core.

Key capabilities:

  • CDS data model with 24 feature columns for ML risk scoring
  • Unbound OData action (analyzeRisks) for batch inference across all transactions
  • Fiori Elements List Report with custom toolbar action and criticality-based highlighting
  • SAP AI Core integration for XGBoost model predictions, with a built-in mock predictor for local development
  • Role-based access control (RiskAnalyst role for analysis actions)

Prerequisites

  • Node.js >= 18
  • SAP CAP (@sap/cds-dk) installed globally: npm i -g @sap/cds-dk
  • (Optional) SAP AI Core instance for live ML predictions -- the app runs fully locally with the mock predictor

Setup and Run

npm ci
cds watch

Open http://localhost:4004/risk/webapp/index.html in your browser.

Log in with user test-analyst / password pass (mocked authentication in development profile).

Environment Variables (Optional)

To connect to SAP AI Core for live predictions instead of the mock predictor, copy .env.example to .env and fill in your BTP service key credentials:

cp .env.example .env
# Edit .env with your SAP AI Core credentials

Set AI_CORE_MOCK=true (the default) to use the built-in mock predictor without any external services.

Running Tests

npm test

The test suite includes:

Test What it verifies
test/integration/risk-service.test.js OData service behavior, CRUD, action execution
test/integration/annotations.test.js CDS annotation correctness
test/unit/feature-extractor.test.js Feature engineering logic
test/unit/ai-core-client.test.js AI Core client with mocked responses
test/unit/i18n.test.js All i18n keys used in code exist in properties file
test/unit/manifest.test.js Manifest.json structure and route configuration
test/unit/risk-labels.test.js Risk classification label mappings
test/feature-columns.test.js Feature column definitions and ML contract

Repository Structure

cap-agentic-engineered/
+-- AGENTS.md                  # MCP routing rules and SAP development patterns (reusable)
+-- db/
|   +-- schema.cds             # GLTransactions entity with 24 ML feature columns
|   +-- data/                  # Sample GL transaction data (CSV)
+-- srv/
|   +-- risk-service.cds       # OData V4 service definition with unbound action
|   +-- risk-service.js        # Service handler with AI Core integration
|   +-- lib/
|       +-- ai-core-client.js  # SAP AI Core inference client
|       +-- mock-predictor.js  # Local mock predictor (no AI Core needed)
|       +-- feature-extractor.js  # 24-feature engineering pipeline
|       +-- feature-columns.js # ML contract: CDS field <-> model feature mapping
|       +-- risk-labels.js     # Risk classification labels and criticality
+-- app/
|   +-- services.cds           # Service binding for Fiori app
|   +-- risks/
|       +-- annotations.cds    # UI annotations (LineItem, SelectionFields, etc.)
|       +-- webapp/
|           +-- manifest.json  # Fiori Elements List Report configuration
|           +-- ext/controller/ListReportExt.controller.js  # Custom action handler
+-- test/                      # Unit and integration tests
+-- spec/                     # GSD specs: roadmap, phased requirements, execution logs
+-- skills/                    # SAP MCP skills (auto-trigger on file patterns)

Reusing the AGENTS.md and Skills

The AGENTS.md defines which MCP server to query for each type of SAP artifact — CDS models, Fiori annotations, UI5 controllers — so the generated code is grounded in live API documentation rather than stale training data. The skills in skills/ enforce those rules automatically: when the agent touches a file matching a skill's path pattern (e.g., srv/**/*.cds), the skill fires and instructs it to query the correct MCP server before writing code.

Copy AGENTS.md and skills/ into your own CAP + Fiori Elements project, configure the MCP servers in .claude/settings.json (instructions inside the file), and your AI coding agent will automatically query the right server for each task.

Scope

This application is designed for local development only. It demonstrates the MCP-grounded methodology and the resulting application quality — not a production ready app. For a comprehensive CAP reference covering BTP deployment, HANA, XSUAA, draft editing, compositions, and multi-app frontends, see SAP-samples/cap-sflight.

How to Obtain Support

This repository is provided as-is. For questions about SAP CAP, Fiori Elements, or AI Core, use the SAP Community.

For questions about Claude Code or MCP, see the Claude Code documentation.

Contributing

If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.

License

Copyright (c) 2026 SAP SE or an SAP affiliate company and cap-agentic-engineered contributors. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

About

Reference CAP + Fiori Elements application showing how AI coding agents produce higher-quality SAP applications when grounded by SAP MCP servers (CAP, Fiori, UI5). Includes a reusable CLAUDE.md, MCP skills, and a working Financial Risk Analyzer built entirely by Claude Code.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors