Skip to main content
Glama

get_metaobject

Retrieve a metaobject's display name, handle, type, publishable status, and truncated field values using its GID. Use list_metaobjects to find GIDs first.

Instructions

Fetch a single metaobject by GID and return its display name, handle, type, publishable status, and all of its field values. Field values longer than 120 characters are truncated in the rendered output (full values are still on the underlying record). Use list_metaobjects to discover GIDs first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesMetaobject GID, e.g. 'gid://shopify/Metaobject/123456'. Discover GIDs via list_metaobjects.

Implementation Reference

  • The handler function for the 'get_metaobject' tool. It executes a GraphQL query (GET_METAOBJECT_QUERY) with the provided id, formats the returned metaobject fields, and returns a text response with display name, handle, type, status, and field values.
    async (args) => {
      const data = await client.graphql<{
        metaobject: MetaobjectNode | null;
      }>(GET_METAOBJECT_QUERY, { id: args.id });
      if (!data.metaobject) {
        return {
          content: [
            { type: "text" as const, text: `Metaobject not found: ${args.id}` },
          ],
        };
      }
      const m = data.metaobject;
      const status = m.capabilities?.publishable?.status;
      return {
        content: [
          {
            type: "text" as const,
            text: [
              `${m.displayName ?? m.handle} (${m.type})${status ? ` [${status}]` : ""}`,
              `  ID: ${m.id}`,
              `  Handle: ${m.handle}`,
              `  Updated: ${m.updatedAt}`,
              "  Fields:",
              ...formatMetaobjectFields(m.fields),
            ].join("\n"),
          },
        ],
      };
    },
  • The input schema for 'get_metaobject'. Defines a single required string parameter 'id' (a metaobject GID like 'gid://shopify/Metaobject/123456'), described with a hint to discover GIDs via list_metaobjects.
    const getMetaobjectSchema = {
      id: z
        .string()
        .describe(
          "Metaobject GID, e.g. 'gid://shopify/Metaobject/123456'. Discover GIDs via list_metaobjects.",
        ),
    };
  • Registration of the 'get_metaobject' tool via server.tool(). The tool is registered with its name, description, schema, and handler lambda. This is inside registerMetaobjectTools() which is called from src/server.ts line 67.
    server.tool(
      "get_metaobject",
      "Fetch a single metaobject by GID and return its display name, handle, type, publishable status, and all of its field values. Field values longer than 120 characters are truncated in the rendered output (full values are still on the underlying record). Use list_metaobjects to discover GIDs first.",
      getMetaobjectSchema,
      async (args) => {
        const data = await client.graphql<{
          metaobject: MetaobjectNode | null;
        }>(GET_METAOBJECT_QUERY, { id: args.id });
        if (!data.metaobject) {
          return {
            content: [
              { type: "text" as const, text: `Metaobject not found: ${args.id}` },
            ],
          };
        }
        const m = data.metaobject;
        const status = m.capabilities?.publishable?.status;
        return {
          content: [
            {
              type: "text" as const,
              text: [
                `${m.displayName ?? m.handle} (${m.type})${status ? ` [${status}]` : ""}`,
                `  ID: ${m.id}`,
                `  Handle: ${m.handle}`,
                `  Updated: ${m.updatedAt}`,
                "  Fields:",
                ...formatMetaobjectFields(m.fields),
              ].join("\n"),
            },
          ],
        };
      },
    );
  • The GET_METAOBJECT_QUERY GraphQL query string used by the handler. Queries a single metaobject by ID, returning id, type, handle, displayName, updatedAt, capabilities (publishable status), and fields (key, type, value, jsonValue).
    const GET_METAOBJECT_QUERY = /* GraphQL */ `
      query GetMetaobject($id: ID!) {
        metaobject(id: $id) {
          id
          type
          handle
          displayName
          updatedAt
          capabilities { publishable { status } }
          fields { key type value jsonValue }
        }
      }
    `;
  • Helper function formatMetaobjectFields() used by the handler to format field key/type/value pairs, truncating values longer than 120 characters for display.
    function formatMetaobjectFields(fields: MetaobjectField[]): string[] {
      return fields.map((f) => {
        const val =
          f.value === null || f.value === undefined
            ? "(null)"
            : f.value.length > 120
              ? `${f.value.slice(0, 120)}…`
              : f.value;
        return `    ${f.key} (${f.type}): ${val}`;
      });
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses a key behavioral detail: field values longer than 120 characters are truncated in the rendered output (but full values remain on the underlying record). This is critical for an agent to set expectations. It doesn't cover authentication or rate limits, but for a read-only operation, the disclosure is adequate.

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, front-loaded with the core purpose, immediately followed by the truncation detail and usage advice. Every part is essential and well-organized, with no wasted words.

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

Completeness4/5

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

Although there is no output schema, the description explicitly lists what is returned (display name, handle, type, publishable status, all field values) and notes the truncation behavior. This gives agents a clear understanding of the response content. It could mention any pagination or sorting, but given the tool fetches a single item by ID, it is sufficiently complete.

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?

The only parameter 'id' has 100% schema description coverage with an example GID and a reference to list_metaobjects. The description adds value by repeating and contextualizing the schema's guidance on discovering GIDs, reinforcing the workflow. This goes beyond what the schema alone provides.

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 exact verb ('Fetch'), the resource ('single metaobject'), the method of identification ('by GID'), and the specific fields returned ('display name, handle, type, publishable status, and all of its field values'). It also notes the truncation behavior, which adds precision. The purpose is distinct from sibling tools like 'list_metaobjects' and 'list_metaobject_definitions'.

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

Usage Guidelines4/5

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

The description explicitly instructs the agent to use 'list_metaobjects' first to discover GIDs, providing a clear prerequisite and pointing to the correct sibling tool for discovery. While it doesn't explicitly state when not to use this tool, the guidance is sufficient for an agent to understand the typical workflow.

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