@hed-hog/category 0.0.349 → 0.0.351

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.
@@ -1 +1 @@
1
- {"version":3,"file":"category.module.d.ts","sourceRoot":"","sources":["../src/category.module.ts"],"names":[],"mappings":"AAMA,qBASa,cAAc;CAAG"}
1
+ {"version":3,"file":"category.module.d.ts","sourceRoot":"","sources":["../src/category.module.ts"],"names":[],"mappings":"AAOA,qBASa,cAAc;CAAG"}
@@ -12,6 +12,7 @@ const api_pagination_1 = require("@hed-hog/api-pagination");
12
12
  const common_1 = require("@nestjs/common");
13
13
  const category_controller_1 = require("./category.controller");
14
14
  const category_service_1 = require("./category.service");
15
+ const category_mcp_tools_1 = require("./mcp-tools/category.mcp-tools");
15
16
  let CategoryModule = class CategoryModule {
16
17
  };
17
18
  exports.CategoryModule = CategoryModule;
@@ -22,7 +23,7 @@ exports.CategoryModule = CategoryModule = __decorate([
22
23
  (0, common_1.forwardRef)(() => api_pagination_1.PaginationModule),
23
24
  ],
24
25
  controllers: [category_controller_1.CategoryController],
25
- providers: [category_service_1.CategoryService],
26
+ providers: [category_service_1.CategoryService, category_mcp_tools_1.CategoryMcpTools],
26
27
  exports: [category_service_1.CategoryService],
27
28
  })
28
29
  ], CategoryModule);
@@ -1 +1 @@
1
- {"version":3,"file":"category.module.js","sourceRoot":"","sources":["../src/category.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAmD;AACnD,4DAA2D;AAC3D,2CAAoD;AACpD,+DAA2D;AAC3D,yDAAqD;AAW9C,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAT1B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,yBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,iCAAgB,CAAC;SACnC;QACD,WAAW,EAAE,CAAC,wCAAkB,CAAC;QACjC,SAAS,EAAE,CAAC,kCAAe,CAAC;QAC5B,OAAO,EAAE,CAAC,kCAAe,CAAC;KAC3B,CAAC;GACW,cAAc,CAAG"}
1
+ {"version":3,"file":"category.module.js","sourceRoot":"","sources":["../src/category.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAmD;AACnD,4DAA2D;AAC3D,2CAAoD;AACpD,+DAA2D;AAC3D,yDAAqD;AACrD,uEAAkE;AAW3D,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAT1B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,yBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,iCAAgB,CAAC;SACnC;QACD,WAAW,EAAE,CAAC,wCAAkB,CAAC;QACjC,SAAS,EAAE,CAAC,kCAAe,EAAE,qCAAgB,CAAC;QAC9C,OAAO,EAAE,CAAC,kCAAe,CAAC;KAC3B,CAAC;GACW,cAAc,CAAG"}
@@ -0,0 +1,15 @@
1
+ import { McpContext } from '@hed-hog/core';
2
+ import { CategoryService } from '../category.service';
3
+ export declare class CategoryMcpTools {
4
+ private readonly categoryService;
5
+ constructor(categoryService: CategoryService);
6
+ list(args: Record<string, any>, context: McpContext): Promise<any>;
7
+ root(_args: Record<string, any>, context: McpContext): Promise<any>;
8
+ stats(_args: Record<string, any>, _context: McpContext): Promise<any>;
9
+ get(args: Record<string, any>, context: McpContext): Promise<any>;
10
+ getByParent(args: Record<string, any>, context: McpContext): Promise<any>;
11
+ create(args: Record<string, any>, context: McpContext): Promise<any>;
12
+ update(args: Record<string, any>, context: McpContext): Promise<any>;
13
+ delete(args: Record<string, any>, context: McpContext): Promise<any>;
14
+ }
15
+ //# sourceMappingURL=category.mcp-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category.mcp-tools.d.ts","sour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0,0 +1,204 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.CategoryMcpTools = void 0;
24
+ const core_1 = require("@hed-hog/core");
25
+ const common_1 = require("@nestjs/common");
26
+ const category_service_1 = require("../category.service");
27
+ let CategoryMcpTools = class CategoryMcpTools {
28
+ constructor(categoryService) {
29
+ this.categoryService = categoryService;
30
+ }
31
+ async list(args, context) {
32
+ var _a, _b, _c, _d, _e;
33
+ return this.categoryService.findAll({ page: (_a = args.page) !== null && _a !== void 0 ? _a : 1, pageSize: (_b = args.pageSize) !== null && _b !== void 0 ? _b : 20, search: (_c = args.search) !== null && _c !== void 0 ? _c : '' }, context.locale, (_d = args.status) !== null && _d !== void 0 ? _d : 'all', (_e = args.parent) !== null && _e !== void 0 ? _e : 'all');
34
+ }
35
+ async root(_args, context) {
36
+ return this.categoryService.getRootCategories(context.locale);
37
+ }
38
+ async stats(_args, _context) {
39
+ return this.categoryService.getStats();
40
+ }
41
+ async get(args, context) {
42
+ return this.categoryService.getById(context.locale, args.id);
43
+ }
44
+ async getByParent(args, context) {
45
+ return this.categoryService.getByParent(String(args.categoryId), context.locale);
46
+ }
47
+ async create(args, context) {
48
+ return this.categoryService.create(context.locale, args);
49
+ }
50
+ async update(args, context) {
51
+ const { id } = args, data = __rest(args, ["id"]);
52
+ return this.categoryService.update(context.locale, id, data);
53
+ }
54
+ async delete(args, context) {
55
+ return this.categoryService.delete(args.id, context.locale);
56
+ }
57
+ };
58
+ exports.CategoryMcpTools = CategoryMcpTools;
59
+ __decorate([
60
+ (0, core_1.McpTool)({
61
+ name: 'category.list',
62
+ description: 'Lists categories with pagination and optional status / parent filters.',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ page: { type: 'number', description: 'Page number (default: 1)' },
67
+ pageSize: { type: 'number', description: 'Items per page (default: 20)' },
68
+ search: { type: 'string', description: 'Search term (matches slug)' },
69
+ status: { type: 'string', enum: ['active', 'inactive', 'all'], description: 'Filter by status (default: all)' },
70
+ parent: { type: 'string', description: 'Filter by parent slug; use "root" for top-level categories, "all" for no filter' },
71
+ },
72
+ },
73
+ readOnly: true,
74
+ }),
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", [Object, Object]),
77
+ __metadata("design:returntype", Promise)
78
+ ], CategoryMcpTools.prototype, "list", null);
79
+ __decorate([
80
+ (0, core_1.McpTool)({
81
+ name: 'category.root',
82
+ description: 'Returns active root categories (categories without a parent).',
83
+ inputSchema: { type: 'object', properties: {} },
84
+ readOnly: true,
85
+ }),
86
+ __metadata("design:type", Function),
87
+ __metadata("design:paramtypes", [Object, Object]),
88
+ __metadata("design:returntype", Promise)
89
+ ], CategoryMcpTools.prototype, "root", null);
90
+ __decorate([
91
+ (0, core_1.McpTool)({
92
+ name: 'category.stats',
93
+ description: 'Returns category counts: total, totalActive, totalInactive, totalRoot.',
94
+ inputSchema: { type: 'object', properties: {} },
95
+ readOnly: true,
96
+ }),
97
+ __metadata("design:type", Function),
98
+ __metadata("design:paramtypes", [Object, Object]),
99
+ __metadata("design:returntype", Promise)
100
+ ], CategoryMcpTools.prototype, "stats", null);
101
+ __decorate([
102
+ (0, core_1.McpTool)({
103
+ name: 'category.get',
104
+ description: 'Returns a single category by ID, including locale translations.',
105
+ inputSchema: {
106
+ type: 'object',
107
+ properties: {
108
+ id: { type: 'number', description: 'Category ID' },
109
+ },
110
+ required: ['id'],
111
+ },
112
+ readOnly: true,
113
+ }),
114
+ __metadata("design:type", Function),
115
+ __metadata("design:paramtypes", [Object, Object]),
116
+ __metadata("design:returntype", Promise)
117
+ ], CategoryMcpTools.prototype, "get", null);
118
+ __decorate([
119
+ (0, core_1.McpTool)({
120
+ name: 'category.get-by-parent',
121
+ description: 'Returns categories that are direct children of the given parent category ID.',
122
+ inputSchema: {
123
+ type: 'object',
124
+ properties: {
125
+ categoryId: { type: 'number', description: 'Parent category ID' },
126
+ },
127
+ required: ['categoryId'],
128
+ },
129
+ readOnly: true,
130
+ }),
131
+ __metadata("design:type", Function),
132
+ __metadata("design:paramtypes", [Object, Object]),
133
+ __metadata("design:returntype", Promise)
134
+ ], CategoryMcpTools.prototype, "getByParent", null);
135
+ __decorate([
136
+ (0, core_1.McpTool)({
137
+ name: 'category.create',
138
+ description: 'Creates a new category with multi-locale names.',
139
+ inputSchema: {
140
+ type: 'object',
141
+ properties: {
142
+ slug: { type: 'string', description: 'Unique slug identifier' },
143
+ category_id: { type: 'number', description: 'Parent category ID (omit for root category)' },
144
+ color: { type: 'string', description: 'Color in hex format (e.g. #ff0000)' },
145
+ icon: { type: 'string', description: 'Icon identifier' },
146
+ status: { type: 'string', enum: ['active', 'inactive'], description: 'Category status' },
147
+ locale: {
148
+ type: 'object',
149
+ description: 'Locale translations as Record<localeCode, { name: string }> (e.g. { "en": { "name": "Electronics" } })',
150
+ },
151
+ },
152
+ required: ['slug', 'locale'],
153
+ },
154
+ }),
155
+ __metadata("design:type", Function),
156
+ __metadata("design:paramtypes", [Object, Object]),
157
+ __metadata("design:returntype", Promise)
158
+ ], CategoryMcpTools.prototype, "create", null);
159
+ __decorate([
160
+ (0, core_1.McpTool)({
161
+ name: 'category.update',
162
+ description: 'Updates an existing category by ID.',
163
+ inputSchema: {
164
+ type: 'object',
165
+ properties: {
166
+ id: { type: 'number', description: 'Category ID' },
167
+ slug: { type: 'string', description: 'Unique slug identifier' },
168
+ category_id: { type: 'number', description: 'Parent category ID' },
169
+ color: { type: 'string', description: 'Color in hex format' },
170
+ icon: { type: 'string', description: 'Icon identifier' },
171
+ status: { type: 'string', enum: ['active', 'inactive'], description: 'Category status' },
172
+ locale: {
173
+ type: 'object',
174
+ description: 'Locale translations as Record<localeCode, { name: string }>',
175
+ },
176
+ },
177
+ required: ['id'],
178
+ },
179
+ }),
180
+ __metadata("design:type", Function),
181
+ __metadata("design:paramtypes", [Object, Object]),
182
+ __metadata("design:returntype", Promise)
183
+ ], CategoryMcpTools.prototype, "update", null);
184
+ __decorate([
185
+ (0, core_1.McpTool)({
186
+ name: 'category.delete',
187
+ description: 'Deletes a category by ID.',
188
+ inputSchema: {
189
+ type: 'object',
190
+ properties: {
191
+ id: { type: 'number', description: 'Category ID' },
192
+ },
193
+ required: ['id'],
194
+ },
195
+ }),
196
+ __metadata("design:type", Function),
197
+ __metadata("design:paramtypes", [Object, Object]),
198
+ __metadata("design:returntype", Promise)
199
+ ], CategoryMcpTools.prototype, "delete", null);
200
+ exports.CategoryMcpTools = CategoryMcpTools = __decorate([
201
+ (0, common_1.Injectable)(),
202
+ __metadata("design:paramtypes", [category_service_1.CategoryService])
203
+ ], CategoryMcpTools);
204
+ //# sourceMappingURL=category.mcp-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category.mcp-tools.js","sourceRoot":"","sources":["../../src/mcp-tools/category.m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AAiB,EAAE;gBACxF,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6DAA6D;iBAC3E;aACF;YACD,QAAQ,EAAE,CAAC,IAAI,CAAC;SACjB;KACF,CAAC;;;;8CAID;AAaK;IAXL,IAAA,cAAO,EAAC;QACP,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,2BAA2B;QACxC,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE;aACnD;YACD,QAAQ,EAAE,CAAC,IAAI,CAAC;SACjB;KACF,CAAC;;;;8CAGD;2BA5IU,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAEmC,kCAAe;GADlD,gBAAgB,CA6I5B"}
@@ -61,4 +61,78 @@
61
61
  - where:
62
62
  slug: admin
63
63
  - where:
64
- slug: admin-category
64
+ slug: admin-category
65
+
66
+ - tool_name: category.list
67
+ type: MCP
68
+ name: Category List
69
+ relations:
70
+ role:
71
+ - where:
72
+ slug: admin
73
+ - where:
74
+ slug: admin-category
75
+
76
+ - tool_name: category.root
77
+ type: MCP
78
+ name: Category Root
79
+ relations:
80
+ role:
81
+ - where:
82
+ slug: admin
83
+ - where:
84
+ slug: admin-category
85
+
86
+ - tool_name: category.stats
87
+ type: MCP
88
+ name: Category Stats
89
+ relations:
90
+ role:
91
+ - where:
92
+ slug: admin
93
+ - where:
94
+ slug: admin-category
95
+
96
+ - tool_name: category.get
97
+ type: MCP
98
+ name: Category Get
99
+ relations:
100
+ role:
101
+ - where:
102
+ slug: admin
103
+ - where:
104
+ slug: admin-category
105
+
106
+ - tool_name: category.get-by-parent
107
+ type: MCP
108
+ name: Category Get By Parent
109
+ relations:
110
+ role:
111
+ - where:
112
+ slug: admin
113
+ - where:
114
+ slug: admin-category
115
+
116
+ - tool_name: category.create
117
+ type: MCP
118
+ name: Category Create
119
+ relations:
120
+ role:
121
+ - where:
122
+ slug: admin
123
+
124
+ - tool_name: category.update
125
+ type: MCP
126
+ name: Category Update
127
+ relations:
128
+ role:
129
+ - where:
130
+ slug: admin
131
+
132
+ - tool_name: category.delete
133
+ type: MCP
134
+ name: Category Delete
135
+ relations:
136
+ role:
137
+ - where:
138
+ slug: admin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/category",
3
- "version": "0.0.349",
3
+ "version": "0.0.351",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -10,10 +10,10 @@
10
10
  "@nestjs/jwt": "^11",
11
11
  "@nestjs/mapped-types": "*",
12
12
  "@hed-hog/api-locale": "0.0.14",
13
- "@hed-hog/api-prisma": "0.0.6",
14
- "@hed-hog/core": "0.0.349",
13
+ "@hed-hog/api": "0.0.8",
15
14
  "@hed-hog/api-pagination": "0.0.7",
16
- "@hed-hog/api": "0.0.8"
15
+ "@hed-hog/api-prisma": "0.0.6",
16
+ "@hed-hog/core": "0.0.351"
17
17
  },
18
18
  "exports": {
19
19
  ".": {
@@ -3,6 +3,7 @@ import { PaginationModule } from '@hed-hog/api-pagination';
3
3
  import { Module, forwardRef } from '@nestjs/common';
4
4
  import { CategoryController } from './category.controller';
5
5
  import { CategoryService } from './category.service';
6
+ import { CategoryMcpTools } from './mcp-tools/category.mcp-tools';
6
7
 
7
8
  @Module({
8
9
  imports: [
@@ -10,7 +11,7 @@ import { CategoryService } from './category.service';
10
11
  forwardRef(() => PaginationModule),
11
12
  ],
12
13
  controllers: [CategoryController],
13
- providers: [CategoryService],
14
+ providers: [CategoryService, CategoryMcpTools],
14
15
  exports: [CategoryService],
15
16
  })
16
17
  export class CategoryModule {}
@@ -0,0 +1,147 @@
1
+ import { McpContext, McpTool } from '@hed-hog/core';
2
+ import { Injectable } from '@nestjs/common';
3
+ import { CategoryService } from '../category.service';
4
+
5
+ @Injectable()
6
+ export class CategoryMcpTools {
7
+ constructor(private readonly categoryService: CategoryService) {}
8
+
9
+ @McpTool({
10
+ name: 'category.list',
11
+ description: 'Lists categories with pagination and optional status / parent filters.',
12
+ inputSchema: {
13
+ type: 'object',
14
+ properties: {
15
+ page: { type: 'number', description: 'Page number (default: 1)' },
16
+ pageSize: { type: 'number', description: 'Items per page (default: 20)' },
17
+ search: { type: 'string', description: 'Search term (matches slug)' },
18
+ status: { type: 'string', enum: ['active', 'inactive', 'all'], description: 'Filter by status (default: all)' },
19
+ parent: { type: 'string', description: 'Filter by parent slug; use "root" for top-level categories, "all" for no filter' },
20
+ },
21
+ },
22
+ readOnly: true,
23
+ })
24
+ async list(args: Record<string, any>, context: McpContext): Promise<any> {
25
+ return this.categoryService.findAll(
26
+ { page: args.page ?? 1, pageSize: args.pageSize ?? 20, search: args.search ?? '' } as any,
27
+ context.locale,
28
+ args.status ?? 'all',
29
+ args.parent ?? 'all',
30
+ );
31
+ }
32
+
33
+ @McpTool({
34
+ name: 'category.root',
35
+ description: 'Returns active root categories (categories without a parent).',
36
+ inputSchema: { type: 'object', properties: {} },
37
+ readOnly: true,
38
+ })
39
+ async root(_args: Record<string, any>, context: McpContext): Promise<any> {
40
+ return this.categoryService.getRootCategories(context.locale);
41
+ }
42
+
43
+ @McpTool({
44
+ name: 'category.stats',
45
+ description: 'Returns category counts: total, totalActive, totalInactive, totalRoot.',
46
+ inputSchema: { type: 'object', properties: {} },
47
+ readOnly: true,
48
+ })
49
+ async stats(_args: Record<string, any>, _context: McpContext): Promise<any> {
50
+ return this.categoryService.getStats();
51
+ }
52
+
53
+ @McpTool({
54
+ name: 'category.get',
55
+ description: 'Returns a single category by ID, including locale translations.',
56
+ inputSchema: {
57
+ type: 'object',
58
+ properties: {
59
+ id: { type: 'number', description: 'Category ID' },
60
+ },
61
+ required: ['id'],
62
+ },
63
+ readOnly: true,
64
+ })
65
+ async get(args: Record<string, any>, context: McpContext): Promise<any> {
66
+ return this.categoryService.getById(context.locale, args.id);
67
+ }
68
+
69
+ @McpTool({
70
+ name: 'category.get-by-parent',
71
+ description: 'Returns categories that are direct children of the given parent category ID.',
72
+ inputSchema: {
73
+ type: 'object',
74
+ properties: {
75
+ categoryId: { type: 'number', description: 'Parent category ID' },
76
+ },
77
+ required: ['categoryId'],
78
+ },
79
+ readOnly: true,
80
+ })
81
+ async getByParent(args: Record<string, any>, context: McpContext): Promise<any> {
82
+ return this.categoryService.getByParent(String(args.categoryId), context.locale);
83
+ }
84
+
85
+ @McpTool({
86
+ name: 'category.create',
87
+ description: 'Creates a new category with multi-locale names.',
88
+ inputSchema: {
89
+ type: 'object',
90
+ properties: {
91
+ slug: { type: 'string', description: 'Unique slug identifier' },
92
+ category_id: { type: 'number', description: 'Parent category ID (omit for root category)' },
93
+ color: { type: 'string', description: 'Color in hex format (e.g. #ff0000)' },
94
+ icon: { type: 'string', description: 'Icon identifier' },
95
+ status: { type: 'string', enum: ['active', 'inactive'], description: 'Category status' },
96
+ locale: {
97
+ type: 'object',
98
+ description: 'Locale translations as Record<localeCode, { name: string }> (e.g. { "en": { "name": "Electronics" } })',
99
+ },
100
+ },
101
+ required: ['slug', 'locale'],
102
+ },
103
+ })
104
+ async create(args: Record<string, any>, context: McpContext): Promise<any> {
105
+ return this.categoryService.create(context.locale, args as any);
106
+ }
107
+
108
+ @McpTool({
109
+ name: 'category.update',
110
+ description: 'Updates an existing category by ID.',
111
+ inputSchema: {
112
+ type: 'object',
113
+ properties: {
114
+ id: { type: 'number', description: 'Category ID' },
115
+ slug: { type: 'string', description: 'Unique slug identifier' },
116
+ category_id: { type: 'number', description: 'Parent category ID' },
117
+ color: { type: 'string', description: 'Color in hex format' },
118
+ icon: { type: 'string', description: 'Icon identifier' },
119
+ status: { type: 'string', enum: ['active', 'inactive'], description: 'Category status' },
120
+ locale: {
121
+ type: 'object',
122
+ description: 'Locale translations as Record<localeCode, { name: string }>',
123
+ },
124
+ },
125
+ required: ['id'],
126
+ },
127
+ })
128
+ async update(args: Record<string, any>, context: McpContext): Promise<any> {
129
+ const { id, ...data } = args;
130
+ return this.categoryService.update(context.locale, id, data as any);
131
+ }
132
+
133
+ @McpTool({
134
+ name: 'category.delete',
135
+ description: 'Deletes a category by ID.',
136
+ inputSchema: {
137
+ type: 'object',
138
+ properties: {
139
+ id: { type: 'number', description: 'Category ID' },
140
+ },
141
+ required: ['id'],
142
+ },
143
+ })
144
+ async delete(args: Record<string, any>, context: McpContext): Promise<any> {
145
+ return this.categoryService.delete(args.id, context.locale);
146
+ }
147
+ }