Skip to main content
Glama
jpnqs

Bookshop MCP Example

by jpnqs
README.md
# Bookshop MCP Example

A minimal [CAP](https://cap.cloud.sap) bookshop sample that exposes its service via the **Model Context Protocol (MCP)**, letting AI agents and LLM tools query it directly.

> Official CAP MCP docs: https://cap.cloud.sap/docs/guides/protocols/mcp

## Setup

```bash
npm install
```

## Run

```bash
cds watch
```

The MCP server starts automatically and is registered with local MCP clients (Claude Code, Opencode).

## How it works

The `CatalogService` in [srv/cat-service.cds](srv/cat-service.cds) is annotated with `@mcp`, which is all that's needed to expose it as an MCP server:

```cds
annotate CatalogService with @mcp;
```

The adapter creates three tools per service:

| Tool | Purpose |
|------|---------|
| `describe` | Returns the data model (entities, actions, functions) |
| `query` | Reads data — supports `select`, `where`, `orderBy`, `limit`, etc. |
| `call_action` | Invokes unbound actions/functions (e.g. `submitOrder`, `checkAvailability`) |

## Try it

With [Claude Code](https://claude.ai/code) or [Opencode](https://opencode.ai) running, just ask:

```
list books with authors and genres
```

## Inspect tools

```bash
npm run inspector
```

Opens the MCP Inspector at `http://localhost:5173`. Connect to `http://localhost:4004/mcp/browse` to browse tools interactively.