Skip to main content
Glama

delete_metafield

Delete a single metafield by owner ID, namespace, and key. Use list_metafields to verify identifiers beforehand to avoid irreversible removal.

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

  • Handler function for the delete_metafield tool. Calls Shopify's metafieldDelete mutation with 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.",
            },
          ],
        };
      },
    );
  • Input schema for delete_metafield tool defining three required string parameters: ownerId, namespace, and key.
    const deleteMetafieldSchema = {
      ownerId: z.string().describe("GID of the owning resource."),
      namespace: z.string().describe("Metafield namespace."),
      key: z.string().describe("Metafield key."),
    };
  • Registration of the delete_metafield tool on the MCP server via registerMetafieldTools (called from src/server.ts:61).
    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.",
            },
          ],
        };
      },
    );
  • GraphQL mutation string used by the delete_metafield handler to call Shopify's metafieldDelete.
    const METAFIELD_DELETE_MUTATION = /* GraphQL */ `
      mutation MetafieldDelete($input: MetafieldIdentifierInput!) {
        metafieldDelete(input: $input) {
          deletedId
          userErrors { field message }
        }
      }
    `;
Behavior5/5

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

No annotations provided, so description carries full burden. It discloses irreversibility, no-op on typos, and that other metafields on the same resource are unaffected. Provides clear behavioral expectations.

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?

Three sentences, no fluff. Front-loaded with the core action and immediate consequences. Every sentence adds 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?

For a simple delete tool with no output schema, the description explains outcome, edge cases (typo), and ties to sibling workflows (list_metafields). Fully covers what an agent needs.

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 descriptions for each parameter. The description does not add new parameter-level detail beyond the schema, but reinforces the triple key. Baseline 3 is appropriate.

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?

Clearly states it permanently deletes a single metafield by ownerId, namespace, key. Distinguishes from sibling tools like list_metafields (for confirmation) and set_metafield (for setting). Verb 'delete' + specific resource 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 instructs to use list_metafields first to confirm namespace and key, mentions that typos result in no-op, and clarifies that only one metafield is deleted per call, recommending a list+loop pattern for bulk deletion.

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