Skip to main content
Glama

createCategory

Add new product categories to the Omnisend catalog with details like title, description, image, and URL for organized product management.

Instructions

Create a new product category in the Omnisend catalog. Category data can include title, description, image, and URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the createCategory MCP tool. It invokes the underlying API createCategory function, applies field filtering, formats the response as JSON text content, and handles errors appropriately.
    async (args) => { try { const response = await createCategory(args.categoryData); // Filter category data to include only defined fields const filteredCategory = filterCategoryFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredCategory, 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 (JSON Schema) for the createCategory tool, specifying that categoryData is a required object with additional properties allowed.
    { additionalProperties: false, properties: { categoryData: { additionalProperties: true, description: "Product category data", properties: {}, type: "object" } }, required: ["categoryData"], type: "object" },
  • MCP tool registration call using server.tool() for the createCategory tool, including name, description, schema, and handler.
    server.tool( "createCategory", "Create a new product category in the Omnisend catalog. Category data can include title, description, image, and URL.", { additionalProperties: false, properties: { categoryData: { additionalProperties: true, description: "Product category data", properties: {}, type: "object" } }, required: ["categoryData"], type: "object" }, async (args) => { try { const response = await createCategory(args.categoryData); // Filter category data to include only defined fields const filteredCategory = filterCategoryFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredCategory, 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" }] }; } } );
  • Helper function that performs the actual HTTP POST request to the Omnisend API to create a product category.
    export const createCategory = async (categoryData: Partial<ProductCategory>): Promise<ProductCategory> => { try { const response = await omnisendApi.post<ProductCategory>('/product-categories', categoryData); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error creating category: ${error.message}`); } else { throw new Error('Unknown error occurred when creating category'); } } };
  • src/index.ts:33-33 (registration)
    Invocation of registerCategoriesTools which registers the createCategory tool (among others) on the MCP server.
    registerCategoriesTools(server);

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