Skip to main content
Glama
ampcome-mcps

Square Model Context Protocol Server

by ampcome-mcps

make_api_request

Execute Square API operations to manage payments, orders, customers, inventory, and other business data through a unified interface.

Instructions

Unified tool for all Square API operations. Be sure to get types before calling. Available services: applepay, bankaccounts, bookingcustomattributes, bookings, cards, cashdrawers, catalog, checkout, customercustomattributes, customergroups, customersegments, customers, devices, disputes, events, giftcardactivities, giftcards, inventory, invoices, labor, locationcustomattributes, locations, loyalty, merchantcustomattributes, merchants, oauth, ordercustomattributes, orders, payments, payouts, refunds, sites, snippets, subscriptions, team, terminal, vendors, webhooksubscriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceYesThe Square API service category (e.g., 'catalog', 'payments')
methodYesThe API method to call (e.g., 'list', 'create')
requestNoThe request object for the API call.

Implementation Reference

  • The core handler function for the make_api_request tool. It destructures params, capitalizes service name, validates service and method using serviceMethodsMap, checks for write permissions, retrieves the specific handler from serviceHandlersMap, calls it with access token and request, and returns the result or error.
    async (params) => {
      try {
        const { service, method, request } = params;
        const serviceName = service.charAt(0).toUpperCase() + service.slice(1);
        
        const methods = serviceMethodsMap[serviceName];
        if (!methods) {
          throw new Error(`Invalid service: ${service}. Available services: ${JSON.stringify(Object.keys(serviceMethodsMap), null, 2)}`);
        }
    
        const handlers = serviceHandlersMap[serviceName];
        if (!methods[method]) {
          throw new Error(`Invalid method ${method} for service ${service}. Available methods: ${JSON.stringify(Object.keys(methods), null, 2)}`);
        }
        
    
        // Support read-only mode if desired
        const methodInfo = methods[method];
        if (process.env.DISALLOW_WRITES == "true" && methodInfo?.isWrite) {
          throw new Error(`Write operations are not allowed in this environment. Please set DISALLOW_WRITES to false to enable write operations. Attempted operation: ${service}.${method}`);
        }
    
        const handler = handlers[method];
        if (!handler) {
          throw new Error(`No handler found for ${service}.${method}`);
        }
    
        const token = await getAccessToken();
        const result = await handler(token, request || {});
    
        return {
          content: [{
            type: "text",
            text: result as string
          }]
        };
      } catch (err: any) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: err.message,
              details: err.errors || err.stack
            }, null, 2)
          }],
          isError: true
        };
      }
    });
  • Zod input schema defining the parameters for make_api_request: service (string), method (string), and optional request object (passthrough).
    {
      service: z.string().describe("The Square API service category (e.g., 'catalog', 'payments')"),
      method: z.string().describe("The API method to call (e.g., 'list', 'create')"),
      request: z.object({}).passthrough().optional().describe("The request object for the API call.")
    },
  • server.ts:180-237 (registration)
    The MCP server.tool() registration call that registers the 'make_api_request' tool with its name, description listing available services, input schema, and handler function.
    server.tool(
      "make_api_request",
      `Unified tool for all Square API operations. Be sure to get types before calling. Available services:
      ${Object.keys(serviceMethodsMap).map(name => name.toLowerCase()).join(", ")}.`,
      {
        service: z.string().describe("The Square API service category (e.g., 'catalog', 'payments')"),
        method: z.string().describe("The API method to call (e.g., 'list', 'create')"),
        request: z.object({}).passthrough().optional().describe("The request object for the API call.")
      },
      async (params) => {
        try {
          const { service, method, request } = params;
          const serviceName = service.charAt(0).toUpperCase() + service.slice(1);
          
          const methods = serviceMethodsMap[serviceName];
          if (!methods) {
            throw new Error(`Invalid service: ${service}. Available services: ${JSON.stringify(Object.keys(serviceMethodsMap), null, 2)}`);
          }
    
          const handlers = serviceHandlersMap[serviceName];
          if (!methods[method]) {
            throw new Error(`Invalid method ${method} for service ${service}. Available methods: ${JSON.stringify(Object.keys(methods), null, 2)}`);
          }
          
    
          // Support read-only mode if desired
          const methodInfo = methods[method];
          if (process.env.DISALLOW_WRITES == "true" && methodInfo?.isWrite) {
            throw new Error(`Write operations are not allowed in this environment. Please set DISALLOW_WRITES to false to enable write operations. Attempted operation: ${service}.${method}`);
          }
    
          const handler = handlers[method];
          if (!handler) {
            throw new Error(`No handler found for ${service}.${method}`);
          }
    
          const token = await getAccessToken();
          const result = await handler(token, request || {});
    
          return {
            content: [{
              type: "text",
              text: result as string
            }]
          };
        } catch (err: any) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: err.message,
                details: err.errors || err.stack
              }, null, 2)
            }],
            isError: true
          };
        }
      });
  • serviceHandlersMap aggregates all imported service-specific handlers (e.g., CatalogHandlers, PaymentsHandlers) used by the make_api_request handler to dispatch to the correct API implementation.
    export const serviceHandlersMap: ServiceHandlers = {
      "ApplePay": ApplePayHandlers,
      "BankAccounts": BankAccountsHandlers,
      "BookingCustomAttributes": BookingCustomAttributesHandlers,
      "Bookings": BookingsHandlers,
      "Cards": CardsHandlers,
      "CashDrawers": CashDrawersHandlers,
      "Catalog": CatalogHandlers,
      "Checkout": CheckoutHandlers,
      "CustomerCustomAttributes": CustomerCustomAttributesHandlers,
      "CustomerGroups": CustomerGroupsHandlers,
      "CustomerSegments": CustomerSegmentsHandlers,
      "Customers": CustomersHandlers,
      "Devices": DevicesHandlers,
      "Disputes": DisputesHandlers,
      "Events": EventsHandlers,
      "GiftCardActivities": GiftCardActivitiesHandlers,
      "GiftCards": GiftCardsHandlers,
      "Inventory": InventoryHandlers,
      "Invoices": InvoicesHandlers,
      "Labor": LaborHandlers,
      "LocationCustomAttributes": LocationCustomAttributesHandlers,
      "Locations": LocationsHandlers,
      "Loyalty": LoyaltyHandlers,
      "MerchantCustomAttributes": MerchantCustomAttributesHandlers,
      "Merchants": MerchantsHandlers,
      "OAuth": OAuthHandlers,
      "OrderCustomAttributes": OrderCustomAttributesHandlers,
      "Orders": OrdersHandlers,
      "Payments": PaymentsHandlers,
      "Payouts": PayoutsHandlers,
      "Refunds": RefundsHandlers,
      "Sites": SitesHandlers,
      "Snippets": SnippetsHandlers,
      "Subscriptions": SubscriptionsHandlers,
      "Team": TeamHandlers,
      "Terminal": TerminalHandlers,
      "Vendors": VendorsHandlers,
      "WebhookSubscriptions": WebhookSubscriptionsHandlers
    };
  • serviceMethodsMap aggregates metadata for all Square API services and methods (descriptions, request types, isWrite flags), used for validation and info in make_api_request.
    export const serviceMethodsMap: ServiceMethods = {
      "ApplePay": ApplePayMethods,
      "BankAccounts": BankAccountsMethods,
      "BookingCustomAttributes": BookingCustomAttributesMethods,
      "Bookings": BookingsMethods,
      "Cards": CardsMethods,
      "CashDrawers": CashDrawersMethods,
      "Catalog": CatalogMethods,
      "Checkout": CheckoutMethods,
      "CustomerCustomAttributes": CustomerCustomAttributesMethods,
      "CustomerGroups": CustomerGroupsMethods,
      "CustomerSegments": CustomerSegmentsMethods,
      "Customers": CustomersMethods,
      "Devices": DevicesMethods,
      "Disputes": DisputesMethods,
      "Events": EventsMethods,
      "GiftCardActivities": GiftCardActivitiesMethods,
      "GiftCards": GiftCardsMethods,
      "Inventory": InventoryMethods,
      "Invoices": InvoicesMethods,
      "Labor": LaborMethods,
      "LocationCustomAttributes": LocationCustomAttributesMethods,
      "Locations": LocationsMethods,
      "Loyalty": LoyaltyMethods,
      "MerchantCustomAttributes": MerchantCustomAttributesMethods,
      "Merchants": MerchantsMethods,
      "OAuth": OAuthMethods,
      "OrderCustomAttributes": OrderCustomAttributesMethods,
      "Orders": OrdersMethods,
      "Payments": PaymentsMethods,
      "Payouts": PayoutsMethods,
      "Refunds": RefundsMethods,
      "Sites": SitesMethods,
      "Snippets": SnippetsMethods,
      "Subscriptions": SubscriptionsMethods,
      "Team": TeamMethods,
      "Terminal": TerminalMethods,
      "Vendors": VendorsMethods,
      "WebhookSubscriptions": WebhookSubscriptionsMethods
    };

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations, the description carries full burden but only states it is a unified tool and lists services. It does not disclose that it makes HTTP calls, requires authentication, can modify data, or has rate limits. Minimal behavioral context is provided.

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 extremely concise—two sentences with no superfluous words. It front-loads the core purpose and then lists services efficiently.

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?

Despite the tool's complexity (any API operation), the description lacks details on return values, how to structure the request object, or supported methods beyond 'list' and 'create' implied. Sibling tools exist but the description does not fully compensate for missing output schema or behavioral specifics.

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

Parameters4/5

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

Schema coverage is 100%, but the description adds value by enumerating all available services, which is absent as enum constraints in the schema. This helps the agent select valid service values, going beyond the generic schema description.

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 states it is a unified tool for all Square API operations, clearly indicating its purpose as a general-purpose API caller. It distinguishes from sibling tools (get_service_info, get_type_info) by specifying it performs operations rather than information retrieval.

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 advises to 'get types before calling,' providing a prerequisite but not explicit when-to-use or when-not-to-use guidance. It implies this is the primary tool for API calls but does not contrast with alternatives beyond the mention of getting types.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools