Skip to content

Experimental · Unofficial

Built by Tim Benniks. This is not an official Contentstack product and is not supported by Contentstack.

Credentials

This package does not read Contentstack credentials from the environment. You create a Delivery SDK stack and pass it where CDA access happens.

Direct mode (default)

The stack is created in the browser, so the delivery token ships in the JS bundle:

typescript
import contentstack from "@contentstack/delivery-sdk";

const stack = contentstack.stack({
  apiKey: import.meta.env.VITE_CONTENTSTACK_API_KEY,
  deliveryToken: import.meta.env.VITE_CONTENTSTACK_DELIVERY_TOKEN,
  environment: import.meta.env.VITE_CONTENTSTACK_ENVIRONMENT,
});

createContentstackWebMcp({ mode: "direct", stack, contentTypes });

Use a read-only delivery token scoped to an environment that contains only content you are happy to have public. The token grants read access to every content type in that environment, not just the ones you configured — see Execution modes.

Proxy mode

Browser                     Your server                      Contentstack CDA
  │                              │                                  │
  │  fetch /api/contentstack/*   │  stack (server env vars)         │
  ├─────────────────────────────►├─────────────────────────────────►│
  │  no delivery token           │  CONTENTSTACK_DELIVERY_TOKEN       │

Browser — no stack required

typescript
createContentstackWebMcp({
  mode: "proxy",
  proxyBasePath: "/api/contentstack",
  contentTypes,
});

Server — credentials here

typescript
import contentstack from "@contentstack/delivery-sdk";

const stack = contentstack.stack({
  apiKey: process.env.CONTENTSTACK_API_KEY!,
  deliveryToken: process.env.CONTENTSTACK_DELIVERY_TOKEN!,
  environment: process.env.CONTENTSTACK_ENVIRONMENT!,
});

WARNING

In proxy mode, use server-only env vars. Never prefix delivery tokens with NEXT_PUBLIC_, VITE_, or other client-exposed prefixes — that defeats the entire point of the proxy.

Token guidance

ModeToken exposureUse when
DirectClient bundle (read-only, environment-scoped)The whole environment is public content
ProxyServer-onlyThe environment holds anything you would not publish, or you need caching/quotas

Security boundary

This package must never encourage:

  • Management tokens
  • Write-capable credentials
  • Browser-exposed CMA access

All built-in CDA tools are read-only with readOnlyHint: true.

Framework credential split

Only relevant in proxy mode — direct mode has no server side.

FrameworkServer (credentials)Client (no credentials)
Next.jsapp/api/contentstack/[...path]/route.tsuseContentstackWebMcp({ mode: "proxy", ... })
Astrosrc/pages/api/contentstack/[...path].tsWebMcpInit.astro client island
Nuxtserver/api/contentstack/[...].tscomposable with proxy mode
VanillaAny backend route<script type="module">

See framework guides in Integrations.

Released under the MIT License.