Skip to main content
Glama

delete_metafield

Delete a single metafield permanently by specifying owner ID, namespace, and key. Use list_metafields to verify before deletion.

Instructions

Permanently delete a single metafield by (ownerId, namespace, key). Irreversible — the value is gone after this call. Use list_metafields first to confirm the namespace and key, since typos result in a no-op rather than an error. Other metafields on the same resource are unaffected. To delete every metafield on a resource, you'd need a list+loop pattern; this tool only deletes one at a time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerIdYesGID of the owning resource.
namespaceYesMetafield namespace.
keyYesMetafield key.

Implementation Reference

  • Registration of the 'delete_metafield' tool on the MCP server, wiring it to the deleteMetafieldSchema and the async handler that calls the Shopify GraphQL mutation.
    server.tool(
      "delete_metafield",
      "Permanently delete a single metafield by (ownerId, namespace, key). Irreversible — the value is gone after this call. Use list_metafields first to confirm the namespace and key, since typos result in a no-op rather than an error. Other metafields on the same resource are unaffected. To delete every metafield on a resource, you'd need a list+loop pattern; this tool only deletes one at a time.",
      deleteMetafieldSchema,
      async (args) => {
        const data = await client.graphql<{
          metafieldDelete: {
            deletedId: string | null;
            userErrors: ShopifyUserError[];
          };
        }>(METAFIELD_DELETE_MUTATION, {
          input: {
            ownerId: args.ownerId,
            namespace: args.namespace,
            key: args.key,
          },
        });
        throwIfUserErrors(data.metafieldDelete.userErrors, "metafieldDelete");
        return {
          content: [
            {
              type: "text" as const,
              text: data.metafieldDelete.deletedId
                ? `Deleted metafield ${data.metafieldDelete.deletedId}.`
                : "No metafield matched; nothing deleted.",
            },
          ],
        };
      },
    );
  • Async handler function that executes the delete_metafield tool logic: calls the Shopify GraphQL metafieldDelete mutation using ownerId, namespace, and key, then returns the result.
    async (args) => {
      const data = await client.graphql<{
        metafieldDelete: {
          deletedId: string | null;
          userErrors: ShopifyUserError[];
        };
      }>(METAFIELD_DELETE_MUTATION, {
        input: {
          ownerId: args.ownerId,
          namespace: args.namespace,
          key: args.key,
        },
      });
      throwIfUserErrors(data.metafieldDelete.userErrors, "metafieldDelete");
      return {
        content: [
          {
            type: "text" as const,
            text: data.metafieldDelete.deletedId
              ? `Deleted metafield ${data.metafieldDelete.deletedId}.`
              : "No metafield matched; nothing deleted.",
          },
        ],
      };
    },
  • Zod schema defining the input parameters for delete_metafield: ownerId (string), namespace (string), key (string).
    const deleteMetafieldSchema = {
      ownerId: z.string().describe("GID of the owning resource."),
      namespace: z.string().describe("Metafield namespace."),
      key: z.string().describe("Metafield key."),
    };
  • The METAFIELD_DELETE_MUTATION GraphQL string used by the delete_metafield handler to delete a metafield via Shopify's Admin API.
    const METAFIELD_DELETE_MUTATION = /* GraphQL */ `
      mutation MetafieldDelete($input: MetafieldIdentifierInput!) {
        metafieldDelete(input: $input) {
          deletedId
          userErrors { field message }
        }
      }
    `;
  • src/server.ts:61-69 (registration)
    Top-level registration call that wires registerMetafieldTools (which registers delete_metafield) into the MCP server.
    registerMetafieldTools(s, shopify);
    registerDraftOrderTools(s, shopify);
    registerCollectionTools(s, shopify);
    registerVariantTools(s, shopify);
    registerFulfillmentTools(s, shopify);
    registerWebhookTools(s, shopify);
    registerMetaobjectTools(s, shopify);
    registerAnalyticsTools(s, shopify);
    registerBridgeTools(s, shopify, comfyui, config.comfyUIDefaultCkpt);
Behavior5/5

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

The description discloses that the deletion is irreversible, that other metafields on the same resource are unaffected, and that the operation is a no-op for invalid keys. With no annotations provided, this fully informs the agent of the tool's behavioral traits.

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 concise, front-loaded with the core purpose, and each sentence adds necessary context without redundancy. It efficiently covers irreversibility, prerequisites, and limitations.

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?

Given the tool has no output schema and no annotations, the description adequately covers deletion behavior, safety notes, and usage patterns. Minor gap: no mention of the response (e.g., whether it returns success or the deleted entity), but this is not critical for an agent to use the tool correctly.

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?

The input schema already provides descriptions for all three parameters (100% coverage), so the description adds no additional semantic detail beyond restating the parameter names. The baseline of 3 is appropriate as the schema does the heavy lifting.

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 begins with 'Permanently delete a single metafield by (ownerId, namespace, key)', which is a specific verb and resource with the required parameters. It clearly distinguishes this tool from siblings like set_metafield and delete_metaobject by specifying the exact identification triple.

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?

Explicitly recommends using list_metafields first to confirm namespace and key, warns that typos cause a no-op rather than an error, and explains that only one metafield is deleted per call (not bulk). This provides clear guidance on when and how to use the tool.

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