getCategory
Retrieve detailed product category information from Omnisend marketing platform using unique identifiers to manage product data.
Instructions
Retrieve detailed information about a specific product category by its unique identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/categories/index.ts:98-119 (handler)MCP tool handler for getCategory: calls API function, applies field filter, returns formatted JSON response or error.async (args) => { try { const response = await getCategory(args.categoryId); // 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" }] }; } }
- src/tools/categories/index.ts:90-97 (schema)Input JSON schema for getCategory tool: requires categoryId string.{ additionalProperties: false, properties: { categoryId: { description: "Category ID", type: "string" } }, required: ["categoryId"], type: "object" },
- src/tools/categories/index.ts:87-87 (registration)Registration of the getCategory MCP tool on the server.server.tool(
- Core helper function implementing the Omnisend API call to fetch a single product category by ID.export const getCategory = async (categoryId: string): Promise<ProductCategory> => { try { const response = await omnisendApi.get<ProductCategory>(`/product-categories/${categoryId}`); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error getting category information: ${error.message}`); } else { throw new Error('Unknown error occurred when getting category'); } }
- src/filters/categories/index.ts:1-13 (helper)Helper utility to filter and select specific fields from category data for tool responses.// Filter function for category data export const filterCategoryFields = (category: any) => { return { categoryID: category.categoryID, title: category.title, handle: category.handle, description: category.description, imageUrl: category.imageUrl, categoryUrl: category.categoryUrl, createdAt: category.createdAt, updatedAt: category.updatedAt }; };