SAP

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Create an agent from a CAP service

Learn how simple it is to create an agent based on a CAP service.

Overview

You will learn

  • ✔How to turn a CAP service in to a fully functioning agent with a single annotation
DJ Adams D DJ Adams October 14, 2026
Created on October 14, 2026
Contributors

More from DJ Adams

See all 18 tutorials by DJ Adams →

Prerequisites

You will need a development environment for CAP Node.js. See the tutorial Set up a self-contained development environment for CAP Node.js The assumptions in this tutorial are based on option 1 or option 2 in that tutorial, in that you have a VS Code (or GitHub Codespace) environment based on the foundation repository used in the setup described there, which also means that your starting directory will be /workspaces/cap-nodejs-dev-env. If you have your own CAP Node.js development environment setup, then please make the appropriate adjustments where necessary.

Steps

Intro

The agentic AI era is truly upon us. Agents, as independent self-contained units of reasoning & acting towards a goal, accessed via natural language conveyed over the open agent-to-agent (A2A) protocol, are important components.

There are many ways to create agents, but perhaps one of the most straightforward, especially in the context of a service that we want an agent to help us with and be an expert in, is to use CAP and the @agent annotation.


Step 1 Set up a simple CAP service
—

To have a service from which we can create an agent, let’s set up a very simple CAP project with a basic “books” oriented service. Conveniently there’s the tiny-sample facet which we can use.

👉 Create a new CAP project using this facet, plus the nodejs facet:

Shell
cds init --add tiny-sample,nodejs cap-create-agent

We’re adding the nodejs facet so that we have a package.json file, as we’ll be installing a package with npm later.

👉 Now open the new cap-create-agent/ directory in a new VS Code / Codespace window:

Shell
code cap-create-agent/

This should place you and any new terminal session in the new cap-create-agent/ directory.

There’s a simple CatalogService with a single Books entity, for which there are a handful of records. Let’s have a quick look.

👉 Start the server with cds watch, which should cause log lines as shown below to be emitted:

Log
[cds] - loaded model from 1 file(s):
 
  srv/cat-service.cds

[cds] - using bindings from: { registry: '~/.cds-services.json' }
[cds] - connect to db > sqlite { database: ':memory:' }
  > init from db/data/CatalogService.Books.csv 
/> successfully deployed to in-memory database. 

[cds] - serving CatalogService {
  at: [ '/odata/v4/catalog' ],
  decl: 'srv/cat-service.cds:1'
}
[cds] - server listening on { url: 'http://localhost:4004' }

The path on which CatalogService is served - /odata/v4/catalog - indicates that this is OData v4.

Step 2 Add the agents plugin
+
Step 3 Add an @agent annotation
+
Step 4 Restart the CAP server
+
Step 5 Check the CAP server welcome page
+
Step 6 Explore the two standard A2A endpoints
+
Step 7 Explore the Preview facility in mock LLM mode
+
Step 8 Wrap-up and further info
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 8
1. Set up a simple CAP service 2. Add the agents plugin 3. Add an @agent annotation 4. Restart the CAP server 5. Check the CAP server welcome page 6. Explore the two standard A2A endpoints 7. Explore the Preview facility in mock LLM mode 8. Wrap-up and further info