MCP server: the service for AI agents

The Model Context Protocol (MCP) lets an AI agent (Claude, an IDE assistant, an in-house agent…) call "tools". Open RAP Runtime turns the OData service of a RAP BO into an MCP server: each operation becomes a tool, run by the service itself, with the authorizations, the access controls, the validations and the messages of the BO (D47).

1. Describing the tools: rapt mcp

rapt mcp my-project          # or, in VS Code: "RAP: Generate the MCP server of the service"

The command writes rapt/mcp.json, to version with the sources:

{
  "server": {
    "name": "zrt_ui_travel",
    "instructions": "Travel agency. Read with _list and _get before changing; the BO checks each change."
  },
  "tools": {
    "Travel_list": "Lists the travels. Filter by AgencyID, OverallStatus (O open, A accepted, X rejected)…",
    "Travel_acceptTravel": "Accepts a travel: its status becomes A. Refused when the travel is already accepted.",
    "Booking_delete": false
  }
}

2. The tools

ToolOData requestArguments
<Set>_listGET <Set>filter (OData $filter), search, select, orderby, top (50 by default, 1000 at most), skip
<Set>_getGET <Set>(key)the keys
<Set>_createPOST <Set>the editable fields (mandatory ones: required of the schema)
<Set>_updatePATCH <Set>(key)the keys and the fields to change
<Set>_deleteDELETE <Set>(key)the keys
<Set>_create<_Composition>POST <Set>(key)/<_Composition>the keys of the parent and the fields of the child
<Set>_<action>POST <Set>(key)/<namespace>.<action>the keys (except for a static action) and the parameters
<Set>_<function>GET …/<namespace>.<function>(…)same

The input schemas (JSON Schema) come from the OData types: format: uuid, date, date-time, maximum lengths, strings of digits. The read tools are marked readOnlyHint, the deletions destructiveHint.

The result is the JSON of the service without its OData control information; an error of the BO (validation, authorization, lock) comes back as text with its messages and isError: true, so that the agent can correct its request.

3. Running and connecting

The application built with rapt/mcp.json serves the tools on /mcp ("Streamable HTTP" transport of the protocol, JSON responses). With rapt dev, the MCP server tile of the development launchpad points to it.

rapt dev my-project                                          # http://localhost:8080/mcp
claude mcp add --transport http travel http://localhost:8080/mcp   # Claude Code

For a client configured by a file (for example .mcp.json):

{ "mcpServers": { "travel": { "type": "http", "url": "http://localhost:8080/mcp" } } }

4. Security

Connecting an MCP client with OAuth 2.0 (D113)

With AUTH_MODE=oidc and PUBLIC_URL, the application publishes the metadata of the protected resource (RFC 9728) at /.well-known/oauth-protected-resource/mcp (and at /.well-known/oauth-protected-resource):

{
  "resource": "https://helpdesk.example.com/mcp",
  "authorization_servers": ["<OIDC_ISSUER>"],
  "bearer_methods_supported": ["header"],
  "scopes_supported": ["openid", "profile", "email"],
  "resource_name": "zui_helpdesk"
}

A request without a valid token gets a 401 whose WWW-Authenticate header gives resource_metadata="…" (and error="invalid_token" for a refused token, insufficient_scope with a 403). The client then reads the metadata of the identity provider, registers itself (dynamic client registration) or uses a client declared by hand, signs the user in with PKCE and calls /mcp with the token: the tools run with the authorizations of that user.

The identity provider must:

OIDC_MCP_SCOPES (separated by spaces) gives the scopes the clients ask for (scopes_supported); without it, the client chooses.

Limits: KNOWN_GAPS.md.