Skip to main content
Glama
square

Square Model Context Protocol Server

Official
by square

make_api_request

Execute Square API operations to manage customers, process payments, handle inventory, and access other Square services through the Model Context Protocol.

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

  • Core execution logic for the 'make_api_request' tool. Dispatches requests to specific Square API service handlers based on service and method parameters, handles errors, and enforces write permissions.
    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 parameters for the 'make_api_request' tool: service, method, and optional request body.
    {
      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)
    MCP server registration of the 'make_api_request' tool, including name, description, 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
          };
        }
      });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'Be sure to get types before calling' which hints at a prerequisite, but doesn't describe authentication requirements, rate limits, error handling, or what happens when calls fail. For a general API request tool with no annotation coverage, this leaves significant behavioral gaps about how the tool actually operates and what to expect.

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

Conciseness4/5

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

The description is appropriately sized with two sentences: a purpose statement and a service list. The service list is comprehensive but necessary for this type of tool. The structure is front-loaded with the key information first. While the service list is long, it serves a clear purpose in defining scope.

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?

For a complex API gateway tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain return values, error conditions, authentication requirements, or how to interpret results. The mention of 'get types before calling' hints at complexity but doesn't provide enough context for proper usage. Given the tool's complexity and lack of structured documentation, more comprehensive guidance 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 three parameters (service, method, request) adequately. The description adds value by listing specific service categories (applepay, bankaccounts, etc.) which provides concrete examples beyond the schema's generic description. However, it doesn't explain parameter relationships or provide additional semantic context about how these parameters work together.

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

Purpose2/5

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

The description states 'Unified tool for all Square API operations' which is a tautology of the name 'make_api_request' - it essentially restates that this makes API requests. While it lists available services, it doesn't specify what the tool actually does with those services (execute operations, make calls, etc.). The verb 'make_api_request' is clear but the description doesn't elaborate beyond restating this basic concept.

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 provides some guidance with 'Be sure to get types before calling' which implies a prerequisite workflow. It also lists available services which helps identify scope. However, it doesn't explicitly state when to use this tool versus the sibling tools (get_service_info, get_type_info) or provide clear alternatives for specific scenarios. The guidance is implied rather than explicit.

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/square/square-mcp-server'

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