Skip to main content
Glama
marco-looy

Pega DX MCP Server

by marco-looy

change_to_stage

Navigate a Pega case to any valid workflow stage using stageID, automatically fetching required eTag when omitted to ensure proper case progression.

Instructions

Change to a specified stage of a case based on stageID passed. Allows navigation to any valid stage (primary, alternate) within a case workflow. If no eTag is provided, automatically fetches the latest eTag from the case action for seamless operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
caseIDYesCase ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces.
stageIDYesStage ID to navigate to (Example: "PRIM1", "ALT1"). a valid stage identifier for the case type.
eTagNoOptional. Auto-fetched if omitted. For faster execution, use eTag from previous response.
viewTypeNoUI resources to return. "none" returns no UI resources (default), "form" returns form UI metadata in read-only review mode, "page" returns full page UI metadata in read-only review mode.none
cleanupProcessesNoWhether to clean up the processes, including assignments, of the stage being switched away from. Default is true. Set to false to opt out of this cleanup feature.
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

  • Main handler function for the 'change_to_stage' tool. Validates inputs, auto-fetches eTag if missing using getCaseAction, initializes session if provided, and executes the stage change via pegaClient.
    async execute(params) {
      console.log(`[DEBUG] change_to_stage execute called with params:`, JSON.stringify(params, null, 2));
      const { caseID, stageID, eTag, viewType, cleanupProcesses } = 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', 'stageID']);
      if (requiredValidation) {
        return requiredValidation;
      }
    
      // Validate enum parameters using base class
      const enumValidation = this.validateEnumParams(params, {
        viewType: ['none', 'form', 'page']
      });
      if (enumValidation) {
        return enumValidation;
      }
    
      // Auto-fetch eTag if not provided
      let finalETag = eTag;
      let autoFetchedETag = false;
      
      if (!finalETag) {
        console.log(`[DEBUG] Starting auto-fetch for case ${caseID}`);
        try {
          console.log(`Auto-fetching latest eTag for stage change on case ${caseID}...`);
          const caseActionResponse = await this.pegaClient.getCaseAction(caseID.trim(), 'pyChangeStage', {
            viewType: 'form',  // getCaseAction only accepts 'form' or 'page', not 'none'
            excludeAdditionalActions: true
          });
          
          console.log(`[DEBUG] getCaseAction response:`, JSON.stringify(caseActionResponse, null, 2));
          
          if (!caseActionResponse || !caseActionResponse.success) {
            const errorMsg = `Failed to auto-fetch eTag: ${caseActionResponse?.error?.message || 'Unknown error'}`;
            console.log(`[DEBUG] Auto-fetch failed: ${errorMsg}`);
            return {
              error: errorMsg
            };
          }
          
          finalETag = caseActionResponse.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_action. This may indicate a server issue.';
            console.log(`[DEBUG] ${errorMsg}`);
            return {
              error: errorMsg
            };
          }
        } catch (error) {
          const errorMsg = `Failed to auto-fetch eTag: ${error.message}`;
          console.log(`[DEBUG] Exception during auto-fetch: ${errorMsg}`);
          console.log(`[DEBUG] Stack trace:`, error.stack);
          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.'
        };
      }
    
        // Execute with standardized error handling
        return await this.executeWithErrorHandling(
          `Change to Stage: ${caseID} -> ${stageID}${autoFetchedETag ? ' (auto-fetched eTag)' : ''}`,
          async () => await this.pegaClient.changeToStage(caseID.trim(), stageID.trim(), finalETag.trim(), { viewType, cleanupProcesses }),
          { viewType, cleanupProcesses, autoFetchedETag, sessionInfo }
        );
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `## Error: Change to Stage\n\n**Unexpected Error**: ${error.message}\n\n${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*`
          }]
        };
      }
    }
  • Tool schema definition including name, description, and input schema specifying required caseID/stageID and optional parameters like eTag, viewType, sessionCredentials.
    static getDefinition() {
      return {
        name: 'change_to_stage',
        description: 'Change to a specified stage of a case based on stageID passed. Allows navigation to any valid stage (primary, alternate) within a case workflow. If no eTag is provided, automatically fetches the latest eTag from the case action for seamless operation.',
        inputSchema: {
          type: 'object',
          properties: {
            caseID: {
              type: 'string',
              description: 'Case ID. Example: "MYORG-APP-WORK C-1001". Complete identifier including spaces.'
            },
            stageID: {
              type: 'string',
              description: 'Stage ID to navigate to (Example: "PRIM1", "ALT1"). a valid stage identifier for the case type.'
            },
            eTag: {
              type: 'string',
              description: 'Optional. Auto-fetched if omitted. For faster execution, use eTag from previous response.'
            },
            viewType: {
              type: 'string',
              enum: ['none', 'form', 'page'],
              description: 'UI resources to return. "none" returns no UI resources (default), "form" returns form UI metadata in read-only review mode, "page" returns full page UI metadata in read-only review mode.',
              default: 'none'
            },
            cleanupProcesses: {
              type: 'boolean',
              description: 'Whether to clean up the processes, including assignments, of the stage being switched away from. Default is true. Set to false to opt out of this cleanup feature.',
              default: true
            },
            sessionCredentials: getSessionCredentialsSchema()
          },
          required: ['caseID', 'stageID']
        }
      };
    }
  • PegaClient wrapper method that delegates the changeToStage call to the appropriate V1/V2 client after feature availability check.
    async changeToStage(caseID, stageID, eTag, options = {}) {
      if (!this.isFeatureAvailable('stageNavigation')) {
        this.throwUnsupportedFeatureError('stageNavigation', 'changeToStage');
      }
      return this.client.changeToStage(caseID, stageID, eTag, options);
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes key behaviors: the eTag auto-fetch mechanism and the ability to navigate to any valid stage. However, it doesn't address important aspects like whether this is a mutation operation (implied by 'change'), potential side effects, error conditions, or what happens to case state during the transition. The cleanupProcesses parameter hints at side effects but isn't explained in the description.

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 two sentences that each add value. The first sentence states the core purpose, and the second adds important behavioral context about eTag handling. There's no wasted text, and information is front-loaded with the primary function stated first.

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

Completeness3/5

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

For a mutation tool with 6 parameters (including complex nested objects), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and one key behavioral aspect (eTag handling), but doesn't address mutation consequences, error handling, return values, or how it differs from similar sibling tools. Given the complexity and lack of structured metadata, more contextual information would be helpful.

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 parameter semantics beyond the schema - it mentions the eTag auto-fetch behavior and implies stageID can be 'primary' or 'alternate' types, but doesn't provide additional context about parameter interactions or usage patterns that aren't already in the schema descriptions.

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: 'Change to a specified stage of a case based on stageID passed.' It specifies the verb ('change to') and resource ('stage of a case'), but doesn't explicitly differentiate from sibling tools like 'change_to_next_stage' or 'jump_to_step' beyond mentioning 'allows navigation to any valid stage.'

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'allows navigation to any valid stage (primary, alternate) within a case workflow,' but doesn't provide explicit guidance on when to use this tool versus alternatives like 'change_to_next_stage' or 'jump_to_step.' It offers some operational guidance with the eTag auto-fetch behavior, but lacks clear when/when-not directives.

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