add_case_tags
Add multiple tags to a Pega case to organize, categorize, and improve case management workflows by applying structured labels.
Instructions
Add multiple tags to a case
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| caseID | Yes | Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces."OSIEO3-DOCSAPP-WORK T-561003". a complete case identifier including spaces and special characters. | |
| tags | Yes | Array of tag objects to add to the case. Each tag object must contain a Name property. | |
| sessionCredentials | No | Optional session-specific credentials. If not provided, uses environment variables. Supports two authentication modes: (1) OAuth mode - provide baseUrl, clientId, and clientSecret, or (2) Token mode - provide baseUrl and accessToken. |
Implementation Reference
- src/tools/tags/add-case-tags.js:53-97 (handler)The main handler function that validates input parameters (caseID and tags array), initializes the Pega session, and executes the addCaseTags API call via pegaClient with standardized error handling.
async execute(params) { const { caseID, tags } = params; let sessionInfo = null; try { sessionInfo = this.initializeSessionConfig(params); // Validate required parameters using base class const requiredValidation = this.validateRequiredParams(params, ['caseID', 'tags']); if (requiredValidation) { return requiredValidation; } // Additional validation for tags array if (!Array.isArray(tags) || tags.length === 0) { return { error: 'Invalid tags parameter. tags must be a non-empty array of tag objects.' }; } // Validate each tag object has required Name property for (let i = 0; i < tags.length; i++) { const tag = tags[i]; if (!tag || typeof tag !== 'object' || !tag.Name || typeof tag.Name !== 'string' || tag.Name.trim() === '') { return { error: `Invalid tag at index ${i}. Each tag must be an object with a non-empty Name property.` }; } } // Execute with standardized error handling return await this.executeWithErrorHandling( `Add Tags to Case: ${caseID}`, async () => await this.pegaClient.addCaseTags(caseID.trim(), tags), { sessionInfo } ); } catch (error) { return { content: [{ type: 'text', text: `## Error: Add Tags to Case: ${caseID}\n\n**Unexpected Error**: ${error.message}\n\n${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*` }] }; } } - Defines the tool schema including name 'add_case_tags', description, and input validation schema requiring caseID (string) and tags (array of objects with Name, 1-50 items).
static getDefinition() { return { name: 'add_case_tags', description: 'Add multiple tags to a case', inputSchema: { type: 'object', properties: { caseID: { type: 'string', description: 'Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces."OSIEO3-DOCSAPP-WORK T-561003". a complete case identifier including spaces and special characters.' }, tags: { type: 'array', description: 'Array of tag objects to add to the case. Each tag object must contain a Name property.', items: { type: 'object', properties: { Name: { type: 'string', description: 'Name of the tag to add to the case' } }, required: ['Name'], additionalProperties: false }, minItems: 1, maxItems: 50 }, sessionCredentials: getSessionCredentialsSchema() }, required: ['caseID', 'tags'] } }; }