# Cap Agentic Engineered

> 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 AGENTS.md, MCP skills, and a working Financial Risk Analyzer built entirely by Claude Code.

- **Type:** MCP server
- **Install:** `agentstack add mcp-sap-samples-cap-agentic-engineered`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [SAP-samples](https://agentstack.voostack.com/s/sap-samples)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [SAP-samples](https://github.com/SAP-samples)
- **Source:** https://github.com/SAP-samples/cap-agentic-engineered

## Install

```sh
agentstack add mcp-sap-samples-cap-agentic-engineered
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

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

[](https://api.reuse.software/info/github.com/SAP-samples/cap-agentic-engineered)

A reference application showing how AI coding agents produce higher-quality SAP applications when grounded by [SAP MCP servers](https://community.sap.com/t5/technology-blog-posts-by-sap/sap-build-introduces-new-mcp-servers-to-enable-agentic-development-for/ba-p/14205602). The app was built entirely by [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) following specs generated by [GSD](https://github.com/nickbaumann98/gsd), a spec-driven development tool. The [`AGENTS.md`](AGENTS.md) and [`skills/`](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`](AGENTS.md) and [skills](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/`](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](https://nodejs.org/) >= 18
- [SAP CAP](https://cap.cloud.sap) (`@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

```bash
npm ci
cds watch
```

Open [http://localhost:4004/risk/webapp/index.html](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:

```bash
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

```bash
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`](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/`](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](https://github.com/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](https://community.sap.com/).

For questions about Claude Code or MCP, see the [Claude Code documentation](https://docs.anthropic.com/en/docs/claude-code/overview).

## 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](https://developercertificate.org/).

## 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](LICENSES/Apache-2.0.txt) file.

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [SAP-samples](https://github.com/SAP-samples)
- **Source:** [SAP-samples/cap-agentic-engineered](https://github.com/SAP-samples/cap-agentic-engineered)
- **License:** Apache-2.0

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-sap-samples-cap-agentic-engineered
- Seller: https://agentstack.voostack.com/s/sap-samples
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
