Skip to main content
Glama
wspotter

MCP Art Supply Store

by wspotter

calculate_profit_margin

Calculate profit margin for art supplies using cost and selling price to determine product profitability and inform pricing decisions.

Instructions

Calculate profit margin for a product or category based on cost and selling price.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
costPriceYesCost price per unit
skuYesProduct SKU

Implementation Reference

  • Handler implementation for calculate_profit_margin tool. Looks up product by SKU from mock inventory data, calculates profit per unit and profit margin percentage, and formats a detailed analysis response including potential revenue from current stock.
    case 'calculate_profit_margin': {
      const sku = String(args?.sku || '');
      const costPrice = Number(args?.costPrice || 0);
      const item = storeData.inventory.find(i => i.id === sku);
      
      if (!item) {
        return { content: [{ type: 'text', text: `❌ Product ${sku} not found` }] };
      }
      
      const profit = item.price - costPrice;
      const margin = (profit / item.price) * 100;
      
      return {
        content: [{
          type: 'text',
          text: `💰 Profit Analysis: ${item.name}\n\n- Selling Price: $${item.price}\n- Cost Price: $${costPrice.toFixed(2)}\n- Profit per Unit: $${profit.toFixed(2)}\n- Profit Margin: ${margin.toFixed(1)}%\n- Potential Revenue (current stock): $${(item.quantity * profit).toFixed(2)}`
        }]
      };
    }
  • Tool schema definition including name, description, and input schema requiring 'sku' (string) and 'costPrice' (number). This is part of the tools array returned by ListToolsRequestHandler.
    {
      name: 'calculate_profit_margin',
      description: 'Calculate profit margin for a product or category based on cost and selling price.',
      inputSchema: {
        type: 'object',
        properties: {
          sku: { type: 'string', description: 'Product SKU' },
          costPrice: { type: 'number', description: 'Cost price per unit' },
        },
        required: ['sku', 'costPrice'],
      },
    },
  • src/index.ts:516-518 (registration)
    Registration of all tools (including calculate_profit_margin via the 'tools' array) for the ListTools MCP request.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
  • src/dashboard.ts:50-50 (registration)
    Mock tool listing/registration for dashboard display purposes.
    { name: 'calculate_profit_margin', description: 'Calculate profitability', category: 'Sales & Analytics' },

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