getProduct
Retrieve detailed product information from the Omnisend marketing platform using a unique identifier to access specific product data for management and tracking operations.
Instructions
Retrieve detailed information about a specific product by its unique identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/products/index.ts:104-125 (handler)The handler function for the 'getProduct' tool. It calls the underlying API function, applies field filtering, and returns the product data as formatted JSON text in the MCP response format.async (args) => { try { const response = await getProduct(args.productId); // Filter product data to include only defined fields const filteredProduct = filterProductFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredProduct, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } }
- src/tools/products/index.ts:96-103 (schema)Input schema validation for the 'getProduct' tool, specifying that a 'productId' string is required.{ additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" } }, required: ["productId"], type: "object" },
- src/tools/products/index.ts:93-126 (registration)Registration of the 'getProduct' tool on the MCP server using server.tool(), including name, description, schema, and handler.server.tool( "getProduct", "Retrieve detailed information about a specific product by its unique identifier.", { additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" } }, required: ["productId"], type: "object" }, async (args) => { try { const response = await getProduct(args.productId); // Filter product data to include only defined fields const filteredProduct = filterProductFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredProduct, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
- Supporting API utility function that performs the HTTP GET request to retrieve product details from the Omnisend API.export const getProduct = async (productId: string): Promise<Product> => { try { const response = await omnisendApi.get<Product>(`/products/${productId}`); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error getting product information: ${error.message}`); } else { throw new Error('Unknown error occurred when getting product'); } } };