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:
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
createContentstackWebMcp({
mode: "proxy",
proxyBasePath: "/api/contentstack",
contentTypes,
});Server — credentials here
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
| Mode | Token exposure | Use when |
|---|---|---|
| Direct | Client bundle (read-only, environment-scoped) | The whole environment is public content |
| Proxy | Server-only | The 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.
| Framework | Server (credentials) | Client (no credentials) |
|---|---|---|
| Next.js | app/api/contentstack/[...path]/route.ts | useContentstackWebMcp({ mode: "proxy", ... }) |
| Astro | src/pages/api/contentstack/[...path].ts | WebMcpInit.astro client island |
| Nuxt | server/api/contentstack/[...].ts | composable with proxy mode |
| Vanilla | Any backend route | <script type="module"> |
See framework guides in Integrations.