Skip to main content
Glama
hungryweb

CS-Cart MCP Server

by hungryweb

get_products

Retrieve and filter a list of products from a CS-Cart store using pagination, status, category, or search queries for efficient product management and inventory tracking.

Instructions

Retrieve a list of products from the CS-Cart store

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
category_idNoFilter by category ID
items_per_pageNoNumber of items per page
pageNoPage number for pagination
qNoSearch query for product name
statusNoProduct status filter (A=Active, D=Disabled, H=Hidden)

Implementation Reference

  • The core handler function that implements the get_products tool logic. It constructs URL query parameters from input arguments and fetches products from the CS-Cart API endpoint `/products`, returning the JSON response as tool content.
    async getProducts(args) { const params = new URLSearchParams(); if (args.page) params.append('page', args.page.toString()); if (args.items_per_page) params.append('items_per_page', args.items_per_page.toString()); if (args.status) params.append('status', args.status); if (args.category_id) params.append('cid', args.category_id.toString()); if (args.q) params.append('q', args.q); const queryString = params.toString(); const endpoint = `/products${queryString ? `?${queryString}` : ''}`; const result = await this.makeRequest('GET', endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • Defines the input schema for the get_products tool, specifying optional parameters for pagination, status filtering, category filtering, and search query.
    inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination', default: 1, }, items_per_page: { type: 'number', description: 'Number of items per page', default: 10, }, status: { type: 'string', description: 'Product status filter (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], }, category_id: { type: 'number', description: 'Filter by category ID', }, q: { type: 'string', description: 'Search query for product name', }, }, },
  • src/index.js:43-74 (registration)
    Registers the get_products tool in the ListTools response, including its name, description, and input schema.
    { name: 'get_products', description: 'Retrieve a list of products from the CS-Cart store', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination', default: 1, }, items_per_page: { type: 'number', description: 'Number of items per page', default: 10, }, status: { type: 'string', description: 'Product status filter (A=Active, D=Disabled, H=Hidden)', enum: ['A', 'D', 'H'], }, category_id: { type: 'number', description: 'Filter by category ID', }, q: { type: 'string', description: 'Search query for product name', }, }, }, },
  • src/index.js:390-391 (registration)
    Dispatches calls to the get_products tool handler in the CallToolRequestHandler switch statement.
    case 'get_products': return await this.getProducts(args);
  • Shared helper method used by getProducts (and other tools) to make 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; }

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