Skip to main content
Glama

query_records

Retrieve records from Gadget models by specifying the model name and GraphQL fields. Use introspect_model first to discover available fields for querying.

Instructions

Query records from any Gadget model. Specify the model name and a GraphQL field selection. Use introspect_model first to discover available fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYesModel name in camelCase, e.g. shopifyOrder, label
fieldsYesGraphQL field selection, e.g. "id name email createdAt"
filterNoGadget filter object, e.g. { "name": { "equals": "#59389" } }
limitNoMax records to return (default 10, max 50)

Implementation Reference

  • The handler logic for the 'query_records' tool, which constructs and executes a GraphQL query based on provided arguments.
    case "query_records": {
      const { model, fields, filter, limit = 10 } = args as {
        model: string;
        fields: string;
        filter?: Record<string, unknown>;
        limit?: number;
      };
      const first = Math.min(limit, 50);
      const filterArg = filter ? `, filter: $filter` : "";
      const varsDef = filter ? `($filter: ${model.charAt(0).toUpperCase() + model.slice(1)}Filter, $first: Int)` : `($first: Int)`;
      const varsVal: Record<string, unknown> = { first };
      if (filter) varsVal.filter = filter;
    
      const query = `
        query QueryRecords${varsDef} {
          ${model}(first: $first${filterArg}) {
            edges {
              node {
                ${fields}
              }
            }
            pageInfo { hasNextPage }
          }
        }
      `;
    
      const data = await gql(query, varsVal);
      const connection = data[model];
      const records = connection.edges.map((e: any) => e.node);
      return {
        content: [{
          type: "text",
          text: JSON.stringify({ records, hasMore: connection.pageInfo.hasNextPage }, null, 2),
        }],
      };
    }
  • The schema definition for 'query_records', including input parameters like model, fields, filter, and limit.
    {
      name: "query_records",
      description:
        "Query records from any Gadget model. Specify the model name and a GraphQL field selection. Use introspect_model first to discover available fields.",
      inputSchema: {
        type: "object",
        required: ["model", "fields"],
        properties: {
          model: { type: "string", description: "Model name in camelCase, e.g. shopifyOrder, label" },
          fields: {
            type: "string",
            description: "GraphQL field selection, e.g. \"id name email createdAt\"",
          },
          filter: {
            type: "object",
            description: "Gadget filter object, e.g. { \"name\": { \"equals\": \"#59389\" } }",
          },
          limit: { type: "number", description: "Max records to return (default 10, max 50)" },
        },
      },
    },
Behavior2/5

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

No annotations provided, so description carries full burden. While 'Query' implies read-only operation, the description discloses no other behavioral traits: return format/pagination (no output schema), error conditions, rate limits, or whether partial failures are possible. Does not mention that 'limit' constrains results or if pagination tokens are available.

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

Conciseness4/5

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

Three concise sentences front-loaded with purpose. Third sentence provides crucial workflow context. Second sentence is somewhat redundant with schema parameter descriptions, but overall efficient with minimal waste.

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

Completeness3/5

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

Given 4 parameters with 100% schema coverage and no output schema, the description covers the essential prerequisite workflow (introspect_model) but omits description of return values and pagination behavior which would be necessary for complete context without an output schema.

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 coverage is 100% with detailed descriptions for all 4 parameters including examples (e.g., 'shopifyOrder', '{ "name": { "equals": "#59389" } }'). Description mentions 'Specify the model name and a GraphQL field selection' which aligns with schema but adds minimal semantic meaning beyond what schema already documents. Baseline 3 appropriate for high schema coverage.

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?

States specific action 'Query records from any Gadget model' with clear verb and resource. Mentions 'introspect_model' which begins to distinguish workflow from sibling discovery tools, though it doesn't explicitly differentiate from 'get_record' (single vs multiple) or 'run_graphql' (structured vs raw).

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

Usage Guidelines3/5

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

Provides explicit prerequisite 'Use introspect_model first to discover available fields' which establishes a workflow sequence. However, lacks explicit guidance on when to use 'get_record' (single record by ID) vs this tool, or when to prefer 'run_graphql' for complex operations.

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/Stronger-eCommerce/gadget-mcp'

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