Skip to main content
Glama

BulkDeleteRecords

Delete multiple database records at once using search conditions, labels, or transaction IDs to remove data matching specific criteria.

Instructions

Delete multiple records matching a query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelsNoFilter by record labels
whereYesSearch conditions for records to delete
transactionIdNoOptional transaction ID for atomic bulk deletion

Implementation Reference

  • The core handler function that performs bulk deletion of records matching the provided where clause and optional labels, using the database API.
    export async function BulkDeleteRecords({
      labels,
      where,
      transactionId
    }: BulkDeleteRecordsArgs): Promise<BulkDeleteRecordsResult> {
      const searchQuery: any = { where }
      if (labels && labels.length > 0) {
        searchQuery.labels = labels
      }
    
      const result = await db.records.delete(searchQuery, transactionId)
    
      return {
        message: result.data?.message || 'Records deleted successfully'
      }
    }
  • TypeScript type definitions for the input arguments and output result of the BulkDeleteRecords tool.
    type BulkDeleteRecordsArgs = {
      labels?: string[]
      where: Record<string, any>
      transactionId?: string
    }
    
    type BulkDeleteRecordsResult = {
      message: string
    }
  • tools.ts:270-282 (registration)
    MCP tool registration entry defining the name, description, and input schema for BulkDeleteRecords in the tools list.
    {
      name: 'BulkDeleteRecords',
      description: 'Delete multiple records matching a query',
      inputSchema: {
        type: 'object',
        properties: {
          labels: { type: 'array', items: { type: 'string' }, description: 'Filter by record labels' },
          where: { type: 'object', description: 'Search conditions for records to delete' },
          transactionId: { type: 'string', description: 'Optional transaction ID for atomic bulk deletion' }
        },
        required: ['where']
      }
    },
  • The switch case dispatcher in the main server handler that invokes the BulkDeleteRecords function and formats the MCP response.
    case 'BulkDeleteRecords':
      const bulkDeleteResult = await BulkDeleteRecords({
        labels: args.labels as string[] | undefined,
        where: args.where as Record<string, any>,
        transactionId: args.transactionId as string | undefined
      })
      return {
        content: [
          {
            type: 'text',
            text: bulkDeleteResult.message
          }
        ]
      }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/1pxone/RushDB'

If you have feedback or need assistance with the MCP directory API, please join our Discord server