by gavdilabs
Enables CAP services to be exposed as Model Context Protocol servers, turning OData entities, actions, and functions into AI‑accessible resources, tools, and reusable prompt templates.
Cap Mcp Plugin automatically generates Model Context Protocol (MCP) servers from annotated SAP CAP services. By adding @mcp annotations to entities, functions, and actions, the plugin creates AI‑readable resources, executable tools, and prompt definitions without manual server code.
npm install @gavdi/cap-mcp
package.json (or .cdsrc):
{
  "cds": {
    "mcp": {
      "name": "my-bookshop-mcp",
      "auth": "inherit",
      "wrap_entities_to_actions": false,
      "wrap_entity_modes": ["query", "get"],
      "instructions": "MCP server instructions for agents"
    }
  }
}
@mcp (entities, tools, prompts, etc.).cds serve
http://localhost:4004/mcp with a health check at http://localhost:4004/mcp/health.npx @modelcontextprotocol/inspector
filter, orderby, select, top, skip).query, get, create, update) for entities.inherit or none), capability toggles, and versioning./mcp/health and configurable debug logging.Q: Which Node.js version is required? A: Node.js 18 or higher.
Q: Do I need to write any server code? A: No. The plugin integrates automatically after installation and configuration.
Q: How is authentication handled?
A: Set auth to inherit to reuse the CAP app’s authentication (e.g., XSUAA) or none for development testing only.
Q: Can I expose only selected OData query options?
A: Yes. Use the resource array in the @mcp annotation to list desired options or set it to true for all.
Q: How do I test the MCP server locally?
A: Use the MCP Inspector (npx @modelcontextprotocol/inspector) or the provided Bruno collection under the bruno/ folder.
Q: What if I need custom prompt templates?
A: Add an @mcp.prompts annotation at the service level with name, title, description, template, and inputs definitions.
 
 
 
This implementation is based on the Model Context Protocol (MCP) put forward by Anthropic. For more information on MCP, please have a look at their official documentation.
A CAP (Cloud Application Programming) plugin that automatically generates Model Context Protocol (MCP) servers from your CAP services using simple annotations. Transform your CAP OData services into AI-accessible resources, tools, and prompts with minimal configuration.
The Model Context Protocol bridges the gap between your enterprise data and AI agents. By integrating MCP with your CAP applications, you unlock:
npm install @gavdi/cap-mcp
The plugin follows CAP's standard plugin architecture and will automatically integrate with your CAP application upon installation.
Add MCP configuration to your package.json:
{
  "cds": {
    "mcp": {
      "name": "my-bookshop-mcp",
      "auth": "inherit",
      "wrap_entities_to_actions": false,
      "wrap_entity_modes": ["query", "get"],
      "instructions": "MCP server instructions for agents"
    }
  }
}
Annotate your CAP services with @mcp annotations:
// srv/catalog-service.cds
service CatalogService {
  @mcp: {
    name: 'books',
    description: 'Book catalog with search and filtering',
    resource: ['filter', 'orderby', 'select', 'top', 'skip']
  }
  entity Books as projection on my.Books;
  // Optionally expose Books as tools for LLMs (query/get enabled by default config)
  annotate CatalogService.Books with @mcp.wrap: {
    tools: true,
    modes: ['query','get'],
    hint: 'Use for read-only lookups of books'
  };
  @mcp: {
    name: 'get-book-recommendations',
    description: 'Get personalized book recommendations',
    tool: true
  }
  function getRecommendations(genre: String, limit: Integer) returns array of String;
}
cds serve
The MCP server will be available at:
http://localhost:4004/mcphttp://localhost:4004/mcp/healthnpx @modelcontextprotocol/inspector
Connect to http://localhost:4004/mcp to explore your generated MCP resources, tools, and prompts.
This plugin transforms your annotated CAP services into a fully functional MCP server that can be consumed by any MCP-compatible AI client.
query, get, and optionally create, update) for LLM tool use while keeping resources intactnpm testnpm run mocknpx @modelcontextprotocol/inspectorThe bruno/ folder contains HTTP requests for the MCP endpoint (handy for local manual testing using Bruno or any HTTP client). You may add calls for tools/list and tools/call to exercise the new wrapper tools.
Transform CAP entities into AI-queryable resources:
service CatalogService {
  @readonly
  @mcp: {
    name       : 'books',
    description: 'Book data list',
    resource   : [
      'filter',
      'orderby',
      'select',
      'skip',
      'top'
    ]
  }
  entity Books as projection on my.Books;
  // Enable all OData query options
  @mcp: {
    name       : 'authors',
    description: 'Author data list',
    resource   : true
  }
  entity Authors as projection on my.Authors;
  // Or maybe you just want it as a static top 100 list of data?
  @mcp: {
    name       : 'genres',
    description: 'Book genre list',
    resource   : []
  }
  entity Genres as projection on my.Genres;
}
Generated MCP Resource Capabilities:
$filter, $orderby, $top, $skip, $selectWhen wrap_entities_to_actions is enabled (globally or via @mcp.wrap.tools: true), you will see tools named like:
CatalogService_Books_queryCatalogService_Books_getCatalogService_Books_create (if enabled)CatalogService_Books_update (if enabled)Each tool includes a description with fields and OData notes to guide the model. You can add @mcp.wrap.hint per entity to enrich descriptions for LLMs.
Example:
  // Wrap Books entity as tools for query/get/create/update (demo)
  annotate CatalogService.Books with @mcp.wrap: {
    tools: true,
    modes: [
      'query',
      'get',
      'create',
      'update'
    ],
    hint : 'Use for read and write demo operations'
  };
Convert CAP functions and actions into executable AI tools:
// Service-level function
@mcp: {
  name       : 'get-author',
  description: 'Gets the desired author',
  tool       : true
}
function getAuthor(input: String) returns String;
// Entity-level action
extend projection Books with actions {
  @mcp: {
    name       : 'get-stock',
    description: 'Retrieves stock from a given book',
    tool       : true
  }
  function getStock() returns Integer;
}
Request user confirmation or input before tool execution using the elicit property:
// Request user confirmation before execution
@mcp: {
  name       : 'book-recommendation',
  description: 'Get a random book recommendation',
  tool       : true,
  elicit     : ['confirm']
}
function getBookRecommendation() returns String;
// Request user input for parameters
@mcp: {
  name       : 'get-author',
  description: 'Gets the desired author',
  tool       : true,
  elicit     : ['input']
}
function getAuthor(id: String) returns String;
// Request both input and confirmation
@mcp: {
  name       : 'books-by-author',
  description: 'Gets a list of books made by the author',
  tool       : true,
  elicit     : ['input', 'confirm']
}
function getBooksByAuthor(authorName: String) returns array of String;
NOTE: Elicitation is only available for direct tools at this moment. Wrapped entities are not covered by this.
Elicit Types:
confirm: Requests user confirmation before executing the tool with a yes/no promptinput: Prompts the user to provide values for the tool's parameters['input', 'confirm'] to first collect parameters, then ask for confirmationUser Experience:
Define reusable AI prompt templates:
annotate CatalogService with @mcp.prompts: [{
  name       : 'give-me-book-abstract',
  title      : 'Book Abstract',
  description: 'Gives an abstract of a book based on the title',
  template   : 'Search the internet and give me an abstract of the book {{book-id}}',
  role       : 'user',
  inputs     : [{
    key : 'book-id',
    type: 'String'
  }]
}];
Configure the MCP plugin through your CAP application's package.json or .cdsrc file:
{
  "cds": {
    "mcp": {
      "name": "my-mcp-server",
      "version": "1.0.0",
      "auth": "inherit",
      "instructions": "mcp server instructions for agents",
      "capabilities": {
        "resources": {
          "listChanged": true,
          "subscribe": false
        },
        "tools": {
          "listChanged": true
        },
        "prompts": {
          "listChanged": true
        }
      }
    }
  }
}
| Option | Type | Default | Description | 
|---|---|---|---|
| name | string | package.json name | MCP server name | 
| version | string | package.json version | MCP server version | 
| auth | "inherit"|"none" | "inherit" | Authentication mode | 
| instructions | string | null | MCP server instructions for agents | 
| capabilities.resources.listChanged | boolean | true | Enable resource list change notifications | 
| capabilities.resources.subscribe | boolean | false | Enable resource subscriptions | 
| capabilities.tools.listChanged | boolean | true | Enable tool list change notifications | 
| capabilities.prompts.listChanged | boolean | true | Enable prompt list change notifications | 
The plugin supports two authentication modes:
"inherit" Mode (Default)Uses your CAP application's existing authentication system:
{
  "cds": {
    "mcp": {
      "auth": "inherit"
    },
    "requires": {
      "auth": {
        "kind": "xsuaa"
      }
    }
  }
}
"none" Mode (Development/Testing)Disables authentication completely:
{
  "cds": {
    "mcp": {
      "auth": "none"
    }
  }
}
⚠️ Security Warning: Only use "none" mode in development environments. Never deploy to production without proper authentication.
/mcp endpointauth: "inherit")The plugin automatically:
@mcp annotations/mcp and /mcp/healthOnce configured, AI agents can interact with your CAP data naturally; Let's take an example from the standard CAP Bookshop:
$orderby=stock desc&$top=5$filter=contains(name,'Smith') on Authors resourceget-stock tool for the specified bookbook-recommendation toolWhile this shows how this example CDS annotation works, the possibilities are endless and only you and your data sets the boundaries.
Your CAP service includes a workflow management system with MCP integration:
service WorkflowService {
  @mcp: {
    name       : 'get-my-pending-approval',
    description: 'Fetches workflows awaiting approval by the specified user',
    tool       : true
  }
  function getPendingApproval(userId: String) returns array of Workflows;
}
1. User Query
User: "Hey <Agent>, do I have any workflows pending approval?"
2. AI Agent Processing
get-my-pending-approval tool as the appropriate method3. MCP Tool Execution
// Agent calls the MCP tool
{
  "tool": "get-my-pending-approval",
  "arguments": {
    "userId": "john.doe@company.com"
  }
}
4. CAP Service Processing
getPendingApproval("john.doe@company.com")5. AI Response
Agent: "You have 3 workflows pending your approval:
• **Purchase Order #PO-2024-001**
  Submitted by: Sarah Johnson
  Amount: $12,500
  Submitted: 2 days ago
• **Budget Request - Marketing Q2**
  Submitted by: Mike Chen
  Amount: $45,000
  Submitted: 1 day ago
• **New Employee Onboarding - Jane Smith**
  Submitted by: HR Department
  Start Date: Next Monday
  Submitted: 4 hours ago
Would you like me to help you review any of these in detail?"
If you want to test the MCP implementation you have made on your CAP application locally, you have 2 options available (that does not involve direct integration with AI Agent).
You can inspect the MCP implementation by utilizing the official @modelcontextprotocol/inspector.
This inspector can be started up through either the included npm run inspect command, or by running npx @modelcontextprotocol/inspector.
For plugin implementation implementation in your own project it is recommended to add the above command to your own script collection.
For more information on the inspector, please see the official documentation.
This repository comes with a Bruno collection available that includes some example queries you can use to verify your MCP implementation. These can be found in the bruno directory.
Run the comprehensive test suite to validate your implementation:
# Test specific components
npm test -- --testPathPattern=annotations  # Test annotation parsing
npm test -- --testPathPattern=mcp          # Test MCP functionality
npm test -- --testPathPattern=security     # Test security boundaries
npm test -- --testPathPattern=auth         # Test authentication
# Run with detailed output
npm test -- --verbose
# Run in watch mode for development
npm test -- --watch
docs/entity-tools.mdContributions are welcome! This is an open-source project aimed at bridging CAP applications with the AI ecosystem.
This project is licensed under the Apache-2.0 License - see the LICENSE.md file for details.
cds serveauth: "inherit", ensure your CAP authentication is properly configured# Check if MCP endpoint is accessible
curl http://localhost:4004/mcp/health
# Expected response:
# {"status": "healthy", "timestamp": "2025-01-XX..."}
@mcp annotation syntax matches the examplesresource, tool, prompts)@modelcontextprotocol/sdk bug, provide all query parameters when using dynamic queriesresource arrays instead of true for large datasets{
  "cds": {
    "log": {
      "levels": {
        "mcp": "debug"
      }
    }
  }
}
# Use MCP Inspector for interactive testing
npm run inspect
# Or run integration tests
npm test -- --testPathPattern=integration
@modelcontextprotocol/sdk RFC template string issueresource: ['top'] or similar constraints for entities with many records(c) Copyright by Gavdi Labs 2025 - All Rights Reserved
Transform your CAP applications into AI-ready systems with the power of the Model Context Protocol.
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by zed-industries
A high‑performance, multiplayer code editor designed for speed and collaboration.
by modelcontextprotocol
Model Context Protocol Servers
by modelcontextprotocol
A Model Context Protocol server for Git repository interaction and automation.
by modelcontextprotocol
A Model Context Protocol server that provides time and timezone conversion capabilities.
by cline
An autonomous coding assistant that can create and edit files, execute terminal commands, and interact with a browser directly from your IDE, operating step‑by‑step with explicit user permission.
by continuedev
Enables faster shipping of code by integrating continuous AI agents across IDEs, terminals, and CI pipelines, offering chat, edit, autocomplete, and customizable agent workflows.
by upstash
Provides up-to-date, version‑specific library documentation and code examples directly inside LLM prompts, eliminating outdated information and hallucinated APIs.
by github
Connects AI tools directly to GitHub, enabling natural‑language interactions for repository browsing, issue and pull‑request management, CI/CD monitoring, code‑security analysis, and team collaboration.
by daytonaio
Provides a secure, elastic infrastructure that creates isolated sandboxes for running AI‑generated code with sub‑90 ms startup, unlimited persistence, and OCI/Docker compatibility.