Skip to main content
Glama
hungryweb

CS-Cart MCP Server

by hungryweb

get_categories

Retrieve a list of product categories from CS-Cart stores. Filter by parent category ID or status (Active, Disabled, Hidden) to organize and manage e-commerce product structures effectively.

Instructions

Get list of product categories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parent_idNoParent category ID (0 for root categories)
statusNoCategory status filter (A=Active, D=Disabled, H=Hidden)

Implementation Reference

  • The core handler function for the 'get_categories' tool. It constructs query parameters from input args (parent_id and status), makes a GET request to the CS-Cart /categories endpoint via the makeRequest helper, and returns the JSON response formatted as text content.
    async getCategories(args) { const params = new URLSearchParams(); if (args.parent_id !== undefined) params.append('parent_id', args.parent_id.toString()); if (args.status) params.append('status', args.status); const queryString = params.toString(); const endpoint = `/categories${queryString ? `?${queryString}` : ''}`; const result = await this.makeRequest('GET', endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • Input schema definition for the 'get_categories' tool, specifying optional parent_id (number, default 0) and status (string enum ['A','D','H']) properties.
    inputSchema: { type: 'object', properties: { parent_id: { type: 'number', description: 'Parent category ID (0 for root categories)', default: 0, }, status: { type: 'string', description: 'Category status filter (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], }, }, },
  • src/index.js:225-243 (registration)
    Registration of the 'get_categories' tool in the ListToolsRequestSchema response, defining its name, description, and input schema.
    { name: 'get_categories', description: 'Get list of product categories', inputSchema: { type: 'object', properties: { parent_id: { type: 'number', description: 'Parent category ID (0 for root categories)', default: 0, }, status: { type: 'string', description: 'Category status filter (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], }, }, }, },
  • Dispatch case in the CallToolRequestSchema handler that invokes the getCategories method for the 'get_categories' tool.
    case 'get_categories': return await this.getCategories(args);
  • Shared helper method used by getCategories (and other tools) to perform authenticated HTTP requests to the CS-Cart API.
    async makeRequest(method, endpoint, data = null) { const config = { method, url: `${process.env.CSCART_API_URL}${endpoint}`, headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${Buffer.from(`${process.env.CSCART_API_EMAIL}:${process.env.CSCART_API_KEY}`).toString('base64')}`, }, }; if (data) { config.data = data; } const response = await axios(config); return response.data; }

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/hungryweb/cscart-mcp'

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