Skip to main content
Glama

createProduct

Add new products to the Omnisend catalog by defining details such as title, description, variants, images, and pricing. Streamlines product management for targeted marketing campaigns.

Instructions

Create a new product in the Omnisend catalog. Product data can include details like title, description, variants, images, price, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productDataYesProduct data

Implementation Reference

  • MCP tool handler for createProduct: invokes API createProduct, filters response with filterProductFields, formats as MCP text content with JSON.
    async (args) => { try { const response = await createProduct(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" }] }; } }
  • JSON Schema defining the input for createProduct tool: requires productData as object with arbitrary properties.
    { additionalProperties: false, properties: { productData: { additionalProperties: true, description: "Product data", properties: {}, type: "object" } }, required: ["productData"], type: "object" },
  • Registers the 'createProduct' MCP tool on the server using server.tool, specifying name, description, input schema, and handler function.
    server.tool( "createProduct", "Create a new product in the Omnisend catalog. Product data can include details like title, description, variants, images, price, and more.", { additionalProperties: false, properties: { productData: { additionalProperties: true, description: "Product data", properties: {}, type: "object" } }, required: ["productData"], type: "object" }, async (args) => { try { const response = await createProduct(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 utility function imported and called by the tool handler; performs the actual HTTP POST to /products endpoint.
    export const createProduct = async (productData: Partial<Product>): Promise<Product> => { try { const response = await omnisendApi.post<Product>('/products', productData); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error creating product: ${error.message}`); } else { throw new Error('Unknown error occurred when creating product'); } }
  • Supporting utility to filter product data to a safe set of fields before returning in MCP response.
    export const filterProductFields = (product: any) => { return { productID: product.productID, title: product.title, status: product.status, description: product.description, currency: product.currency, price: product.price, oldPrice: product.oldPrice, productUrl: product.productUrl, imageUrl: product.imageUrl, vendor: product.vendor, variants: product.variants, createdAt: product.createdAt, updatedAt: product.updatedAt }; };

Other Tools

Related Tools

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