@gavdi/cap-mcp
Exposes annotated SAP CAP services as MCP tools, enabling agents to query and retrieve CAP entities, invoke functions and actions, and optionally perform writes under CAP authentication and authorization.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
@gavdi/cap-mcp
Pre-release version
Expose SAP CAP services to AI agents over the Model Context Protocol.
Annotate a service with @mcp, and agents can query it through MCP clients such as desktop
chat apps, IDEs and agent frameworks. The plugin is a thin, stateless adapter: CAP authenticates
every request, enforces @requires and @restrict, runs your handlers and owns the
transaction, exactly as it does for OData. Nothing is exposed unless you annotate it.
One endpoint,
/mcp, for all annotated services, serving MCP 2026-07-28 and 2025-era clientsA read-only baseline from one annotation; writes, actions and every MCP feature are opt-in
Tools with JSON Schema inputs and outputs, paging with totals, CAP search, structured errors
Resources, prompts, MCP Apps UI, user confirmation (MRTR) and key completion
Resources from code: other plugins and app code add documents through
mcp:resourcesHints from code: other plugins and app code add to server instructions and tool descriptions through
mcp:hintsXSUAA and IAS (also with X.509 credentials),
@sap/ams, multitenant XSUAA, RFC 9728 metadataA startup report that tells you what is served and what in your model needs a look
Install
npm add @gavdi/cap-mcpRequires Node.js 22 or later, with @sap/cds 10 and express 5 as peer dependencies. A new CAP
major gets a plugin release once it is tested: the plugin reads some of CAP's behaviour (row limits,
@restrict) the way CAP does, which a major may change.
CAP loads the plugin automatically; there is no immediate integration code to write.
Related MCP server: CAP MCP Plugin
Quickstart
Annotate a service, or let cds add mcp --service CatalogService write
annotate CatalogService with @mcp; to srv/mcp.cds for you:
/** Browse the bookshop catalog. */
@mcp // read-only baseline: query + get for entities, plus functions
service CatalogService {
entity Books { key ID : Integer; title : String; stock : Integer; costPrice : Decimal; }
@mcp // actions are opt-in
action submitOrder(book : Integer, quantity : Integer);
}
annotate CatalogService.Books with { costPrice @mcp.omit; }; // never visible to agentscds watch[mcp] - serving 3 tools, 0 resources, 0 prompts at /mcpThe tools are CatalogService_Books_query, CatalogService_Books_get and
CatalogService_submitOrder, at http://localhost:4004/mcp.
Connect a client. Clients that speak Streamable HTTP (the
MCP Inspector, many desktop and IDE
clients) take the URL directly. With CAP's mocked auth, send a mocked user as
Authorization: Basic …; each user sees what CAP lets them use. Clients that only start local
processes over stdio use a bridge such as mcp-remote:
{
"mcpServers": {
"bookshop": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:4004/mcp",
"--header",
"Authorization: Basic YWxpY2U6YWxpY2U="
]
}
}
}Getting started walks through it step by step.
Everything is opt-in
What | How |
Query and get tools for each entity |
|
Functions |
|
Actions |
|
Create, update, delete |
|
Nested children in writes |
|
Hide a field |
|
Single records as resources |
|
Prompts |
|
MCP Apps UI |
|
Documents as resources, from code |
|
Hints in instructions and tools |
|
User confirmation before a call |
|
Key completion |
|
Model description tool |
|
Compact generic tool set |
|
@mcp: false or @cds.api.ignore excludes an entity. No configuration switches a feature on.
See the annotation reference.
Security model
CAP does the security work; the plugin never re-implements it.
Authentication is CAP's:
/mcpruns behind CAP's own middlewares, so whatever authenticates OData authenticates MCP. With XSUAA, IAS or JWT, an unauthenticated request gets401with an RFC 9728resource_metadatapointer naming your authorization server. In production, CAP'srestrict_all_servicesapplies to/mcptoo.Enforced by CAP on every call:
@requires,@restrict(includingwhere),@sap/amspolicies, input validation and your handlers. A user gets over MCP exactly what they get over OData. Each call runs in the caller'scds.contextand one transaction, rolled back on error.Hidden by the plugin, for the agent's sake:
tools/listleaves out tools CAP would always refuse for the caller. That is advertising, not enforcement.Said by the plugin, for the agent's sake: when every grant that lets the caller read an entity has a
where, its query and get tools say that authorization limits the records, so an agent does not take an empty result for "does not exist". The condition is never shown (ADR 0015;filterNotices: falseturns it off).Never exposed:
@mcp.omitfields, entities and operations you did not annotate, and actions without their own@mcp.Browser requests (DNS rebinding): a request with an
Originheader gets403unless that origin is listed inallowedOrigins, even your app's own. Desktop clients and bridges send noOriginand are not affected; browser-based clients and web apps must be listed.
Read Authentication and production before you deploy.
Configuration
Optional, in cds.mcp (package.json or .cdsrc.json, profiles work as usual). No key turns
a feature on.
Key | Default | Meaning |
|
| Endpoint path |
|
| Server identity shown to clients; set them to tell apps apart |
| none | Instructions for agents: a string, or |
| none | Browser origins that may call |
| none | Multitenant XSUAA: regular expression over the request host, first group = subscriber subdomain |
|
| Upper bound for |
|
| Page size when the agent gives none |
|
|
|
{
"cds": {
"mcp": {
"name": "bookshop",
"version": "1.0.0",
"instructions": { "file": "mcp-instructions.md" },
"limits": { "maxRows": 100 }
}
}
}An unknown key or a value of the wrong shape is reported at startup and that key's default is
used. cds build copies the instructions file into the deployed app.
Compatibility
MCP | 2026-07-28 (stateless), and 2025-era clients (2025-11-25 back to 2024-11-05) without sessions |
MCP Apps | The MCP Apps extension: |
CAP |
|
Node.js | 22 or later |
Express | 5 |
Migrating from v1
v2 reads v1 annotations through a shim and reports at startup what to change. Operation tools
are renamed, writes and the describe tool are no longer on by default, and CAP's own auth
replaces auth: 'none'. See Migrating from v1.
Guides
Contributing
See CONTRIBUTING.md.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Guarded MCP server for agent-readable business truth, provenance, readiness, and discovery.
MCP server for OnceAsk, the AI-native current-address layer for people and agents.
Related MCP Servers
AlicenseNot gradedqualityAmaintenanceMCP server for SAP CAP that enables AI-assisted development by searching CDS model definitions and CAP documentation.60,616 npm118Apache 2.0- AlicenseNot gradedqualityBmaintenanceA CAP plugin that automatically generates MCP servers from your CAP services, transforming OData services into AI-accessible resources, tools, and prompts with minimal configuration.866 npm61Apache 2.0
- AlicenseNot gradedqualityDmaintenanceDynamically generates MCP tools from any OData or OpenAPI spec, enabling natural-language queries via SAP AI Core.MIT
- FlicenseNot gradedqualityDmaintenanceExposes a CAP bookshop service via MCP, enabling AI agents to query books, authors, and genres using natural language.-