Skip to main content
Glama
andrewlwn77
by andrewlwn77

search_records

Search for database records using a query string to find specific information within NocoDB tables. Apply filters, sorting, and pagination to refine results.

Instructions

Search for records containing a query string

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_idYesThe ID of the base/project
table_nameYesThe name of the table
queryYesSearch query string
whereNoAdditional filter condition
sortNoSort fields
limitNoNumber of records to return
offsetNoNumber of records to skip

Implementation Reference

  • MCP tool handler for 'search_records' that invokes NocoDBClient.searchRecords with provided arguments and formats the response.
      handler: async (
        client: NocoDBClient,
        args: {
          base_id: string;
          table_name: string;
          query: string;
          where?: string;
          sort?: string;
          limit?: number;
          offset?: number;
        },
      ) => {
        const result = await client.searchRecords(
          args.base_id,
          args.table_name,
          args.query,
          {
            where: args.where,
            sort: args.sort,
            limit: args.limit,
            offset: args.offset,
          },
        );
        return {
          records: result.list,
          pageInfo: result.pageInfo,
          count: result.list.length,
          query: args.query,
        };
      },
    },
  • Input schema defining parameters for the 'search_records' tool.
    inputSchema: {
      type: "object",
      properties: {
        base_id: {
          type: "string",
          description: "The ID of the base/project",
        },
        table_name: {
          type: "string",
          description: "The name of the table",
        },
        query: {
          type: "string",
          description: "Search query string",
        },
        where: {
          type: "string",
          description: "Additional filter condition",
        },
        sort: {
          type: "string",
          description: "Sort fields",
        },
        limit: {
          type: "number",
          description: "Number of records to return",
        },
        offset: {
          type: "number",
          description: "Number of records to skip",
        },
      },
      required: ["base_id", "table_name", "query"],
    },
  • src/index.ts:55-62 (registration)
    Includes recordTools (containing 'search_records') in the allTools array registered with MCP server handlers for list and call requests.
    const allTools = [
      ...databaseTools,
      ...tableTools,
      ...recordTools,
      ...viewTools,
      ...queryTools,
      ...attachmentTools,
    ];
  • NocoDBClient.searchRecords method implementing client-side fuzzy search by fetching records and filtering those containing the query string.
    async searchRecords(
      baseId: string,
      tableName: string,
      query: string,
      options?: QueryOptions,
    ): Promise<{ list: NocoDBRecord[]; pageInfo: any }> {
      // For now, use regular list with client-side filtering
      // since NocoDB search syntax is complex
      const records = await this.listRecords(baseId, tableName, options);
      const filtered = records.list.filter((record) => {
        return Object.values(record).some((value) =>
          String(value).toLowerCase().includes(query.toLowerCase()),
        );
      });
      return { list: filtered, pageInfo: records.pageInfo };
    }

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/andrewlwn77/nocodb-mcp'

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