Skip to content

Commit 5251c59

Browse files
ndbroadbentclaude
andcommitted
feat: MCP server error handling for missing binary
Added comprehensive error handling for when renamify CLI binary is missing: - Detects ENOENT errors and provides helpful installation instructions - Includes curl install command and documentation link - Added tests for both executeCommand and preview error scenarios - Distinguishes between missing binary vs missing plan file errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 00bbcd1 commit 5251c59

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

renamify-mcp/src/renamify-service.error.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ describe('RenamifyService Error Handling', () => {
3232
service.plan({ search: 'old', replace: 'new' })
3333
).rejects.toThrow(
3434
'Renamify CLI not found. Please install it using:\n\n' +
35-
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
36-
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
35+
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
36+
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
3737
);
3838
});
3939

@@ -96,8 +96,8 @@ describe('RenamifyService Error Handling', () => {
9696

9797
await expect(service.preview({})).rejects.toThrow(
9898
'Renamify CLI not found. Please install it using:\n\n' +
99-
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
100-
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
99+
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
100+
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
101101
);
102102
});
103103

renamify-mcp/src/renamify-service.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,15 @@ export class RenamifyService {
169169
return result.stdout;
170170
} catch (error) {
171171
// Check if the binary is missing (ENOENT error)
172-
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
172+
if (
173+
error instanceof Error &&
174+
'code' in error &&
175+
error.code === 'ENOENT'
176+
) {
173177
throw new Error(
174178
'Renamify CLI not found. Please install it using:\n\n' +
175-
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
176-
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
179+
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
180+
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
177181
);
178182
}
179183

@@ -308,13 +312,12 @@ export class RenamifyService {
308312
// This is an execa error - binary not found
309313
throw new Error(
310314
'Renamify CLI not found. Please install it using:\n\n' +
311-
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
312-
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
315+
'curl -fsSL https://docspring.github.io/renamify/install.sh | bash\n\n' +
316+
'For more installation options, visit: https://docspring.github.io/renamify/installation/'
313317
);
314-
} else {
315-
// This is a file access error - plan file not found
316-
throw new Error(`Plan file not found: ${planPath}`);
317318
}
319+
// This is a file access error - plan file not found
320+
throw new Error(`Plan file not found: ${planPath}`);
318321
}
319322
if ('stderr' in error) {
320323
const execaError = error as ExecaError;

0 commit comments

Comments
 (0)