Skip to main content
Glama

ExportRecords

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

Instructions

Export records to CSV format

Input Schema

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

Implementation Reference

  • The core handler function that performs the record export to CSV using the database export method based on provided labels, where clause, and limit.
    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, including parameters for labels, where, limit, and orderBy.
    { 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)
    Registration and dispatching logic in the main MCP server handler's switch case for calling the ExportRecords tool and formatting the 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 that brings the ExportRecords handler into the main index file for use in the tool dispatcher.
    import { ExportRecords } from './tools/ExportRecords.js'
  • tools.ts:30-30 (registration)
    Tool name included in the ToolName type union for type-safe tool handling.
    | 'ExportRecords'

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