Skip to main content
Glama

list_metaobject_definitions

List all custom metaobject definitions (types/schemas) on your Shopify store, including their typed fields and required fields. Discover available data shapes before querying or creating metaobject instances.

Instructions

List the metaobject definitions (custom types/schemas) registered on this Shopify store, with their field definitions. Each definition declares a type handle, a set of typed fields, and which fields are required. Use this tool to discover what custom data shapes the store supports before calling list_metaobjects (which queries instances of one type) or create_metaobject (which creates a new instance). Cursor-paginated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNoPage size (1-100). 25 is usually plenty — most stores have <50 metaobject types total.
afterNoCursor from a prior page's pageInfo. Omit on the first call.

Implementation Reference

  • The tool handler registration for 'list_metaobject_definitions' — calls the GraphQL query LIST_METAOBJECT_DEFINITIONS_QUERY and formats the response as text.
    server.tool(
      "list_metaobject_definitions",
      "List the metaobject definitions (custom types/schemas) registered on this Shopify store, with their field definitions. Each definition declares a `type` handle, a set of typed fields, and which fields are required. Use this tool to discover what custom data shapes the store supports before calling list_metaobjects (which queries instances of one type) or create_metaobject (which creates a new instance). Cursor-paginated.",
      listDefinitionsSchema,
      async (args) => {
        const data = await client.graphql<{
          metaobjectDefinitions: Connection<MetaobjectDefinitionNode>;
        }>(LIST_METAOBJECT_DEFINITIONS_QUERY, {
          first: args.first,
          after: args.after,
        });
        const edges = data.metaobjectDefinitions.edges;
        if (edges.length === 0) {
          return {
            content: [
              { type: "text" as const, text: "No metaobject definitions on this store." },
            ],
          };
        }
        const rows: string[] = [`Found ${edges.length} definition(s):`];
        for (const { node } of edges) {
          rows.push(`  ${node.name} (${node.type}) — ${node.metaobjectsCount ?? "?"} objects — ${node.id}`);
          for (const f of node.fieldDefinitions) {
            const req = f.required ? "*" : "";
            rows.push(`    - ${f.key}${req}: ${f.type.name}`);
          }
        }
        return {
          content: [{ type: "text" as const, text: rows.join("\n") }],
        };
      },
    );
  • Input schema (listDefinitionsSchema) for the tool: 'first' (page size, default 25, 1-100) and 'after' (optional cursor).
    const listDefinitionsSchema = {
      first: z
        .number()
        .int()
        .min(1)
        .max(100)
        .default(25)
        .describe("Page size (1-100). 25 is usually plenty — most stores have <50 metaobject types total."),
      after: z
        .string()
        .optional()
        .describe("Cursor from a prior page's pageInfo. Omit on the first call."),
    };
  • Registration via server.tool('list_metaobject_definitions', ...) inside registerMetaobjectTools(), which is called from src/server.ts line 67.
    server.tool(
      "list_metaobject_definitions",
      "List the metaobject definitions (custom types/schemas) registered on this Shopify store, with their field definitions. Each definition declares a `type` handle, a set of typed fields, and which fields are required. Use this tool to discover what custom data shapes the store supports before calling list_metaobjects (which queries instances of one type) or create_metaobject (which creates a new instance). Cursor-paginated.",
      listDefinitionsSchema,
      async (args) => {
        const data = await client.graphql<{
          metaobjectDefinitions: Connection<MetaobjectDefinitionNode>;
        }>(LIST_METAOBJECT_DEFINITIONS_QUERY, {
          first: args.first,
          after: args.after,
        });
        const edges = data.metaobjectDefinitions.edges;
        if (edges.length === 0) {
          return {
            content: [
              { type: "text" as const, text: "No metaobject definitions on this store." },
            ],
          };
        }
        const rows: string[] = [`Found ${edges.length} definition(s):`];
        for (const { node } of edges) {
          rows.push(`  ${node.name} (${node.type}) — ${node.metaobjectsCount ?? "?"} objects — ${node.id}`);
          for (const f of node.fieldDefinitions) {
            const req = f.required ? "*" : "";
            rows.push(`    - ${f.key}${req}: ${f.type.name}`);
          }
        }
        return {
          content: [{ type: "text" as const, text: rows.join("\n") }],
        };
      },
    );
  • The LIST_METAOBJECT_DEFINITIONS_QUERY GraphQL query used by the handler to fetch metaobject definitions from Shopify.
    const LIST_METAOBJECT_DEFINITIONS_QUERY = /* GraphQL */ `
      query ListMetaobjectDefinitions($first: Int!, $after: String) {
        metaobjectDefinitions(first: $first, after: $after) {
          edges {
            cursor
            node {
              id
              name
              type
              description
              metaobjectsCount
              fieldDefinitions {
                key
                name
                type { name }
                required
                description
              }
            }
          }
          pageInfo { hasNextPage hasPreviousPage startCursor endCursor }
        }
      }
    `;
  • TypeScript interface MetaobjectDefinitionNode describing the shape of a metaobject definition returned by the GraphQL query.
    interface MetaobjectDefinitionNode {
      id: string;
      name: string;
      type: string;
      description?: string | null;
      metaobjectsCount?: number | null;
      fieldDefinitions: Array<{
        key: string;
        name: string;
        type: { name: string };
        required: boolean;
        description?: string | null;
      }>;
    }
Behavior4/5

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

No annotations are provided, so the description carries full burden. It discloses cursor-paginated behavior and the contents of each definition. While it doesn't describe rate limits or permissions, it is adequate for a read-only list operation.

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 two sentences: the first dense with information, the second providing usage guidance. No redundant or filler content. Every sentence contributes value.

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

Completeness5/5

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

Given the tool's low complexity, no output schema, and rich annotations in sibling tools, the description fully covers purpose, usage, pagination, and parameter hints. It is complete for an agent to decide when and how to invoke it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both parameters. The tool description adds extra value by suggesting a default page size and providing real-world usage context ('most stores have <50 metaobject types'). This goes beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists metaobject definitions with field definitions, and distinguishes it from siblings like list_metaobjects and create_metaobject. The verb+resource combination and scope are precise.

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

Usage Guidelines5/5

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

The description explicitly says to use this tool before calling list_metaobjects or create_metaobject, and provides context on what the tool yields. It also implies when not to use it by naming alternatives.

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/miller-joe/shopify-mcp'

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