get_users
Retrieve a paginated list of users/customers from CS-Cart, filtered by status and user type (Admin, Vendor, or Customer). Manage data efficiently with page and item-per-page controls.
Instructions
Get list of users/customers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items_per_page | No | Number of items per page | |
| page | No | Page number for pagination | |
| status | No | User status filter (A=Active, D=Disabled) | |
| user_type | No | User type filter (A=Admin, V=Vendor, C=Customer) |
Implementation Reference
- src/index.js:531-544 (handler)Core handler function that constructs query parameters from input args and makes a GET request to the CS-Cart /users API endpoint, returning the JSON response.async getUsers(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.user_type) params.append('user_type', args.user_type); const queryString = params.toString(); const endpoint = `/users${queryString ? `?${queryString}` : ''}`; const result = await this.makeRequest('GET', endpoint); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/index.js:327-355 (registration)Registers the get_users tool in the ListToolsRequest handler, providing name, description, and input schema.{ name: 'get_users', description: 'Get list of users/customers', 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: 'User status filter (A=Active, D=Disabled)', enum: ['A', 'D'], }, user_type: { type: 'string', description: 'User type filter (A=Admin, V=Vendor, C=Customer)', enum: ['A', 'V', 'C'], }, }, }, },
- src/index.js:330-354 (schema)Input schema definition for the get_users tool, specifying parameters for pagination, status, and user type filtering.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: 'User status filter (A=Active, D=Disabled)', enum: ['A', 'D'], }, user_type: { type: 'string', description: 'User type filter (A=Admin, V=Vendor, C=Customer)', enum: ['A', 'V', 'C'], }, }, },
- src/index.js:410-411 (registration)Dispatches execution of the get_users tool in the CallToolRequest handler by calling the getUsers method.case 'get_users': return await this.getUsers(args);
- src/index.js:424-440 (helper)Shared helper method used by getUsers to make authenticated API requests to the CS-Cart backend.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; }