Skip to main content
Glama
marco-looy

Pega DX MCP Server

by marco-looy

get_case_attachments

Retrieve all attachments for a specific Pega case, including file details, URLs, creation information, and available actions. Supports optional thumbnail retrieval for image attachments.

Instructions

Get a comprehensive list of all attachments associated with a specific Pega case. Retrieves attachment metadata including file details, URLs, creation information, and available actions (download, edit, delete) for each attachment. Only attachments from categories selected in the Attachment Category rule are returned. Supports optional thumbnail retrieval for image attachments (gif, jpg, jpeg, png, and others) as base64 encoded strings.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
caseIDYesCase ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces.
includeThumbnailsNoWhether to include thumbnails as base64 strings. For images: gif, jpg, jpeg, png. Default: false
sessionCredentialsNoOptional 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

  • The main handler function 'execute' that performs parameter validation, initializes session, calls the Pega API via pegaClient.getCaseAttachments, handles errors, and formats the response.
    async execute(params) {
      const { caseID, includeThumbnails = false } = params;
    
      let sessionInfo = null;
      try {
        sessionInfo = this.initializeSessionConfig(params);
    
        // Basic parameter validation using base class
        const requiredValidation = this.validateRequiredParams(params, ['caseID']);
        if (requiredValidation) {
          return requiredValidation;
        }
    
        // Additional comprehensive parameter validation for complex logic
        const validationResult = this.validateParameters(caseID, includeThumbnails);
        if (!validationResult.valid) {
          return {
            error: validationResult.error
          };
        }
    
        // Execute with standardized error handling
        return await this.executeWithErrorHandling(
          `Case Attachments: ${caseID}`,
          async () => await this.pegaClient.getCaseAttachments(caseID, { includeThumbnails }),
          { caseID, includeThumbnails, sessionInfo }
        );
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `## Error: Case Attachments\n\n**Unexpected Error**: ${error.message}\n\n${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*`
          }]
        };
      }
    }
  • The tool schema definition including name, description, inputSchema with properties for caseID (required), includeThumbnails (optional), and sessionCredentials.
    static getDefinition() {
      return {
        name: 'get_case_attachments',
        description: 'Get a comprehensive list of all attachments associated with a specific Pega case. Retrieves attachment metadata including file details, URLs, creation information, and available actions (download, edit, delete) for each attachment. Only attachments from categories selected in the Attachment Category rule are returned. Supports optional thumbnail retrieval for image attachments (gif, jpg, jpeg, png, and others) as base64 encoded strings.',
        inputSchema: {
          type: 'object',
          properties: {
            caseID: {
              type: 'string',
              description: 'Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces.'
            },
            includeThumbnails: {
              type: 'boolean',
              description: 'Whether to include thumbnails as base64 strings. For images: gif, jpg, jpeg, png. Default: false',
              default: false
            },
            sessionCredentials: getSessionCredentialsSchema()
          },
          required: ['caseID']
        }
      };
    }
  • Custom overridden formatSuccessResponse method that generates a richly formatted Markdown response with attachment summaries, details, session info, and related tool suggestions.
    formatSuccessResponse(operation, data, options = {}) {
      const { caseID, includeThumbnails, sessionInfo } = options;
      const { attachments = [] } = data;
      
      let response = `## ${operation}\n\n`;
    
      response += `*Operation completed at: ${new Date().toISOString()}*\n\n`;
    
      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`;
      }
      
      if (attachments.length === 0) {
        response += `No attachments found for this case.\n\n`;
        response += `### â„šī¸ Note\n`;
        response += `- Only attachment categories selected in the Attachment Category rule are displayed\n`;
        response += `- Use \`add_case_attachments\` tool to add attachments to this case\n`;
        response += `- Use \`upload_attachment\` tool to prepare files for attachment\n`;
      } else {
        response += `Found **${attachments.length} ${attachments.length === 1 ? 'attachment' : 'attachments'}** associated with this case.\n\n`;
        
        // Group attachments by type for better organization
        const fileAttachments = attachments.filter(att => att.type === 'FILE');
        const urlAttachments = attachments.filter(att => att.type === 'URL');
        const emailAttachments = attachments.filter(att => att.type === 'EMAIL');
        const otherAttachments = attachments.filter(att => !['FILE', 'URL', 'EMAIL'].includes(att.type));
    
        response += `### 📎 Attachment Summary\n`;
        if (fileAttachments.length > 0) response += `- **Files**: ${fileAttachments.length}\n`;
        if (urlAttachments.length > 0) response += `- **URLs**: ${urlAttachments.length}\n`;
        if (emailAttachments.length > 0) response += `- **Emails**: ${emailAttachments.length}\n`;
        if (otherAttachments.length > 0) response += `- **Other**: ${otherAttachments.length}\n`;
        
        response += `\n### 📋 Detailed Attachment Information\n\n`;
    
        // Display each attachment with comprehensive details
        attachments.forEach((attachment, index) => {
          response += `#### ${index + 1}. ${attachment.name || 'Unnamed Attachment'}\n`;
          
          // Basic identification
          response += `- **ID**: \`${attachment.ID}\`\n`;
          response += `- **Type**: ${attachment.type} (${attachment.categoryName || attachment.category})\n`;
          
          // File-specific information
          if (attachment.fileName) {
            response += `- **File Name**: ${attachment.fileName}\n`;
          }
          if (attachment.extension) {
            response += `- **Extension**: .${attachment.extension}\n`;
          }
          if (attachment.mimeType) {
            response += `- **MIME Type**: ${attachment.mimeType}\n`;
          }
          
          // URL-specific information
          if (attachment.type === 'URL' && attachment.url) {
            response += `- **URL**: ${attachment.url}\n`;
          }
          
          // Creation information
          if (attachment.createdByName || attachment.createdBy) {
            response += `- **Created By**: ${attachment.createdByName || attachment.createdBy}\n`;
          }
          if (attachment.createTime) {
            const createDate = new Date(attachment.createTime);
            response += `- **Created**: ${createDate.toLocaleString()}\n`;
          }
          
          // Available actions from HATEOAS links
          if (attachment.links && Object.keys(attachment.links).length > 0) {
            const actions = Object.keys(attachment.links);
            response += `- **Available Actions**: ${actions.map(action => 
              action.charAt(0).toUpperCase() + action.slice(1)
            ).join(', ')}\n`;
          }
          
          // Thumbnail information
          if (includeThumbnails && attachment.thumbnail) {
            response += `- **Thumbnail**: ✅ Included (base64 encoded)\n`;
          } else if (includeThumbnails && attachment.type === 'FILE' && attachment.mimeType && 
                     attachment.mimeType.startsWith('image/')) {
            response += `- **Thumbnail**: ❌ Not available\n`;
          }
          
          response += `\n`;
        });
    
        // Display configuration information
        response += `### âš™ī¸ Configuration Details\n`;
        response += `- **Attachment Categories**: Only categories selected in Attachment Category rule are shown\n`;
        response += `- **Thumbnails**: ${includeThumbnails ? 'Enabled (base64 encoded)' : 'Disabled'}\n`;
        if (includeThumbnails) {
          const imageAttachments = attachments.filter(att => 
            att.mimeType && att.mimeType.startsWith('image/')
          );
          response += `- **Image Attachments**: ${imageAttachments.length} (eligible for thumbnails)\n`;
        }
      }
    
      // Display related operations
      response += `\n### 🔗 Related Operations\n`;
      response += `- Use \`add_case_attachments\` to add new attachments to this case\n`;
      response += `- Use \`upload_attachment\` to prepare files for attachment\n`;
      response += `- Use \`get_case\` to view complete case information\n`;
      if (attachments.length > 0) {
        response += `- Individual attachment operations (download, edit, delete) available via attachment links\n`;
      }
      
      return response;
    }
  • PegaClient wrapper method that proxies the getCaseAttachments API call to the underlying client. This is the direct API integration called from the tool handler.
    async getCaseAttachments(caseID, options = {}) {
      return this.client.getCaseAttachments(caseID, options);
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and does well by disclosing key behaviors: it returns only attachments from selected categories in the Attachment Category rule, supports optional thumbnail retrieval for specific image types as base64 strings, and describes the metadata included (file details, URLs, creation info, actions). It doesn't mention pagination, rate limits, or authentication requirements, but covers substantial operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in three sentences: first states core purpose, second details metadata and constraints, third covers thumbnail feature. Every sentence adds value without redundancy, and it's front-loaded with the main functionality. No wasted words or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read operation with 3 parameters (1 required), 100% schema coverage, and no output schema, the description is quite complete. It covers what the tool does, constraints (category filtering), optional features (thumbnails), and return content. Without annotations, it could mention authentication or rate limits, but given the context, it provides sufficient guidance for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds minimal parameter semantics beyond the schema: it clarifies that 'includeThumbnails' applies to 'image attachments (gif, jpg, jpeg, png, and others)' and mentions 'categories selected in the Attachment Category rule' which relates to caseID context. It doesn't significantly enhance parameter understanding beyond what the schema already documents.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'attachments associated with a specific Pega case', distinguishing it from sibling tools like 'get_attachment' (singular) and 'add_case_attachments'. It specifies it retrieves 'a comprehensive list of all attachments' with metadata details, making the purpose specific and differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: to get attachments for a specific case with optional thumbnail retrieval. It implicitly distinguishes from 'get_attachment' (singular) by focusing on lists, but doesn't explicitly state when to choose alternatives like 'get_attachment_categories' or mention exclusions (e.g., not for editing attachments).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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