Skip to main content
Glama

listCategories

Retrieve paginated product categories from the Omnisend catalog to manage and organize e-commerce inventory.

Instructions

Retrieve a list of product categories from the Omnisend catalog with pagination support. The response includes pagination information (next/previous cursor, limit, offset).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the "listCategories" MCP tool. It calls the underlying API function, filters the categories using filterCategoryFields, formats the response as JSON, and handles errors by returning error text content.
    async (args) => { try { const response = await listCategories(args); // Filter categories data to include only defined fields const filteredCategories = response.categories.map(filterCategoryFields); return { content: [ { type: "text", text: JSON.stringify({ categories: filteredCategories, paging: response.paging }, 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" }] }; } }
  • The JSON schema defining the input parameters for the listCategories tool: optional limit and offset for pagination.
    { additionalProperties: false, properties: { limit: { description: "Maximum number of categories to return", type: "number" }, offset: { description: "Skip first N results", type: "number" } }, type: "object" },
  • The registration of the "listCategories" tool using McpServer.tool(), including name, description, input schema, and handler function.
    server.tool( "listCategories", "Retrieve a list of product categories from the Omnisend catalog with pagination support. The response includes pagination information (next/previous cursor, limit, offset).", { additionalProperties: false, properties: { limit: { description: "Maximum number of categories to return", type: "number" }, offset: { description: "Skip first N results", type: "number" } }, type: "object" }, async (args) => { try { const response = await listCategories(args); // Filter categories data to include only defined fields const filteredCategories = response.categories.map(filterCategoryFields); return { content: [ { type: "text", text: JSON.stringify({ categories: filteredCategories, paging: response.paging }, 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 API call to Omnisend's /product-categories endpoint, used by the tool handler.
    export const listCategories = async (params: ListCategoriesParams = {}): Promise<CategoriesResponse> => { try { const response = await omnisendApi.get<CategoriesResponse>('/product-categories', { params }); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error getting categories list: ${error.message}`); } else { throw new Error('Unknown error occurred when getting categories list'); } } };

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