Skip to main content
Glama
andrewlwn77
by andrewlwn77

query

Execute advanced database queries with filtering, sorting, and field selection to retrieve specific data from NocoDB tables.

Instructions

Execute an advanced query with filtering, sorting, and field selection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_idYesThe ID of the base/project
table_nameYesThe name of the table
whereNoFilter condition using NocoDB syntax (e.g., "(status,eq,active)~and(priority,gt,5)")
sortNoArray of sort fields (prefix with - for descending)
fieldsNoArray of fields to return
limitNoNumber of records to return
offsetNoNumber of records to skip

Implementation Reference

  • The asynchronous handler function for the 'query' tool. It uses the NocoDBClient to list records with provided filters, sorting, fields, limit, and offset, then returns the records, page info, count, and query parameters.
    handler: async (
      client: NocoDBClient,
      args: {
        base_id: string;
        table_name: string;
        where?: string;
        sort?: string[];
        fields?: string[];
        limit?: number;
        offset?: number;
      },
    ) => {
      const result = await client.listRecords(args.base_id, args.table_name, {
        where: args.where,
        sort: args.sort,
        fields: args.fields,
        limit: args.limit || 25,
        offset: args.offset || 0,
      });
      return {
        records: result.list,
        pageInfo: result.pageInfo,
        count: result.list.length,
        query: {
          where: args.where,
          sort: args.sort,
          fields: args.fields,
          limit: args.limit,
          offset: args.offset,
        },
      };
    },
  • JSON schema defining the input parameters for the 'query' tool, including base_id, table_name, optional where, sort, fields, limit, and offset.
    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",
        },
        where: {
          type: "string",
          description:
            'Filter condition using NocoDB syntax (e.g., "(status,eq,active)~and(priority,gt,5)")',
        },
        sort: {
          type: "array",
          description: "Array of sort fields (prefix with - for descending)",
          items: {
            type: "string",
          },
        },
        fields: {
          type: "array",
          description: "Array of fields to return",
          items: {
            type: "string",
          },
        },
        limit: {
          type: "number",
          description: "Number of records to return",
          default: 25,
        },
        offset: {
          type: "number",
          description: "Number of records to skip",
          default: 0,
        },
      },
      required: ["base_id", "table_name"],
    },
  • src/index.ts:55-62 (registration)
    Registration of the 'query' tool by including queryTools in the allTools array, which is used to list and call tools in the MCP server handlers.
    const allTools = [
      ...databaseTools,
      ...tableTools,
      ...recordTools,
      ...viewTools,
      ...queryTools,
      ...attachmentTools,
    ];
  • src/index.ts:16-16 (registration)
    Import of queryTools from src/tools/query.ts for registration in the main server.
    import { queryTools } from "./tools/query.js";
  • Definition and export of queryTools array containing the 'query' tool object.
    export const queryTools: Tool[] = [
      {
        name: "query",
        description:
          "Execute an advanced query with filtering, sorting, and field selection",
        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",
            },
            where: {
              type: "string",
              description:
                'Filter condition using NocoDB syntax (e.g., "(status,eq,active)~and(priority,gt,5)")',
            },
            sort: {
              type: "array",
              description: "Array of sort fields (prefix with - for descending)",
              items: {
                type: "string",
              },
            },
            fields: {
              type: "array",
              description: "Array of fields to return",
              items: {
                type: "string",
              },
            },
            limit: {
              type: "number",
              description: "Number of records to return",
              default: 25,
            },
            offset: {
              type: "number",
              description: "Number of records to skip",
              default: 0,
            },
          },
          required: ["base_id", "table_name"],
        },
        handler: async (
          client: NocoDBClient,
          args: {
            base_id: string;
            table_name: string;
            where?: string;
            sort?: string[];
            fields?: string[];
            limit?: number;
            offset?: number;
          },
        ) => {
          const result = await client.listRecords(args.base_id, args.table_name, {
            where: args.where,
            sort: args.sort,
            fields: args.fields,
            limit: args.limit || 25,
            offset: args.offset || 0,
          });
          return {
            records: result.list,
            pageInfo: result.pageInfo,
            count: result.list.length,
            query: {
              where: args.where,
              sort: args.sort,
              fields: args.fields,
              limit: args.limit,
              offset: args.offset,
            },
          };
        },
      },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the query is 'advanced' but doesn't specify whether it's read-only, paginated, rate-limited, or has side effects. For a query tool with 7 parameters and no annotation coverage, this is a significant gap in transparency about how the tool behaves beyond basic functionality.

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 that front-loads the core purpose ('Execute an advanced query') and key capabilities. There's zero waste or redundancy, making it easy for an agent to parse quickly while conveying essential information.

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, no annotations, no output schema), the description is insufficient. It doesn't cover behavioral aspects like read/write nature, error handling, or output format, nor does it differentiate from sibling tools. For a query tool in a database context, more context is needed to guide effective use.

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 7 parameters. The description adds no additional meaning beyond what's in the schema—it doesn't explain parameter relationships, default behaviors, or syntax examples beyond the schema's details. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('Execute an advanced query') and the capabilities ('filtering, sorting, and field selection'), which distinguishes it from simpler retrieval tools like 'list_records' or 'get_record'. However, it doesn't explicitly mention what resource is being queried (database records), leaving some ambiguity compared to siblings like 'search_records' or 'get_view_data'.

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 like 'search_records', 'list_records', or 'get_view_data'. It lacks context about prerequisites (e.g., needing base and table info) or performance considerations, leaving the agent to infer usage from the tool name and parameters alone.

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

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