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 }; } });

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