Skip to main content
Glama
marco-looy

Pega DX MCP Server

by marco-looy

get_case_view_calculated_fields

Retrieve calculated field values from a specific case view in Pega, evaluating only requested fields that exist within that view.

Instructions

Get calculated fields for a given case view. Retrieves only the requested calculated fields from the case view. All requested calculated fields in the request body must be included in the view. Any requested fields that are not part of the view will be filtered out.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
caseIDYesCase ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces."MYORG-SERVICES-WORK S-293001". a complete case identifier including spaces and special characters.
viewIDYesName of the view from which calculated fields are retrieved - ID of the view rule. This identifies the specific view containing the calculated fields to be evaluated.
calculationsYesObject containing the fields data to retrieve their respective calculated values. Must contain a "fields" array with field objects.
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 that performs parameter validation, session handling, and calls the Pega client to retrieve calculated fields for a case view.
    async execute(params) {
      const { caseID, viewID, calculations } = 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', 'viewID', 'calculations']);
        if (requiredValidation) {
          return requiredValidation;
        }
    
      // Additional validation for calculations structure
      if (!calculations || typeof calculations !== 'object' || Array.isArray(calculations)) {
        return {
          error: 'Invalid calculations parameter. an object containing field specifications.'
        };
      }
    
      if (!calculations.fields || !Array.isArray(calculations.fields) || calculations.fields.length === 0) {
        return {
          error: 'Invalid calculations.fields parameter. a non-empty array of field objects.'
        };
      }
    
      // Validate each field object
      for (let i = 0; i < calculations.fields.length; i++) {
        const field = calculations.fields[i];
        
        if (!field || typeof field !== 'object' || Array.isArray(field)) {
          return {
            error: `Invalid field object at index ${i}. an object with required 'name' property.`
          };
        }
    
        if (!field.name || typeof field.name !== 'string' || field.name.trim() === '') {
          return {
            error: `Invalid field name at index ${i}. a non-empty string.`
          };
        }
    
        if (field.context !== undefined && (typeof field.context !== 'string' || field.context.trim() === '')) {
          return {
            error: `Invalid field context at index ${i}. When provided, must be a non-empty string.`
          };
        }
      }
    
      // Validate whens array if provided
      if (calculations.whens !== undefined) {
        if (!Array.isArray(calculations.whens)) {
          return {
            error: 'Invalid calculations.whens parameter. an array of when condition objects.'
          };
        }
    
        for (let i = 0; i < calculations.whens.length; i++) {
          const when = calculations.whens[i];
          
          if (!when || typeof when !== 'object' || Array.isArray(when)) {
            return {
              error: `Invalid when object at index ${i}. an object with required 'name' property.`
            };
          }
    
          if (!when.name || typeof when.name !== 'string' || when.name.trim() === '') {
            return {
              error: `Invalid when name at index ${i}. a non-empty string.`
            };
          }
    
          if (when.context !== undefined && (typeof when.context !== 'string' || when.context.trim() === '')) {
            return {
              error: `Invalid when context at index ${i}. When provided, must be a non-empty string.`
            };
          }
        }
      }
    
        // Execute with standardized error handling
        return await this.executeWithErrorHandling(
          `Case View Calculated Fields: ${viewID} for ${caseID}`,
          async () => await this.pegaClient.getCaseViewCalculatedFields(
            caseID.trim(),
            viewID.trim(),
            calculations
          ),
          { caseID, viewID, calculations, sessionInfo }
        );
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `## Error: Get Case View Calculated Fields\n\n**Unexpected Error**: ${error.message}\n\n${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*`
          }]
        };
      }
    }
  • Static method defining the tool's name, description, and detailed input schema for MCP protocol compliance.
    static getDefinition() {
      return {
        name: 'get_case_view_calculated_fields',
        description: 'Get calculated fields for a given case view. Retrieves only the requested calculated fields from the case view. All requested calculated fields in the request body must be included in the view. Any requested fields that are not part of the view will be filtered out.',
        inputSchema: {
          type: 'object',
          properties: {
            caseID: {
              type: 'string',
              description: 'Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces."MYORG-SERVICES-WORK S-293001". a complete case identifier including spaces and special characters.'
            },
            viewID: {
              type: 'string',
              description: 'Name of the view from which calculated fields are retrieved - ID of the view rule. This identifies the specific view containing the calculated fields to be evaluated.'
            },
            calculations: {
              type: 'object',
              description: 'Object containing the fields data to retrieve their respective calculated values. Must contain a "fields" array with field objects.',
              properties: {
                fields: {
                  type: 'array',
                  description: 'Array of field objects specifying which calculated fields to retrieve from the view.',
                  items: {
                    type: 'object',
                    properties: {
                      name: {
                        type: 'string',
                        description: 'Name of the calculated field to retrieve. Can include property references starting with dot notation (Example: ".LoanEligibilityCheckListCountAll").'
                      },
                      context: {
                        type: 'string',
                        description: 'Context for the calculated field evaluation. Optional parameter that specifies the context in which the field should be evaluated. Default: "content".',
                        default: 'content'
                      }
                    },
                    required: ['name'],
                    additionalProperties: false
                  },
                  minItems: 1
                },
                whens: {
                  type: 'array',
                  description: 'Array of when condition objects for conditional field evaluation. Optional parameter for advanced field calculation scenarios.',
                  items: {
                    type: 'object',
                    properties: {
                      name: {
                        type: 'string',
                        description: 'Name of the when condition.'
                      },
                      context: {
                        type: 'string',
                        description: 'Context for the when condition evaluation.'
                      }
                    },
                    required: ['name'],
                    additionalProperties: false
                  }
                }
              },
              required: ['fields'],
              additionalProperties: false
            },
            sessionCredentials: getSessionCredentialsSchema()
          },
          required: ['caseID', 'viewID', 'calculations']
        }
      };
  • PegaClient router method that checks API version compatibility and delegates the calculated fields request to the appropriate V1/V2 client implementation.
    async getCaseViewCalculatedFields(caseID, viewID, calculations) {
      if (!this.isFeatureAvailable('uiMetadata')) {
        this.throwUnsupportedFeatureError('uiMetadata', 'getCaseViewCalculatedFields');
      }
      return this.client.getCaseViewCalculatedFields(caseID, viewID, calculations);
    }
  • Dynamic registration logic in ToolLoader that instantiates the tool class and registers it by name in the loaded tools map during directory scanning.
      const toolInstance = new ToolClass();
      const toolName = ToolClass.getDefinition().name;
      
      this.loadedTools.set(toolName, {
        instance: toolInstance,
        class: ToolClass,
        category: category,
        filename: filename
      });
      
      return toolInstance;
    } catch (error) {
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions filtering behavior for non-existent fields, which is useful, but fails to describe critical aspects: whether this is a read-only operation, what authentication is required (though hinted in parameters), what happens with invalid inputs, rate limits, or what the return format looks like. For a tool with complex nested parameters and no annotations, this leaves significant gaps.

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

Conciseness4/5

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

The description is appropriately concise with three sentences that each add value: stating the purpose, specifying retrieval scope, and describing filtering behavior. It's front-loaded with the core purpose and avoids unnecessary repetition. The only minor improvement would be combining the last two sentences for better flow.

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

Completeness2/5

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

Given the tool's complexity (4 parameters with nested objects), lack of annotations, and absence of an output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, authentication requirements (beyond parameter hints), or how it differs from similar case view operations. For a tool that retrieves calculated data with conditional logic, more behavioral context is needed.

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 schema already documents all parameters thoroughly. The description adds minimal value beyond the schema - it mentions that requested fields must be in the view and others are filtered, which relates to the 'calculations' parameter behavior but doesn't provide additional syntax or format details. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get calculated fields for a given case view.' It specifies the verb ('Get') and resource ('calculated fields'), and distinguishes it from generic case retrieval tools. However, it doesn't explicitly differentiate from sibling tools like 'get_case_view' or 'recalculate_case_action_fields', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides some implicit usage context by stating that requested fields must be included in the view and others will be filtered out, but it offers no explicit guidance on when to use this tool versus alternatives like 'get_case_view' or 'recalculate_case_action_fields'. There's no mention of prerequisites, performance considerations, or typical scenarios for this specific operation.

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