Skip to main content
Glama

FindRecords

Search and retrieve database records using queries, filters, sorting, and aggregation in RushDB's graph database.

Instructions

Find records in the database using a search query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelsNoFilter by record labels
whereNoSearch conditions for finding records
limitNoMaximum number of records to return
skipNoNumber of records to skip
orderByNoSorting configuration: key = field, value = asc|desc
aggregateNoAggregation definitions (records only)
groupByNoFields to group by (records only)

Implementation Reference

  • The main handler function that executes the tool logic: constructs a search query from parameters and queries the database for records, handling aggregation and grouping specially.
    export async function FindRecords(params: {
      labels?: string[]
      where?: Record<string, any>
      limit?: number
      skip?: number
      orderBy?: Record<string, 'asc' | 'desc'>
      aggregate?: Record<string, { fn: string; field?: string; alias?: string; where?: any }>
      groupBy?: string[]
    }) {
      const { labels, where, limit = 10, skip = 0, orderBy, aggregate, groupBy } = params
    
      const searchQuery: any = {}
      if (labels && labels.length > 0) searchQuery.labels = labels
      if (where) searchQuery.where = where
      if (limit) searchQuery.limit = limit
      if (skip) searchQuery.skip = skip
      if (orderBy && Object.keys(orderBy).length > 0) searchQuery.orderBy = orderBy
      if (aggregate && Object.keys(aggregate).length > 0) searchQuery.aggregate = aggregate
      if (groupBy && groupBy.length > 0) searchQuery.groupBy = groupBy
    
      const result = await db.records.find(searchQuery)
    
      // If aggregation present, return raw response so caller gets aggregates.
      if (searchQuery.aggregate || searchQuery.groupBy) {
        return result
      }
    
      return result.data.map((record: any) => record.data)
    }
  • Defines the input schema and description for the FindRecords tool, used for validation in the MCP server.
      name: 'FindRecords',
      description: 'Find records in the database using a search query',
      inputSchema: {
        type: 'object',
        properties: {
          labels: { type: 'array', items: { type: 'string' }, description: 'Filter by record labels' },
          where: { type: 'object', description: 'Search conditions for finding records' },
          limit: { type: 'number', description: 'Maximum number of records to return', default: 10 },
          skip: { type: 'number', description: 'Number of records to skip', default: 0 },
          orderBy: {
            type: 'object',
            description: 'Sorting configuration: key = field, value = asc|desc',
            additionalProperties: { type: 'string', enum: ['asc', 'desc'] }
          },
          aggregate: {
            type: 'object',
            description: 'Aggregation definitions (records only)',
            additionalProperties: {
              type: 'object',
              properties: {
                fn: {
                  type: 'string',
                  description: 'Aggregation function (count,sum,avg,min,max,timeBucket)'
                },
                field: { type: 'string', description: 'Field to aggregate' },
                alias: { type: 'string', description: 'Optional alias override' },
                granularity: {
                  type: 'string',
                  description: 'For timeBucket, the time granularity (e.g., day, week, month, quarter, year)'
                }
              },
              required: ['fn']
            }
          },
          groupBy: {
            type: 'array',
            items: { type: 'string' },
            description: 'Fields to group by (records only)'
          }
        },
        required: []
      }
    },
  • index.ts:72-76 (registration)
    Registers the list of tools including FindRecords for the MCP ListTools request.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools
      }
    })
  • index.ts:182-206 (registration)
    Dispatches the tool call to the FindRecords handler function in the MCP CallTool request handler.
    case 'FindRecords':
      const foundRecords = await FindRecords({
        labels: args.labels as string[] | undefined,
        where: args.where as Record<string, any> | undefined,
        limit: args.limit as number | undefined,
        skip: args.skip as number | undefined,
        orderBy: args.orderBy as Record<string, 'asc' | 'desc'> | undefined,
        aggregate: args.aggregate as
          | Record<string, { fn: string; field?: string; alias?: string; where?: any }>
          | undefined,
        groupBy: args.groupBy as string[] | undefined
      })
    
      const isAggregate = Boolean(args.aggregate) || Boolean(args.groupBy)
      return {
        content: [
          {
            type: 'text',
            text:
              Array.isArray(foundRecords) && foundRecords.length === 0 ?
                'No matching records found.'
              : JSON.stringify(foundRecords, null, 2)
          }
        ]
      }
  • index.ts:30-30 (registration)
    Imports the FindRecords handler function for use in the main server.
    import { FindRecords } from './tools/FindRecords.js'
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 finds records but doesn't explain key behaviors: whether it's read-only or mutative, if it requires authentication, how it handles errors, or what the output format looks like. For a search tool with complex parameters, this is inadequate.

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: 'Find records in the database using a search query.' It's front-loaded with the core purpose and wastes no words, making it highly concise and well-structured.

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 (7 parameters with nested objects) and lack of annotations or output schema, the description is insufficient. It doesn't cover behavioral aspects like safety, permissions, or result format, leaving gaps for an agent to understand how to use it effectively in context.

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?

The input schema has 100% description coverage, providing details for all 7 parameters (e.g., labels for filtering, where for conditions, limit for max returns). The description adds no additional parameter semantics beyond the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 tool's purpose: 'Find records in the database using a search query.' It specifies the verb ('Find') and resource ('records'), making the action clear. However, it doesn't differentiate from sibling tools like FindOneRecord, FindUniqRecord, or GetRecordsByIds, which also retrieve records but with different scopes or methods.

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 siblings like FindOneRecord for single records or GetRecordsByIds for specific IDs, nor does it specify prerequisites or exclusions. This leaves the agent without context for tool selection.

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