Skip to main content
Glama
pashaydev

Terminal.shop MCP Server

by pashaydev

add-to-cart

Add products to your shopping cart by specifying product variant ID and quantity for purchase through Terminal.shop's API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productVariantIDYes
quantityYes

Implementation Reference

  • Handler function that adds the specified product variant and quantity to the shopping cart via the Terminal.shop API, then returns updated cart summary.
    async ({ productVariantID, quantity }) => {
      try {
        const response = await terminalApi.put("/cart/item", {
          productVariantID,
          quantity,
        });
    
        const cart = response.data.data;
    
        let formattedText = "# Item Added to Cart\n\n";
        formattedText += `Successfully added item to your cart.\n\n`;
    
        formattedText += "## Updated Cart\n";
        formattedText += `Items: ${cart.items.length}\n`;
        formattedText += `Subtotal: $${cart.subtotal / 100}\n`;
    
        if (cart.amount && cart.amount.shipping) {
          formattedText += `Shipping: $${cart.amount.shipping / 100}\n`;
          if (cart.amount.total) {
            formattedText += `Total: $${cart.amount.total / 100}\n`;
          } else {
            formattedText += `Total: $${(cart.amount.subtotal + cart.amount.shipping) / 100}\n`;
          }
        }
    
        return {
          content: [
            {
              type: "text",
              text: formattedText,
            },
          ],
        };
      } catch (error) {
        console.error("Error adding item to cart:", error);
        return {
          content: [
            {
              type: "text",
              text: `Error adding item to cart: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    },
  • Zod input schema defining required parameters: productVariantID (string) and quantity (positive integer).
    {
      productVariantID: z.string(),
      quantity: z.number().int().positive(),
    },
  • server.js:564-616 (registration)
    MCP server.tool registration that defines the 'add-to-cart' tool including its schema and handler.
    server.tool(
      "add-to-cart",
      {
        productVariantID: z.string(),
        quantity: z.number().int().positive(),
      },
      async ({ productVariantID, quantity }) => {
        try {
          const response = await terminalApi.put("/cart/item", {
            productVariantID,
            quantity,
          });
    
          const cart = response.data.data;
    
          let formattedText = "# Item Added to Cart\n\n";
          formattedText += `Successfully added item to your cart.\n\n`;
    
          formattedText += "## Updated Cart\n";
          formattedText += `Items: ${cart.items.length}\n`;
          formattedText += `Subtotal: $${cart.subtotal / 100}\n`;
    
          if (cart.amount && cart.amount.shipping) {
            formattedText += `Shipping: $${cart.amount.shipping / 100}\n`;
            if (cart.amount.total) {
              formattedText += `Total: $${cart.amount.total / 100}\n`;
            } else {
              formattedText += `Total: $${(cart.amount.subtotal + cart.amount.shipping) / 100}\n`;
            }
          }
    
          return {
            content: [
              {
                type: "text",
                text: formattedText,
              },
            ],
          };
        } catch (error) {
          console.error("Error adding item to cart:", error);
          return {
            content: [
              {
                type: "text",
                text: `Error adding item to cart: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
      },
    );
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/pashaydev/terminal.shop.mcp'

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