CDS pluginCDS plugintypeInstalls into a CAP project and extends the runtime. CAP loads it through cds.requires or the plugin hook.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

@geertjanklaps/cds-toon-ai-protocol-adapter

A protocol adapter that serves CAP data as TOON — Token-Oriented Object Notation — instead of JSON, so a payload bound for a language model costs fewer tokens to send.

The cost nobody budgets for: JSON spends tokens on punctuation and repeated keys, and every one is billed on the way into a model. The adapter converts in both directions at the protocol layer, in a REST variant and an OData one, so the service code and the model stay as they were and only the wire format changes. It counts tokens on both sides and logs the comparison, which is how you find out whether it earned its place.

Facts

Latestv1.0.2ReleasedLast pushLicenceMIT

Where it sits

Lives in
Provides
LLM integrationCAPLLM integrationcapabilityCalling a language model from application code with the tenant, destination and credential handling already solved instead using an SDK call with a hand-rolled key.
Flavors
Node.jsfrom its runtime
Requires
@sap/cds≥ 9@sap/cdsartifactThe peer range, as published.

Who is behind it

Geert-Jan KlapsGeert-Jan KlapsPersonMaintains this
In the atlas: maintains 4, contributes to 11, wrote 4
@geert-janklaps
maintainer

Before choosing this

Conditions

LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
  • § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
  • § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
  • § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
SAP Developer License Agreement 3.2 CAP →

Also, from LLM integration§ 3: Calling a model for inference is not automatically AI training. Section 3 matters when the covered material or application participates in training, model development, refinement or the text-and-data-mining uses it names.

What it declares

Every artifact

Type
CDS plugin
Origin
Independently maintained
Runtime
Node.js

As a CDS plugin

Declared for
>=9
Distributed through
npm

Tasks this contributes to1Beta

Cut the tokens a CAP service spends sending its data to a modelThe same rows a CAP service already hands a model are sent in fewer tokens, so the bill and the latency fall without the service code or the model changing.Shown workingwire format between the service and the model
What it does

Changes the notation and nothing else: the plugin converts between JSON and TOON, Token-Oriented Object Notation, in both directions at the protocol layer, in a REST variant and an OData one, and its README states that this typically reduces token counts while maintaining data integrity. It counts the tokens on both sides and logs the comparison, so the saving on a project's own payloads is measured rather than taken on trust. It calls no model: it sits where the OData and GraphQL adapters sit, and a consumer selects it by content type.

Remaining work

Point whatever assembles the prompt at the adapter's content type, since the saving only happens on calls that go through it, and read the logged counts to find out whether it earned its place on the shapes this project actually sends. Whether a given model reads TOON as reliably as JSON is not addressed by the plugin and was not read here.

All options on the LLM integration page →

Connections1

Install

npm add @geertjanklaps/cds-toon-ai-protocol-adapter

Derived from the package name. No recipe recorded; the README has the configuration.

Learn more1

Readings
  1. cds-toon-ai-protocol-adapter: a pragmatic way to cut AI token costs using SAP CAPGeert-Jan Klaps, SAP Community

README

quoted from geert-janklaps/cds-toon-ai-protocol-adapter under MIT, read
geert-janklaps/cds-toon-ai-protocol-adapter/README.mdOn GitHub

TOON AI Protocol Adapter Plugin for SAP CAP

Token-Oriented Object Notation (TOON) protocol adapter for SAP Cloud Application Programming Model (CAP)

npm version License: MIT

Overview

The TOON AI Protocol Adapter Plugin extends SAP Cloud Application Programming Model (CAP) with support for the TOON (Token-Oriented Object Notation) format. This plugin provides automatic conversion between JSON and TOON format, optimizing data exchange for AI applications by typically reducing token counts while maintaining data integrity.

Key Features
  • 🚀 Two Protocol Variants: REST-based (toon) and OData-based (toon-odata) adapters
  • 🔄 Bidirectional Conversion: Automatic JSON ↔ TOON format conversion
  • 📊 Token Count Optimization: Built-in token statistics and smart content-type selection
  • 🔧 Configurable Processing: Flexible request/response processing controls
  • 📈 Performance Monitoring: Real-time token count comparison and logging
  • 🔌 Plugin Architecture: Easy integration with existing CAP applications

TOON protocol adapter in action

Installation

npm install @geertjanklaps/cds-toon-ai-protocol-adapter
Dependencies
  • @sap/cds: >=9 (peer dependency)
  • @toon-format/toon: ^2.1.0
  • tokenx: ^1.3.0

Quick Start

1. Basic Service Configuration

Define a CAP service with TOON protocol support:

// srv/my-service.cds
@protocol: ['toon']
service MyTOONService {
}
2. Alternative: OData + TOON Protocol

For OData compatibility with TOON optimization:

// srv/my-service.cds
@protocol: ['toon-odata']
service MyTOONODataService {
}

Protocol Endpoints

The plugin automatically creates endpoints for your services:

REST Protocol (@protocol: ['toon'])
  • Base URL: http://localhost:4004/toon/
  • Service Path: /toon/{service-name}/{function-or-action}
  • Example: GET /toon/my-toon-service/getData
OData Protocol (@protocol: ['toon-odata'])
  • Base URL: http://localhost:4004/toon-odata/
  • Service Path: /toon-odata/{service-name}/{function-or-action}
  • Example: GET /toon-odata/my-toon-odata-service/getData

Configuration

Configure the plugin behavior in your package.json:

{
  "cds": {
    "toonAdapter": {
      "requestProcessingEnabled": false,
      "responseProcessingEnabled": true,
      "logTokenStatistics": true,
      "autoDetermineResponseContentType": true
    }
  }
}
Configuration Parameters
ParameterTypeDefaultDescription
requestProcessingEnabledbooleanfalseEnable automatic conversion of incoming TOON requests to JSON
responseProcessingEnabledbooleantrueEnable automatic conversion of JSON responses to TOON format
logTokenStatisticsbooleantrueLog token count comparisons between JSON and TOON formats
autoDetermineResponseContentTypebooleantrueAutomatically choose between JSON/TOON based on token efficiency

Usage Examples

Making Requests
JSON Request (Standard)
GET /toon-odata/catalog/Books?$select=createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code
Content-Type: application/json
Response Formats
JSON Response (auto-selected when more efficient)
{
  "@odata.context": "$metadata#Books",
  "value": [
    {
      "createdAt": "2026-01-25T18:27:05.907Z",
      "createdBy": "anonymous",
      "modifiedAt": "2026-01-25T18:27:05.907Z",
      "modifiedBy": "anonymous",
      "ID": 201,
      "title": "Wuthering Heights",
      "author_ID": 101,
      "genre_ID": 11,
      "stock": 12,
      "price": 11.11,
      "currency_code": "GBP"
    },
    {
      "createdAt": "2026-01-25T18:27:05.907Z",
      "createdBy": "anonymous",
      "modifiedAt": "2026-01-25T18:27:05.907Z",
      "modifiedBy": "anonymous",
      "ID": 207,
      "title": "Jane Eyre",
      "author_ID": 107,
      "genre_ID": 11,
      "stock": 11,
      "price": 12.34,
      "currency_code": "GBP"
    },
    {
      "createdAt": "2026-01-25T18:27:05.907Z",
      "createdBy": "anonymous",
      "modifiedAt": "2026-01-25T18:27:05.907Z",
      "modifiedBy": "anonymous",
      "ID": 251,
      "title": "The Raven",
      "author_ID": 150,
      "genre_ID": 16,
      "stock": 333,
      "price": 13.13,
      "currency_code": "USD"
    },
    {
      "createdAt": "2026-01-25T18:27:05.907Z",
      "createdBy": "anonymous",
      "modifiedAt": "2026-01-25T18:27:05.907Z",
      "modifiedBy": "anonymous",
      "ID": 252,
      "title": "Eleonora",
      "author_ID": 150,
      "genre_ID": 16,
      "stock": 555,
      "price": 14,
      "currency_code": "USD"
    },
    {
      "createdAt": "2026-01-25T18:27:05.907Z",
      "createdBy": "anonymous",
      "modifiedAt": "2026-01-25T18:27:05.907Z",
      "modifiedBy": "anonymous",
      "ID": 271,
      "title": "Catweazle",
      "author_ID": 170,
      "genre_ID": 13,
      "stock": 22,
      "price": 150,
      "currency_code": "JPY"
    }
  ]
}
TOON Response (default when responseProcessingEnabled: true)
[5]{createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code}:
  "2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,201,Wuthering Heights,101,11,12,11.11,GBP
  "2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,207,Jane Eyre,107,11,11,12.34,GBP
  "2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,251,The Raven,150,16,333,13.13,USD
  "2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,252,Eleonora,150,16,555,14,USD
  "2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,271,Catweazle,170,13,22,150,JPY

Token Count Optimization

The plugin provides intelligent token count optimization:

Automatic Content Type Selection

When autoDetermineResponseContentType is enabled:

  • JSON: Used when JSON format has fewer tokens
  • TOON: Used when TOON format has fewer tokens (typical case)
Token Statistics Logging

When logTokenStatistics is enabled, the plugin logs:

[toon] - Token count - JSON: 150, TOON: 95, Difference: 55 (36.7%)

Advanced Configuration

Custom Protocol Registration

The plugin automatically registers protocols, but you can customize them:

// cds-plugin.js
const cds = require("@sap/cds");

cds.protocol.toon = {
  path: "/custom-toon",
  impl: "@geertjanklaps/cds-toon-ai-protocol-adapter",
};
Environment-Specific Settings
{
  "cds": {
    "profiles": {
      "production": {
        "toonAdapter": {
          "logTokenStatistics": false,
          "autoDetermineResponseContentType": true
        }
      },
      "development": {
        "toonAdapter": {
          "logTokenStatistics": true,
          "autoDetermineResponseContentType": false
        }
      }
    }
  }
}

Testing Your Implementation

Use the provided test files as reference:

### OData GET request
GET http://localhost:4004/odata/v4/catalog/Books?$select=createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code
Content-Type: application/json; charset=utf-8
Authorization: Basic alice:

### TOON OData GET Request
GET http://localhost:4004/toon-odata/catalog/Books?$select=createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code
Content-Type: application/json; charset=utf-8
Authorization: Basic alice:

When to Use

Ideal Use Cases
  • AI/LLM Integration: Optimize token usage for AI model communication
  • Large Data Payloads: Reduce bandwidth and token costs for complex responses
  • Real-time Applications: Minimize payload size for faster transmission
  • Cost Optimization: Reduce AI API costs through token count reduction
Performance Benefits
  • Token Reduction: Typically 20-50% fewer tokens compared to JSON
  • Bandwidth Optimization: Smaller payload sizes
  • AI Cost Reduction: Lower token consumption in AI model interactions

API Reference

Adapters
TOONAdapter

Extends SAP CAP's REST adapter with TOON protocol support.

TOONODataAdapter

Extends SAP CAP's OData adapter with TOON protocol support.

Troubleshooting

Common Issues
  1. Plugin Not Loading

    • Ensure plugin is in dependencies, not devDependencies
    • Check CDS version compatibility (>=9 required)
  2. TOON Endpoints Not Available

    • Verify service has @protocol annotation
    • Check service registration in CDS
  3. Token Statistics Not Showing

    • Enable logTokenStatistics: true in configuration
    • Check log level configuration
Debug Logging

Enable debug logging:

DEBUG=toon cds watch

Contributing

Contributions are welcome! Please submit pull requests to the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

  • @toon-format/toon: Core TOON format implementation
  • @sap/cds: SAP Cloud Application Programming Model
  • tokenx: Token counting utilities

MIT, read

History

Latest

v1.0.2

  1. v1.0.1

    Features 1

    Notes
    Additional Changes
3downloads per week, npm
Weekly downloads for @geertjanklaps/cds-toon-ai-protocol-adapter26 complete calendar weeks from 2026-04-27 to 2026-10-25; the latest total is 3.27 Apr – 3 May: 54 May – 10 May: 1311 May – 17 May: 618 May – 24 May: 1025 May – 31 May: 81 Jun – 7 Jun: 128 Jun – 14 Jun: 515 Jun – 21 Jun: 1222 Jun – 28 Jun: 629 Jun – 5 Jul: 146 Jul – 12 Jul: 513 Jul – 19 Jul: 620 Jul – 26 Jul: 527 Jul – 2 Aug: 13 Aug – 9 Aug: 510 Aug – 16 Aug: 1017 Aug – 23 Aug: 924 Aug – 30 Aug: 631 Aug – 6 Sept: 97 Sept – 13 Sept: 414 Sept – 20 Sept: 721 Sept – 27 Sept: 428 Sept – 4 Oct: 35 Oct – 11 Oct: 412 Oct – 18 Oct: 219 Oct – 25 Oct: 3
LLM integration
  1. llm_clientABAP client with one interface to chat-completion LLM APIsfrom ABAP
  2. abap-agent-runtimeABAP-native MCP endpoint that drives opted-in abap2UI5 appsfrom ABAP
  3. abap_btocs_ollamaB-Tocs ABAP SDK plugin connecting to Ollama modelsfrom ABAP
  4. SAP AI CoreAI runtime on BTP with the Generative AI Hubfrom BTP/BAIP
  5. cap-java/cds-aiBridge from CAP Java to SAP AI Core, with Fiori field recommendationsfrom CAP
  6. @cap-js/aiValue-help recommendations and SAP AI Core as a CAP servicefrom CAP
  7. cap-llm-pluginGenerative AI in CAP with fields anonymised through SAP HANAfrom CAP
  8. abap-sdk-nwas-xABAP client library for IBM watsonx.ai APIsfrom ABAP
  9. @jerome-benoit/sap-ai-providerVercel AI SDK provider for SAP AI Corefrom CAP
  10. ui5-cap-ai-featuresCDS plugin and UI5 controls for AI text features via SAP AI Corefrom CAP
  11. Microsoft AI SDK for SAPABAP library for calling Azure OpenAI and OpenAIfrom ABAP
  12. zllmABAP framework for chaining and orchestrating LLM callsfrom ABAP
  13. ABAP AI SDKSAP reuse library for calling large language models from ABAPfrom ABAP
  14. @sap-ai-sdk/ai-apiAI Core control plane API surface of SAP's AI SDKfrom CAP
  15. @sap-ai-sdk/coreShared internals of SAP's AI SDKfrom CAP
  16. @sap-ai-sdk/foundation-modelsClient for foundation models via SAP AI Core and Generative AI Hubfrom CAP
  17. @sap-ai-sdk/orchestrationOrchestration Service client for templating, grounding and maskingfrom CAP
  18. @sap-ai-sdk/prompt-registryClient for prompts kept in SAP's prompt registryfrom CAP
  19. @saptarishi/cds-plugin-llmCAP service kind putting eleven model providers behind one APIfrom CAP
  20. @shahid.la/cds-db-nlquery-mcpMCP server answering plain-English questions against a CDS schemafrom CAP
  21. @ui5/webcomponentsSAP's UI elements as standard custom elementsfrom UI5
  22. abap-sdk-nwasAn ABAP client library for IBM Watson's Discovery, Language Translator, Natural Language Understanding, Speech to Text, Text to Speech and Assistant services, installed through abapGit.from ABAP

Details

Sources5
npm registrydiscovered herechecked
SAP Communitydiscovered here, cap-tagchecked
npm registry, @geertjanklaps/cds-toon-ai-protocol-adapterversion, releases, installschecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
runtimesnode
declared for>=9
latestv1.0.2
first release
releases and cadence3, ~0d median
discovered vianpm registry, SAP Community · cap-tag
first seen in the atlas
ecosystem and domaincap, ai-and-agents
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:geertjanklaps-cds-toon-ai-protocol-adapter
JSON
/artifacts/geertjanklaps-cds-toon-ai-protocol-adapter.json
MCP
Connecting an agent