Skip to content

Getting Started with Agents

A coding agent needs three things to build on Storelayer: judgment (the skill), concepts and worked workflows (these Markdown docs), and exact contracts (OpenAPI). For live operations it also needs a project API key, used either over plain HTTP or through the Storelayer MCP server.

Terminal window
npx skills add storelayer/skills

The canonical source is skills/storelayer/SKILL.md. Edit it in that repository; this docs site does not keep a second copy. For manual installation, download the raw skill into your agent’s skill directory as storelayer/SKILL.md.

  1. Read /llms.txt — one line per page with a specific description.

  2. Fetch only the relevant pages as Markdown by appending .md, e.g. /guides/loyalty-program.md.

  3. For exact request/response shapes, select the needed paths from /openapi.json (it is large — filter with jq, don’t load it whole):

    Terminal window
    curl -s https://api.storelayer.io/openapi.json \
    | jq '.paths["/projects/{projectId}/users/{userId}/wallet/earn"]'
  4. Implement, then verify against live state (balances, workflow runs, promotion evaluation).

Give the agent STORE_LAYER_API_KEY (and the project ID for /projects/{projectId}/… paths) as environment variables and let it call https://api.storelayer.io with Authorization: Bearer $STORE_LAYER_API_KEY. See authentication.

@storelayer/mcp-server (npm) exposes the Storelayer tool catalog as MCP tools over stdio for Claude Code, Claude Desktop, Cursor, and other MCP clients.

VariableRequiredDefaultPurpose
STORE_LAYER_API_KEYyes—Project API key; also selects the project
STORE_LAYER_API_URLnohttps://api.storelayer.ioAPI base URL

There is no project-ID variable: the project is whatever project the key belongs to. Use a separate key (and server entry) per project.

Claude Code:

Terminal window
claude mcp add storelayer -e STORE_LAYER_API_KEY=sk_your_key_here -- npx -y @storelayer/mcp-server

Generic MCP client config:

{
"mcpServers": {
"storelayer": {
"command": "npx",
"args": ["-y", "@storelayer/mcp-server"],
"env": { "STORE_LAYER_API_KEY": "sk_your_key_here" }
}
}
}

On start the server loads the tool list from the API, so it always matches the deployed catalog; restart it to pick up new tools. Tool names replace dots with underscores: wallet.earn becomes wallet_earn, promotions.evaluate_cart becomes promotions_evaluate_cart.

Use Storelayer to award 100 points when a customer’s purchase total reaches $50. Our purchase payload uses integer cents (payload.amount). Inspect existing rules first and test the threshold before enabling the rule.

Build a draft 10% basket promotion. Evaluate a qualifying and a non-qualifying cart (prices in cents) and show the per-item discounts.

  • Write tools change real state (wallets, rules, promotions). Point agents at a test project’s key while developing.
  • Ingested events are processed asynchronously; agents should check the workflow run before concluding a rule did or didn’t fire.
  • Keys in agent configs are secrets — keep them out of committed files.