catalog_get_product
Retrieve full product details using SKU. Access all product information stored in the Magento catalog.
Instructions
Get full product details by SKU.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "catalog_get_product"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | Action parameters as a JSON object |
Implementation Reference
- src/actions/catalog.ts:70-83 (handler)Handler function for catalog.get_product that validates input via CatalogGetProductSchema, creates an API client, and makes a GET request to Magento's /V1/products/{sku} endpoint.
// ── Get Product ─────────────────────────────────────────────────────── { name: 'catalog.get_product', description: 'Get full product details by SKU.', riskTier: RiskTier.Safe, requiresAuth: true, handler: async (params: Record<string, unknown>, context: ActionContext) => { const validated = CatalogGetProductSchema.parse(params); const client = context.getClient(); const storeCode = validated.scope?.store_view_code; const result = await client.get(`/V1/products/${encodeURIComponent(validated.sku)}`, undefined, storeCode); return result; }, }, - src/validation/schemas.ts:133-136 (schema)Zod schema defining input validation: requires a non-empty string 'sku' and optional 'scope' (with store_view_code).
export const CatalogGetProductSchema = z.object({ sku: z.string().min(1), scope: StoreScopeSchema.optional(), }); - src/index.ts:76-159 (registration)Registration of all actions (including catalog.get_product) as MCP tools. The tool name is derived by replacing dots with underscores (catalog.get_product -> catalog_get_product).
for (const action of allActions) { // Convert dots to underscores for MCP tool names (e.g. "auth.login" -> "auth_login") const toolName = action.name.replace(/\./g, '_'); mcpServer.tool( toolName, action.description, { params: z.record(z.unknown()).optional().describe('Action parameters as a JSON object') }, async (args) => { const params = (args.params || {}) as Record<string, unknown>; // Check authentication if (action.requiresAuth) { const token = sessionStore.getToken(sessionId); if (!token) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: { code: 'NOT_AUTHENTICATED', message: 'Not authenticated. Call auth_login first.' } }, null, 2) }], isError: true, }; } } // Build action context const context: ActionContext = { sessionId, getToken: () => sessionStore.getToken(sessionId), getBaseUrl: () => sessionStore.getBaseUrl(sessionId), getDefaultScope: () => sessionStore.getDefaultScope(sessionId), getOAuthCredentials: () => sessionStore.getOAuthCredentials(sessionId), getClient: () => { const baseUrl = sessionStore.getBaseUrl(sessionId); const token = sessionStore.getToken(sessionId); if (!baseUrl) throw new Error('No active session'); const client = new MagentoRestClient(baseUrl, token); const oauth = sessionStore.getOAuthCredentials(sessionId); if (oauth) client.setOAuth(oauth); return client; }, username: sessionStore.getUsername(sessionId), }; try { const result = await action.handler(params, context); // Audit log const auditRecord: AuditRecord = { timestamp: new Date().toISOString(), username: context.username, action: action.name, scope: context.getDefaultScope(), params, result_summary: summarizeResult(result), plan_id: (params['plan_id'] as string) || null, reason: (params['reason'] as string) || null, }; auditLogger.log(auditRecord); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; } catch (err) { const errorMessage = err instanceof Error ? err.message : String(err); // Audit the error const auditRecord: AuditRecord = { timestamp: new Date().toISOString(), username: context.username, action: action.name, scope: null, params, result_summary: `ERROR: ${errorMessage}`, plan_id: null, reason: null, }; auditLogger.log(auditRecord); return { content: [{ type: 'text' as const, text: JSON.stringify({ error: errorMessage }, null, 2) }], isError: true, }; } }, ); } - src/index.ts:51-61 (registration)Collection of all action definitions from createCatalogActions (which includes catalog.get_product).
const allActions: ActionDefinition[] = [ ...createAuthActions(sessionStore), ...createScopeActions(sessionStore), ...createPromotionsActions(planStore, guardrails, config), ...createCatalogActions(planStore, guardrails, idempotencyLedger, config), ...createPricingActions(planStore, guardrails, idempotencyLedger, config), ...createCmsActions(planStore, guardrails, config), ...createSeoActions(planStore, guardrails, config), ...createDiagnosticsActions(), ...createCacheActions(guardrails, config), ];