Skip to main content
Glama

replaceProduct

Update existing product information in Omnisend by modifying specific fields while maintaining the original data structure for accurate synchronization.

Instructions

Replace an existing product with new data. IMPORTANT: You must first get the product using getProduct and preserve the returned structure when replacing. The replace request requires the same structure as returned by the GET method, with only your desired changes applied.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'replaceProduct' MCP tool. It invokes the API replaceProduct helper, filters the response using filterProductFields, formats it as JSON text content, and handles errors by returning error messages.
    async (args) => { try { const response = await replaceProduct(args.productId, args.productData); // 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" }] }; } }
  • Input schema definition for the 'replaceProduct' tool, specifying parameters productId (string) and productData (object).
    { additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" }, productData: { additionalProperties: true, description: "Product data in the same structure as returned by getProduct", properties: {}, type: "object" } }, required: ["productId", "productData"], type: "object" },
  • Registration of the 'replaceProduct' tool on the MCP server using server.tool(), including name, description, schema, and handler.
    server.tool( "replaceProduct", "Replace an existing product with new data. IMPORTANT: You must first get the product using getProduct and preserve the returned structure when replacing. The replace request requires the same structure as returned by the GET method, with only your desired changes applied.", { additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" }, productData: { additionalProperties: true, description: "Product data in the same structure as returned by getProduct", properties: {}, type: "object" } }, required: ["productId", "productData"], type: "object" }, async (args) => { try { const response = await replaceProduct(args.productId, args.productData); // 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" }] }; } } );
  • API helper function that performs the HTTP PUT request to the Omnisend API to replace a product by ID.
    export const replaceProduct = async (productId: string, productData: Partial<Product>): Promise<Product> => { try { const response = await omnisendApi.put<Product>(`/products/${productId}`, productData); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error replacing product: ${error.message}`); } else { throw new Error('Unknown error occurred when replacing product'); } }

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/plutzilla/omnisend-mcp'

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