Skip to main content
Glama
CAP V2 Case MCP

CAP V2 Case MCP

CAP V2 Case MCP โ€” SAP Sales Cloud V2 Case Integration

A SAP CAP (Cloud Application Programming Model) project that exposes SAP Sales Cloud V2 (C4C) case management operations as an OData V4 + MCP dual-protocol service.


๐Ÿ“ Architecture Overview

Client (OData V4 / MCP)
        โ”‚
        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   CaseServices (CAP)    โ”‚  โ† srv/services.cds + srv/services.js
โ”‚  /odata/v4/case-servicesโ”‚
โ”‚                         โ”‚
โ”‚  listCases()            โ”‚
โ”‚  getCaseById()          โ”‚
โ”‚  createCase()           โ”‚
โ”‚  patchCase()            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚ c4c.send() โ€” HTTP REST
             โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  SAP Sales Cloud V2     โ”‚  โ† REST API
โ”‚  /sap/c4c/api/v1/       โ”‚
โ”‚    case-service/cases   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Related MCP server: SAP CPI MCP Server

๐Ÿ—‚๏ธ Project Structure

File / Folder

Purpose

srv/services.cds

CAP service definition โ€” public API contract

srv/services.js

CAP service implementation โ€” handler logic

srv/external/SalesSvcCloudV2_case.cds

Auto-generated CDS model from cds import โ€” describes the remote REST API

srv/external/SalesSvcCloudV2_case.json

Original OpenAPI spec from SAP Sales Cloud V2

package.json โ†’ cds.requires

Remote service binding โ€” credentials & kind


๐Ÿ”‘ Key Concepts

1. Dual Protocol โ€” OData V4 + MCP

The service is annotated with both protocols:

annotate CaseServices with @protocol: ['odata-v4', 'mcp'];

This means the same service is reachable as an OData V4 endpoint and as an MCP (Model Context Protocol) tool โ€” usable by AI agents.


2. External Service Import

The remote SAP Sales Cloud V2 API was imported using:

cds import SalesSvcCloudV2_case.json --as cds

This generates SalesSvcCloudV2_case.cds โ€” a CDS description of the remote REST API. It is used as documentation/metadata only, not invoked by name.


3. kind: "rest" โ€” Not OData

The remote service is bound as a plain REST adapter in package.json:

"SalesSvcCloudV2_case": {
  "kind": "rest",
  "model": "srv/external/SalesSvcCloudV2_case",
  "service": "Case.Service"
}
  • kind: "rest" โ†’ CAP uses an HTTP client, not an OData client

  • service: "Case.Service" โ†’ maps the requires key to the actual service definition inside the CDS model (namespace ![Case]; service Service {})

  • Because it is REST (not OData), there are no entities โ€” c4c.entities is empty


4. c4c.send() โ€” Why Not SELECT.from()

Method

Use when

SELECT.from(c4c.entities.X)

Remote service has OData entities

c4c.send({ method, path, data })

Remote service is REST with functions/actions only

Since SalesSvcCloudV2_case.cds defines only functions (no entities), c4c.send() is used to make a direct HTTP call to the remote path annotated with @openapi.path.


5. Handler Registration & Service Name Matching

CAP wires the JS class to the CDS service via the export key โ€” it must match the CDS service name exactly:

// services.js
module.exports = { CaseServices: CaseService };
//                  โ†‘ must match service name in services.cds

Handlers are registered inside init() using the exact function/action name from services.cds:

this.on("listCases", async (req) => { ... });
//       โ†‘ must match function name in services.cds

๐Ÿš€ Operations

Operation

Type

HTTP

Remote Path

listCases

function

GET

/sap/c4c/api/v1/case-service/cases

getCaseById

function

GET

/sap/c4c/api/v1/case-service/cases/{id}

createCase

action

POST

/sap/c4c/api/v1/case-service/cases

patchCase

action

PATCH

/sap/c4c/api/v1/case-service/cases/{id}


โ–ถ๏ธ Running Locally

npm install
cds watch

Service available at: http://localhost:4004/odata/v4/case-services


๐Ÿ”— References

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    Related MCP Connectors

    Related MCP Servers