Skip to main content
Glama

FindLabels

Filter and search record labels in RushDB using conditions, sorting, and pagination to find specific label data based on activity flags and counts.

Instructions

Find / filter record labels (supports where, limit, skip, orderBy). Superset of GetLabels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of labels to return
orderByNoSorting configuration: key = field, value = asc|desc
skipNoNumber of labels to skip
whereNoFilter conditions for labels (e.g., by activity flags, counts)

Implementation Reference

  • Core handler function for the FindLabels tool. Constructs a database query from input parameters (where, limit, skip, orderBy) and returns an array of labels with their counts.
    export async function FindLabels( params: { where?: Record<string, any> limit?: number skip?: number orderBy?: Record<string, 'asc' | 'desc'> } = {} ) { const { where, limit, skip, orderBy } = params const searchQuery: Record<string, any> = {} if (where) searchQuery.where = where if (typeof limit === 'number') searchQuery.limit = limit if (typeof skip === 'number') searchQuery.skip = skip if (orderBy && Object.keys(orderBy).length > 0) searchQuery.orderBy = orderBy const response = await db.labels.find(searchQuery) // Existing labels.find returns an object mapping label->count when empty query supplied. // When filters applied, SDK still returns .data as mapping; normalize to array. if (response?.success && response.data) { return Object.entries(response.data).map(([name, count]) => ({ name, count })) } return [] }
  • JSON Schema defining the input parameters for the FindLabels tool: optional where filter, limit, skip, and orderBy.
    inputSchema: { type: 'object', properties: { where: { type: 'object', description: 'Filter conditions for labels (e.g., by activity flags, counts)' }, limit: { type: 'number', description: 'Maximum number of labels to return' }, skip: { type: 'number', description: 'Number of labels to skip' }, orderBy: { type: 'object', description: 'Sorting configuration: key = field, value = asc|desc', additionalProperties: { type: 'string', enum: ['asc', 'desc'] } } }, required: [] }
  • tools.ts:55-75 (registration)
    Registration of the FindLabels tool in the tools array exported for MCP listTools request, including name, description, and input schema.
    { name: 'FindLabels', description: 'Find / filter record labels (supports where, limit, skip, orderBy). Superset of GetLabels.', inputSchema: { type: 'object', properties: { where: { type: 'object', description: 'Filter conditions for labels (e.g., by activity flags, counts)' }, limit: { type: 'number', description: 'Maximum number of labels to return' }, skip: { type: 'number', description: 'Number of labels to skip' }, orderBy: { type: 'object', description: 'Sorting configuration: key = field, value = asc|desc', additionalProperties: { type: 'string', enum: ['asc', 'desc'] } } }, required: [] } },
  • index.ts:72-76 (registration)
    MCP server request handler for listTools that returns the array of all tool definitions, including FindLabels.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools } })
  • MCP CallToolRequest handler switch case that invokes the FindLabels function with parsed arguments and formats the response as MCP content.
    case 'FindLabels': const foundLabels = await FindLabels({ 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 }) return { content: [ { type: 'text', text: foundLabels.length > 0 ? foundLabels.map((l: any) => `${l.name}: ${l.count} records`).join('\n') : 'No labels found' } ] }

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