
Security News
Suno Breached via Shai-Hulud Worm, Leaked Code Exposes AI Music Scraping
A Shai-Hulud infection exposed Suno's source code, which shows the AI music startup stream-ripped tracks to train its models.
@mastra/cloudflare
Advanced tools
Affected versions:
Cloudflare KV store for Mastra, providing scalable and serverless storage for threads, messages, workflow snapshots, and evaluations. Supports both Cloudflare Workers KV Bindings and the REST API for flexible deployment in serverless and Node.js environments.
npm install @mastra/cloudflare
import { CloudflareStore } from '@mastra/cloudflare';
// Using Workers Binding API
const store = new CloudflareStore({
bindings: {
threads: THREADS_KV_NAMESPACE,
messages: MESSAGES_KV_NAMESPACE,
workflow_snapshot: WORKFLOW_KV_NAMESPACE,
traces: TRACES_KV_NAMESPACE,
},
keyPrefix: 'myapp_', // Optional
});
// Or using REST API
const store = new CloudflareStore({
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
apiToken: process.env.CLOUDFLARE_API_TOKEN!,
namespacePrefix: 'myapp_', // Optional
});
// Save a thread
await store.saveThread({
thread: {
id: 'thread-123',
resourceId: 'resource-456',
title: 'My Thread',
metadata: { key: 'value' },
createdAt: new Date(),
},
});
// Add messages
await store.saveMessages({
messages: [
{
id: 'msg-1',
threadId: 'thread-123',
content: 'Hello Cloudflare!',
role: 'user',
createdAt: new Date(),
},
],
});
// Query messages
const messages = await store.listMessages({ threadId: 'thread-123' });
bindings option to pass KV namespaces directly (for Cloudflare Workers).accountId, apiToken, and (optionally) namespacePrefix for server-side usage.keyPrefix/namespacePrefix: Useful for isolating environments (e.g., dev/test/prod).saveThread({ thread }): Create or update a threadgetThreadById({ threadId }): Get a thread by IDlistThreadsByResourceId({ resourceId, offset, limit, orderBy? }): List paginated threads for a resourceupdateThread({ id, title, metadata }): Update thread title and metadatadeleteThread({ threadId }): Delete a thread and its messagessaveMessages({ messages }): Save multiple messageslistMessages({ threadId, perPage?, page? }): Get messages for a thread with paginationlistMessagesById({ messageIds }): Get specific messages by their IDsupdateMessages({ messages }): Update existing messagesgetResourceById({ resourceId }): Get a resource by IDsaveResource({ resource }): Create or save a resourceupdateResource({ resourceId, workingMemory }): Update resource working memorypersistWorkflowSnapshot({ workflowName, runId, snapshot }): Save workflow stateloadWorkflowSnapshot({ workflowName, runId }): Load workflow statelistWorkflowRuns({ workflowName, pagination }): List workflow runs with paginationgetWorkflowRunById({ workflowName, runId }): Get a specific workflow runupdateWorkflowState({ workflowName, runId, state }): Update workflow stateupdateWorkflowResults({ workflowName, runId, results }): Update workflow resultsgetScoreById({ id }): Get a score by IDsaveScore(score): Save an evaluation scorelistScoresByScorerId({ scorerId, pagination }): List scores by scorer with paginationlistScoresByRunId({ runId, pagination }): List scores by run with paginationlistScoresByEntityId({ entityId, entityType, pagination }): List scores by entity with paginationlistScoresBySpan({ traceId, spanId, pagination }): List scores by span with paginationdeleteMessages(messageIds): Message deletion is not currently supportedclearTable({ tableName }): Remove all records from a logical tablebatchInsert({ tableName, records }): Batch insert multiple records.insert({ tableName, record }): Insert a single record into a table.text: Stringtimestamp: ISO8601 string (converted to/from Date)uuid: Stringjsonb: JSON-encoded objectAll records are stored as JSON in KV, with automatic serialization/deserialization for metadata, arrays, and custom fields.
bindings option to pass KV namespaces directly (for Cloudflare Workers).accountId, apiToken, and (optionally) namespacePrefix for server-side usage.keyPrefix/namespacePrefix: Useful for isolating environments (e.g., dev/test/prod).Example:
const store = new CloudflareStore({
bindings: { ... }, // for Workers
keyPrefix: 'dev_',
});
// or
const store = new CloudflareStore({
accountId: '...',
apiToken: '...',
namespacePrefix: 'prod_',
});
Each logical Mastra table (threads, messages, workflow_snapshot, evals, traces) maps to a separate KV namespace. Keys are structured as ${prefix}${tableName}:${primaryKey} or ${prefix}${tableName}:${threadId}:${messageId} for messages. The prefix is set by keyPrefix/namespacePrefix.
No explicit cleanup or disconnect is required; Cloudflare KV is fully managed.
FAQs
Cloudflare provider for Mastra - includes db storage capabilities
The npm package @mastra/cloudflare receives a total of 1,790 weekly downloads. As such, @mastra/cloudflare popularity was classified as popular.
We found that @mastra/cloudflare demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A Shai-Hulud infection exposed Suno's source code, which shows the AI music startup stream-ripped tracks to train its models.

Security News
Vercel is formalizing a monthly release program for Next.js. The change follows React2Shell and a sharp rise in AI-assisted vulnerability discovery.

Research
/Security News
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.