Skip to main content
Glama
wspotter

MCP Art Supply Store

by wspotter

calculate_discount

Calculate discounted prices for art supplies using percentage, fixed amount, loyalty, or bulk order discounts based on product SKU and quantity.

Instructions

Calculate discounted price for promotions, bulk orders, or loyalty rewards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
discountTypeYesType: percentage, fixed, loyalty, bulk
discountValueYesDiscount percentage or fixed amount
quantityNoQuantity for bulk pricing
skuYesProduct SKU

Implementation Reference

  • Defines the input schema for the calculate_discount tool, specifying parameters like sku, discountType, discountValue, and optional quantity.
      name: 'calculate_discount',
      description: 'Calculate discounted price for promotions, bulk orders, or loyalty rewards.',
      inputSchema: {
        type: 'object',
        properties: {
          sku: { type: 'string', description: 'Product SKU' },
          discountType: { type: 'string', description: 'Type: percentage, fixed, loyalty, bulk' },
          discountValue: { type: 'number', description: 'Discount percentage or fixed amount' },
          quantity: { type: 'number', description: 'Quantity for bulk pricing' },
        },
        required: ['sku', 'discountType', 'discountValue'],
      },
    },
  • src/index.ts:516-518 (registration)
    Registers all tools including calculate_discount by returning the tools array in response to ListToolsRequestSchema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
  • The handler function for calculate_discount: parses arguments, finds product in inventory, applies discount based on type, computes final price and total, returns formatted response.
    case 'calculate_discount': {
      const sku = String(args?.sku || '');
      const discountType = String(args?.discountType || 'percentage');
      const discountValue = Number(args?.discountValue || 0);
      const quantity = Number(args?.quantity || 1);
      
      const item = storeData.inventory.find(i => i.id === sku);
      if (!item) {
        return { content: [{ type: 'text', text: `❌ Product ${sku} not found` }] };
      }
      
      let finalPrice = item.price;
      let discount = 0;
      
      switch (discountType) {
        case 'percentage':
          discount = item.price * (discountValue / 100);
          finalPrice = item.price - discount;
          break;
        case 'fixed':
          discount = discountValue;
          finalPrice = item.price - discount;
          break;
        case 'loyalty':
          discount = discountValue / 10;
          finalPrice = item.price - discount;
          break;
        case 'bulk':
          if (quantity >= 5) {
            discount = item.price * 0.15;
            finalPrice = item.price - discount;
          }
          break;
      }
      
      return {
        content: [{
          type: 'text',
          text: `💲 Price Calculation: ${item.name}\n\n- Original Price: $${item.price}\n- Discount Type: ${discountType}\n- Discount Amount: $${discount.toFixed(2)}\n- Final Price: $${finalPrice.toFixed(2)}\n- Quantity: ${quantity}\n- Total: $${(finalPrice * quantity).toFixed(2)}`
        }]
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions what the tool does but lacks details on how it behaves: no information on whether it performs calculations only (read-only) or modifies data, what the output format might be, error handling, or any constraints like rate limits or authentication requirements. This is a significant gap for a tool with no annotation coverage.

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 a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part earns its place by specifying the action and key contexts, making it easy to scan and understand quickly.

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

Completeness2/5

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

Given the tool's complexity (4 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the return values, error conditions, or behavioral traits, leaving gaps that could hinder an AI agent's ability to use the tool correctly. For a calculation tool with multiple inputs, more context is needed.

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 description coverage is 100%, so the schema already documents all parameters. The description adds minimal value beyond the schema by hinting at the discount types (promotions, bulk, loyalty) which loosely maps to 'discountType', but doesn't provide additional semantics or clarify relationships between parameters (e.g., how 'quantity' interacts with 'discountType'). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose as calculating discounted prices for specific scenarios (promotions, bulk orders, loyalty rewards), using a specific verb ('calculate') and resource ('discounted price'). It doesn't explicitly distinguish from sibling tools like 'calculate_labor_cost' or 'calculate_profit_margin', but the focus on discount calculation is sufficiently distinct.

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

Usage Guidelines3/5

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

The description implies usage contexts (promotions, bulk orders, loyalty rewards) but doesn't provide explicit guidance on when to use this tool versus alternatives like 'suggest_bundle' or 'compare_supplier_prices'. No exclusions or prerequisites are mentioned, leaving usage somewhat open to interpretation.

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/wspotter/mcpart'

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