Skip to main content
Glama

ExportRecords

Export database records to CSV format with filtering, sorting, and limit options for data analysis and reporting.

Instructions

Export records to CSV format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelsNoFilter by record labels
limitNoMaximum number of records to export
orderByNoSorting configuration for export
whereNoSearch conditions for records to export

Implementation Reference

  • The core handler function for the ExportRecords tool. It constructs a search query from parameters and calls db.records.export to generate CSV output.
    export async function ExportRecords(params: { labels?: string[] where?: Record<string, any> limit?: number }) { const { labels, where, limit } = params const searchQuery: any = {} if (labels && labels.length > 0) { searchQuery.labels = labels } if (where) { searchQuery.where = where } if (limit) { searchQuery.limit = limit } const result = await db.records.export(searchQuery) if (result.success && result.data) { return { csv: result.data.fileContent, dateTime: result.data.dateTime, message: 'Records exported successfully' } } return { csv: '', dateTime: new Date().toISOString(), message: 'No records found to export' } }
  • JSON Schema definition for the ExportRecords tool input parameters, defining labels, where, limit, and orderBy.
    inputSchema: { type: 'object', properties: { labels: { type: 'array', items: { type: 'string' }, description: 'Filter by record labels' }, where: { type: 'object', description: 'Search conditions for records to export' }, limit: { type: 'number', description: 'Maximum number of records to export' }, orderBy: { type: 'object', description: 'Sorting configuration for export', additionalProperties: { type: 'string', enum: ['asc', 'desc'] } } }, required: [] }
  • tools.ts:283-300 (registration)
    Registration of the ExportRecords tool in the tools array, including name, description, and schema for MCP ListTools.
    { name: 'ExportRecords', description: 'Export records to CSV format', inputSchema: { type: 'object', properties: { labels: { type: 'array', items: { type: 'string' }, description: 'Filter by record labels' }, where: { type: 'object', description: 'Search conditions for records to export' }, limit: { type: 'number', description: 'Maximum number of records to export' }, orderBy: { type: 'object', description: 'Sorting configuration for export', additionalProperties: { type: 'string', enum: ['asc', 'desc'] } } }, required: [] } },
  • index.ts:303-316 (registration)
    Dispatcher/registration in the MCP CallToolRequest switch statement, invoking the handler with arguments and formatting response.
    case 'ExportRecords': const exportResult = await ExportRecords({ labels: args.labels as string[] | undefined, where: args.where as Record<string, any> | undefined, limit: args.limit as number | undefined }) return { content: [ { type: 'text', text: `Export completed at ${exportResult.dateTime}\n\n${exportResult.csv}` } ] }
  • index.ts:37-37 (registration)
    Import statement bringing the ExportRecords handler into the main index.ts for use in tool dispatching.
    import { ExportRecords } from './tools/ExportRecords.js'

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