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'
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool exports records to CSV but doesn't describe what happens during export (e.g., file generation, download, side effects), permissions required, rate limits, or error handling. This is a significant gap for a tool with potential data access and output implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It is front-loaded with the core purpose and avoids unnecessary details, making it easy to parse quickly. Every word earns its place by conveying essential information about the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, no output schema, and no annotations), the description is incomplete. It lacks details on behavioral aspects like what the export produces (e.g., a file, data stream), error conditions, or usage context. Without annotations or output schema, more descriptive context is needed for adequate agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 4 parameters (labels, where, limit, orderBy). The description adds no parameter-specific information beyond implying filtering and sorting through the export context. This meets the baseline of 3 since the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Export') and resource ('records') with the output format ('to CSV format'). It distinguishes from siblings like 'FindRecords' or 'GetRecordsByIds' by specifying the export functionality rather than just retrieval. However, it doesn't explicitly differentiate from all potential export-related tools since none are listed among siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, when not to use it, or compare it to sibling tools like 'FindRecords' for viewing data or 'BulkCreateRecords' for importing. Usage is implied only by the name and description, with no explicit context provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/rush-db/RushDB'

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