Skip to content

Commit 2d0747a

Browse files
committed
refactor: added null checks before iterating arrays
1 parent f78a3c3 commit 2d0747a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

.claude/skills/src/mcp-tools.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,21 @@ export function createToolDefinition(skill: QsvSkill): McpToolDefinition {
294294
const required: string[] = ['input_file'];
295295

296296
// Add positional arguments
297-
for (const arg of skill.command.args) {
298-
properties[arg.name] = {
299-
type: mapArgumentType(arg.type),
300-
description: arg.description,
301-
};
302-
if (arg.required) {
303-
required.push(arg.name);
297+
if (skill.command.args && Array.isArray(skill.command.args)) {
298+
for (const arg of skill.command.args) {
299+
properties[arg.name] = {
300+
type: mapArgumentType(arg.type),
301+
description: arg.description,
302+
};
303+
if (arg.required) {
304+
required.push(arg.name);
305+
}
304306
}
305307
}
306308

307309
// Add options
308-
for (const opt of skill.command.options) {
310+
if (skill.command.options && Array.isArray(skill.command.options)) {
311+
for (const opt of skill.command.options) {
309312
const optName = opt.flag.replace(/^--/, '').replace(/-/g, '_');
310313

311314
if (opt.type === 'flag') {
@@ -322,6 +325,7 @@ export function createToolDefinition(skill: QsvSkill): McpToolDefinition {
322325
properties[optName].default = opt.default;
323326
}
324327
}
328+
}
325329
}
326330

327331
// Add output_file (optional for all commands)

0 commit comments

Comments
 (0)