Skip to main content
Glama
ampcome-mcps

Square Model Context Protocol Server

by ampcome-mcps

get_type_info

Retrieve API method specifications for Square services to ensure proper data formatting before making requests.

Instructions

Get type information for a Square API method. You must call this before calling the make_api_request tool.

Input Schema

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

Implementation Reference

  • server.ts:240-288 (registration)
    Registration of the 'get_type_info' MCP tool, including name, description, input schema, and inline handler function.
    server.tool(
      "get_type_info",
      "Get type information for a Square API method. You must call this before calling the make_api_request tool.",
      {
        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')")
      },
      async (params) => {
        try {
          const { service, method } = 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)}`);
          }
    
          if (!methods[method]) {
            throw new Error(`Invalid method ${method} for service ${service}. Available methods: ${JSON.stringify(Object.keys(methods), null, 2)}`);
          }
    
          const methodInfo = methods[method];
          const requestTypeName = methodInfo.requestType;
          
          const typeInfo = typeMap[requestTypeName];
          if (!typeInfo) {
            throw new Error(`Type information not found for ${requestTypeName}`);
          }
    
          return {
            content: [{
              type: "text",
              text: JSON.stringify(typeInfo, null, 2)
            }]
          };
        } catch (err: any) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: err.message,
                details: err.errors || err.stack
              }, null, 2)
            }],
            isError: true
          };
        }
      }
    );
  • Executes the logic for 'get_type_info': capitalizes service name, retrieves method info from serviceMethodsMap, fetches type info from typeMap using requestType, and returns as JSON text content.
    async (params) => {
      try {
        const { service, method } = 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)}`);
        }
    
        if (!methods[method]) {
          throw new Error(`Invalid method ${method} for service ${service}. Available methods: ${JSON.stringify(Object.keys(methods), null, 2)}`);
        }
    
        const methodInfo = methods[method];
        const requestTypeName = methodInfo.requestType;
        
        const typeInfo = typeMap[requestTypeName];
        if (!typeInfo) {
          throw new Error(`Type information not found for ${requestTypeName}`);
        }
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(typeInfo, null, 2)
          }]
        };
      } 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 for the 'get_type_info' tool, requiring 'service' and 'method' strings.
    {
      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')")
    },

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

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