getProduct
Retrieve detailed product information using a unique product ID to access specific data through the Omnisend MCP Server for marketing platform integration.
Instructions
Retrieve detailed information about a specific product by its unique identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Product ID |
Implementation Reference
- src/tools/products/index.ts:104-125 (handler)The handler function that executes the 'getProduct' MCP tool logic. It calls the underlying API function, filters the product fields, formats the response as JSON, and handles errors.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-102 (schema)The JSON Schema defining the input parameters for the 'getProduct' tool, which requires a 'productId' string.{ additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" } }, required: ["productId"], type: "object"
- src/tools/products/index.ts:93-126 (registration)The server.tool() call that registers the 'getProduct' MCP tool on the server, providing name, description, input 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 utility function 'getProduct' that makes the HTTP GET request to the Omnisend API to fetch product details by ID, used by the MCP tool handler.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'); } } };
- src/index.ts:31-35 (registration)High-level registration calls for all tool sets on the MCP server, including registerProductsTools which registers 'getProduct' among others.registerContactsTools(server); registerProductsTools(server); registerCategoriesTools(server); registerEventsTools(server); registerBrandsTools(server);