import { BaseTool } from '../../registry/base-tool.js';
import { getSessionCredentialsSchema } from '../../utils/tool-schema.js';
export class DeleteCaseTool extends BaseTool {
/**
* Get the category this tool belongs to
*/
static getCategory() {
return 'cases';
}
/**
* Get tool definition for MCP protocol
*/
static getDefinition() {
return {
name: 'delete_case',
description: 'Delete a case that is currently in the create stage',
inputSchema: {
type: 'object',
properties: {
caseID: {
type: 'string',
description: 'Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces.'
},
sessionCredentials: getSessionCredentialsSchema()
},
required: ['caseID']
}
};
}
/**
* Execute the delete case operation
*/
async execute(params) {
const { caseID } = params;
let sessionInfo = null;
try {
// Initialize session configuration if provided
sessionInfo = this.initializeSessionConfig(params);
// Validate required parameters using base class
const requiredValidation = this.validateRequiredParams(params, ['caseID']);
if (requiredValidation) {
return requiredValidation;
}
// Execute with standardized error handling
return await this.executeWithErrorHandling(
`Case Deletion: ${caseID}`,
async () => await this.pegaClient.deleteCase(caseID.trim()),
{ caseID, sessionInfo }
);
} catch (error) {
return {
content: [{
type: 'text',
text: `## Error: Delete Case
**Unexpected Error**: ${error.message}
${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*`
}]
};
}
}
/**
* Override formatSuccessResponse to add case deletion specific formatting
*/
formatSuccessResponse(operation, data, options = {}) {
const { caseID, sessionInfo } = options;
let response = `## ${operation}\n\n`;
response += `*Operation completed at: ${new Date().toISOString()}*\n\n`;
// Session Information (if applicable)
if (sessionInfo) {
response += `### Session Information\n`;
response += `- **Session ID**: ${sessionInfo.sessionId}\n`;
response += `- **Authentication Mode**: ${sessionInfo.authMode.toUpperCase()}\n`;
response += `- **Configuration Source**: ${sessionInfo.configSource}\n\n`;
}
response += `✅ **Case ID**: ${caseID}\n\n`;
response += '### Operation Details\n';
response += '- The case has been permanently removed from the system\n';
response += '- This action cannot be undone\n';
response += '- Only cases in the create stage can be deleted\n\n';
return response;
}
}