get_type_info
Retrieve detailed type information for Square API methods, ensuring correct data structure before making API requests with the make_api_request tool.
Instructions
Get type information for a Square API method. You must call this before calling the make_api_request tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | The API method to call (e.g., 'list', 'create') | |
| service | Yes | The Square API service category (e.g., 'catalog', 'payments') |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"method": {
"description": "The API method to call (e.g., 'list', 'create')",
"type": "string"
},
"service": {
"description": "The Square API service category (e.g., 'catalog', 'payments')",
"type": "string"
}
},
"required": [
"service",
"method"
],
"type": "object"
}
Implementation Reference
- server.ts:247-287 (handler)Handler function that executes the get_type_info tool logic: validates service and method, retrieves requestType from serviceMethodsMap, fetches typeInfo from typeMap, and returns JSON stringified type information.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 }; } }
- server.ts:243-246 (schema)Input schema for get_type_info tool using Zod, defining 'service' and 'method' string parameters.{ 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')") },
- server.ts:240-288 (registration)MCP server registration of the 'get_type_info' tool, including description, schema, and handler.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 }; } } );