Skip to main content
Glama
marco-looy
by marco-looy
delete-participant.js4.28 kB
import { BaseTool } from '../../registry/base-tool.js'; import { getSessionCredentialsSchema } from '../../utils/tool-schema.js'; export class DeleteParticipantTool extends BaseTool { /** * Get the category this tool belongs to */ static getCategory() { return 'participants'; } /** * Get tool definition for MCP protocol */ static getDefinition() { return { name: 'delete_participant', description: 'Delete a participant from a Pega case by case ID and participant ID. If no eTag is provided, automatically fetches the latest eTag from the case for seamless operation. Requires an eTag value for optimistic locking to ensure data consistency. Returns success confirmation or detailed error information.', inputSchema: { type: 'object', properties: { caseID: { type: 'string', description: 'Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces."ON6E5R-DIYRecipe-Work-RecipeCollection R-1008". a complete case identifier including spaces and special characters.' }, participantID: { type: 'string', description: 'Participant ID to remove from the case. This identifies the specific participant that will be deleted from the case participant list.' }, eTag: { type: 'string', description: 'eTag for optimistic locking. If not provided, automatically fetches latest eTag. Represents case pxSaveDateTime.' }, sessionCredentials: getSessionCredentialsSchema() }, required: ['caseID', 'participantID'] } }; } /** * Execute the delete participant operation */ async execute(params) { const { caseID, participantID, eTag } = params; let sessionInfo = null; try { sessionInfo = this.initializeSessionConfig(params); // Validate required parameters using base class const requiredValidation = this.validateRequiredParams(params, ['caseID', 'participantID']); if (requiredValidation) { return requiredValidation; } // Execute with standardized error handling // Auto-fetch eTag if not provided let finalETag = eTag; let autoFetchedETag = false; if (!finalETag) { try { console.log(`Auto-fetching latest eTag for participant operation on ${caseID}...`); const caseResponse = await this.pegaClient.getCase(caseID.trim()); if (!caseResponse || !caseResponse.success) { const errorMsg = `Failed to auto-fetch eTag: ${caseResponse?.error?.message || 'Unknown error'}`; return { error: errorMsg }; } finalETag = caseResponse.eTag; autoFetchedETag = true; console.log(`Successfully auto-fetched eTag: ${finalETag}`); if (!finalETag) { const errorMsg = 'Auto-fetch succeeded but no eTag was returned from get_case. This may indicate a server issue.'; return { error: errorMsg }; } } catch (error) { const errorMsg = `Failed to auto-fetch eTag: ${error.message}`; return { error: errorMsg }; } } // Validate eTag format (should be a timestamp-like string) if (typeof finalETag !== 'string' || finalETag.trim().length === 0) { return { error: 'Invalid eTag parameter. a non-empty string representing case save date time.' }; } return await this.executeWithErrorHandling( `Delete Participant: ${caseID.trim()} / ${participantID.trim()}`, async () => await this.pegaClient.deleteParticipant(caseID.trim(), participantID.trim(), finalETag.trim()), { caseID: caseID.trim(), participantID: participantID.trim(), eTag: '***', sessionInfo } // Hide eTag in logs for security ); } catch (error) { return { content: [{ type: 'text', text: `## Error: Delete Participant: ${caseID} / ${participantID}\n\n**Unexpected Error**: ${error.message}\n\n${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*` }] }; } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marco-looy/pega-dx-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server