karrito-mcp 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12,9 +12,11 @@ import { register as registerCurrencies } from './resources/currencies.js';
12
12
  import { register as registerCatalogTools } from './tools/catalog.js';
13
13
  import { register as registerProductTools } from './tools/products.js';
14
14
  import { register as registerOrderTools } from './tools/orders.js';
15
+ import { register as registerCategoryTools } from './tools/categories.js';
16
+ import { register as registerStoreTools } from './tools/store.js';
15
17
  const server = new McpServer({
16
18
  name: 'karrito',
17
- version: '1.0.0',
19
+ version: '1.1.0',
18
20
  });
19
21
  const client = new KarritoApiClient();
20
22
  // Register static resources (public, no auth needed)
@@ -27,6 +29,8 @@ registerCurrencies(server);
27
29
  registerCatalogTools(server, client);
28
30
  registerProductTools(server, client);
29
31
  registerOrderTools(server, client);
32
+ registerCategoryTools(server, client);
33
+ registerStoreTools(server, client);
30
34
  // Connect via stdio
31
35
  async function main() {
32
36
  const transport = new StdioServerTransport();
@@ -19,5 +19,9 @@ export declare class KarritoApiClient {
19
19
  listCategories(limit?: number, offset?: number): Promise<unknown>;
20
20
  listOrders(limit?: number, offset?: number, status?: string): Promise<unknown>;
21
21
  getOrder(id: string): Promise<unknown>;
22
+ updateProduct(id: string, data: Record<string, unknown>): Promise<unknown>;
23
+ deleteProduct(id: string): Promise<unknown>;
24
+ createCategory(data: Record<string, unknown>): Promise<unknown>;
25
+ getStore(): Promise<unknown>;
22
26
  }
23
27
  export {};
@@ -14,7 +14,7 @@ export class KarritoApiClient {
14
14
  async request(path, options = {}) {
15
15
  const headers = {
16
16
  'Content-Type': 'application/json',
17
- 'User-Agent': 'karrito-mcp/1.0.0',
17
+ 'User-Agent': 'karrito-mcp/1.1.0',
18
18
  };
19
19
  if (this.apiKey) {
20
20
  headers['Authorization'] = `Bearer ${this.apiKey}`;
@@ -70,4 +70,24 @@ export class KarritoApiClient {
70
70
  async getOrder(id) {
71
71
  return this.request(`/api/v1/orders/${id}`);
72
72
  }
73
+ async updateProduct(id, data) {
74
+ return this.request(`/api/v1/products/${id}`, {
75
+ method: 'PUT',
76
+ body: JSON.stringify(data),
77
+ });
78
+ }
79
+ async deleteProduct(id) {
80
+ return this.request(`/api/v1/products/${id}`, {
81
+ method: 'DELETE',
82
+ });
83
+ }
84
+ async createCategory(data) {
85
+ return this.request('/api/v1/categories', {
86
+ method: 'POST',
87
+ body: JSON.stringify(data),
88
+ });
89
+ }
90
+ async getStore() {
91
+ return this.request('/api/v1/store');
92
+ }
73
93
  }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { KarritoApiClient } from '../lib/api-client.js';
3
+ export declare function register(server: McpServer, client: KarritoApiClient): void;
@@ -0,0 +1,76 @@
1
+ import { z } from 'zod';
2
+ export function register(server, client) {
3
+ // --- list_categories (auth required) ---
4
+ server.tool('list_categories', 'List categories in your Karrito store. Requires KARRITO_API_KEY environment variable.', {
5
+ limit: z.number().min(1).max(100).default(50).describe('Max categories to return (1-100)'),
6
+ offset: z.number().min(0).default(0).describe('Pagination offset'),
7
+ }, async ({ limit, offset }) => {
8
+ if (!client.hasApiKey) {
9
+ return {
10
+ content: [
11
+ {
12
+ type: 'text',
13
+ text: 'Authentication required. Set the KARRITO_API_KEY environment variable with your Karrito API key. You can generate one at https://karrito.shop/settings/api',
14
+ },
15
+ ],
16
+ isError: true,
17
+ };
18
+ }
19
+ try {
20
+ const data = await client.listCategories(limit, offset);
21
+ return {
22
+ content: [
23
+ {
24
+ type: 'text',
25
+ text: JSON.stringify(data, null, 2),
26
+ },
27
+ ],
28
+ };
29
+ }
30
+ catch (error) {
31
+ const message = error instanceof Error ? error.message : 'Unknown error';
32
+ return {
33
+ content: [{ type: 'text', text: `Error listing categories: ${message}` }],
34
+ isError: true,
35
+ };
36
+ }
37
+ });
38
+ // --- create_category (auth required) ---
39
+ server.tool('create_category', 'Create a new category in your Karrito store. Requires KARRITO_API_KEY environment variable.', {
40
+ name: z.string().min(1).max(100).describe('Category name'),
41
+ position: z.number().int().min(0).optional().describe('Sort order (lower = first)'),
42
+ }, async ({ name, position }) => {
43
+ if (!client.hasApiKey) {
44
+ return {
45
+ content: [
46
+ {
47
+ type: 'text',
48
+ text: 'Authentication required. Set the KARRITO_API_KEY environment variable with your Karrito API key. You can generate one at https://karrito.shop/settings/api',
49
+ },
50
+ ],
51
+ isError: true,
52
+ };
53
+ }
54
+ try {
55
+ const categoryData = { name };
56
+ if (position !== undefined)
57
+ categoryData.position = position;
58
+ const data = await client.createCategory(categoryData);
59
+ return {
60
+ content: [
61
+ {
62
+ type: 'text',
63
+ text: JSON.stringify(data, null, 2),
64
+ },
65
+ ],
66
+ };
67
+ }
68
+ catch (error) {
69
+ const message = error instanceof Error ? error.message : 'Unknown error';
70
+ return {
71
+ content: [{ type: 'text', text: `Error creating category: ${message}` }],
72
+ isError: true,
73
+ };
74
+ }
75
+ });
76
+ }
@@ -80,4 +80,89 @@ export function register(server, client) {
80
80
  };
81
81
  }
82
82
  });
83
+ // --- update_product (auth required) ---
84
+ server.tool('update_product', 'Update an existing product in your Karrito catalog. Requires KARRITO_API_KEY environment variable.', {
85
+ id: z.string().describe('Product ID to update'),
86
+ name: z.string().min(1).max(200).optional().describe('New product name'),
87
+ price: z.number().min(0).optional().describe('New price in store currency'),
88
+ description: z.string().max(2000).optional().describe('New product description'),
89
+ categoryId: z.string().optional().describe('New category ID'),
90
+ comparePrice: z.number().min(0).optional().describe('Compare-at price (must be > price)'),
91
+ isActive: z.boolean().optional().describe('Whether the product is active'),
92
+ }, async ({ id, ...updates }) => {
93
+ if (!client.hasApiKey) {
94
+ return {
95
+ content: [
96
+ {
97
+ type: 'text',
98
+ text: 'Authentication required. Set the KARRITO_API_KEY environment variable with your Karrito API key. You can generate one at https://karrito.shop/settings/api',
99
+ },
100
+ ],
101
+ isError: true,
102
+ };
103
+ }
104
+ try {
105
+ const updateData = {};
106
+ for (const [key, value] of Object.entries(updates)) {
107
+ if (value !== undefined)
108
+ updateData[key] = value;
109
+ }
110
+ if (Object.keys(updateData).length === 0) {
111
+ return {
112
+ content: [{ type: 'text', text: 'No fields to update. Provide at least one field (name, price, description, categoryId, comparePrice, isActive).' }],
113
+ isError: true,
114
+ };
115
+ }
116
+ const data = await client.updateProduct(id, updateData);
117
+ return {
118
+ content: [
119
+ {
120
+ type: 'text',
121
+ text: JSON.stringify(data, null, 2),
122
+ },
123
+ ],
124
+ };
125
+ }
126
+ catch (error) {
127
+ const message = error instanceof Error ? error.message : 'Unknown error';
128
+ return {
129
+ content: [{ type: 'text', text: `Error updating product: ${message}` }],
130
+ isError: true,
131
+ };
132
+ }
133
+ });
134
+ // --- delete_product (auth required) ---
135
+ server.tool('delete_product', 'Delete a product from your Karrito catalog (soft delete). Requires KARRITO_API_KEY environment variable.', {
136
+ id: z.string().describe('Product ID to delete'),
137
+ }, async ({ id }) => {
138
+ if (!client.hasApiKey) {
139
+ return {
140
+ content: [
141
+ {
142
+ type: 'text',
143
+ text: 'Authentication required. Set the KARRITO_API_KEY environment variable with your Karrito API key. You can generate one at https://karrito.shop/settings/api',
144
+ },
145
+ ],
146
+ isError: true,
147
+ };
148
+ }
149
+ try {
150
+ const data = await client.deleteProduct(id);
151
+ return {
152
+ content: [
153
+ {
154
+ type: 'text',
155
+ text: JSON.stringify(data, null, 2),
156
+ },
157
+ ],
158
+ };
159
+ }
160
+ catch (error) {
161
+ const message = error instanceof Error ? error.message : 'Unknown error';
162
+ return {
163
+ content: [{ type: 'text', text: `Error deleting product: ${message}` }],
164
+ isError: true,
165
+ };
166
+ }
167
+ });
83
168
  }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { KarritoApiClient } from '../lib/api-client.js';
3
+ export declare function register(server: McpServer, client: KarritoApiClient): void;
@@ -0,0 +1,34 @@
1
+ export function register(server, client) {
2
+ // --- get_my_store (auth required) ---
3
+ server.tool('get_my_store', 'Get information about your Karrito store (name, slug, currency, stats). Requires KARRITO_API_KEY environment variable.', {}, async () => {
4
+ if (!client.hasApiKey) {
5
+ return {
6
+ content: [
7
+ {
8
+ type: 'text',
9
+ text: 'Authentication required. Set the KARRITO_API_KEY environment variable with your Karrito API key. You can generate one at https://karrito.shop/settings/api',
10
+ },
11
+ ],
12
+ isError: true,
13
+ };
14
+ }
15
+ try {
16
+ const data = await client.getStore();
17
+ return {
18
+ content: [
19
+ {
20
+ type: 'text',
21
+ text: JSON.stringify(data, null, 2),
22
+ },
23
+ ],
24
+ };
25
+ }
26
+ catch (error) {
27
+ const message = error instanceof Error ? error.message : 'Unknown error';
28
+ return {
29
+ content: [{ type: 'text', text: `Error getting store info: ${message}` }],
30
+ isError: true,
31
+ };
32
+ }
33
+ });
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karrito-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "MCP server for Karrito — digital catalog builder for WhatsApp sellers in LATAM",
5
5
  "bin": {
6
6
  "karrito-mcp": "./dist/index.js"