Skip to main content
Glama
marco-looy

Pega DX MCP Server

by marco-looy

create_case

Create new Pega cases to initiate workflows, generating initial assignments and supporting optional field values or embedded page configurations.

Instructions

Create a new Pega case. This is the FIRST step in case workflows. Automatically creates the initial assignment (returned in nextAssignmentInfo). Many case types accept empty content {}. If fields required, automatic field discovery provides guidance. Returns: caseID, assignmentID (in nextAssignmentInfo.ID), eTag. Next steps: use get_assignment with assignmentID to view form fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
caseTypeIDYesCase type ID (Example: "Org-App-Work-CaseType"). Use get_case_types to discover available types.
parentCaseIDNoParent case ID for child case creation
processIDNoStarting process ID to use for case creation (Example: "pyStartCase"). Optional parameter that specifies which flow to use when creating the case. Some case types may require this to bypass initial validation.
contentNoField values for case creation (optional). Empty {} often works. If fields required, automatic discovery provides guidance. For embedded pages use pageInstructions.
pageInstructionsNoOptional list of page-related operations for embedded pages, page lists, or page groups. Required for setting embedded page references (Example: Collection, Datasource). See Pega DX API documentation on page instructions for embedded pages.
attachmentsNoA list of attachments to be added to specific attachment fields (optional)
viewTypeNoUI resources to return. "none" returns no UI resources, "form" returns form UI metadata, "page" returns full page UI metadatanone
pageNameNoIf provided, view metadata for specific page name will be returned (only used when viewType is "page")
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 that executes the create_case tool. Handles input validation, session management, proactive field discovery with empty content, error handling, and calls pegaClient.createCase. Includes smart field discovery and guidance for missing fields.
      async execute(params) {
        const { caseTypeID, parentCaseID, processID, content, pageInstructions, attachments, viewType, pageName } = 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, ['caseTypeID']);
        if (requiredValidation) {
          return requiredValidation;
        }
    
        // Validate enum parameters using base class
        const enumValidation = this.validateEnumParams(params, {
          viewType: ['none', 'form', 'page']
        });
        if (enumValidation) {
          return enumValidation;
        }
    
        // Validate pageName usage
        if (pageName && viewType !== 'page') {
          return {
            error: 'pageName parameter can only be used when viewType is set to "page".'
          };
        }
    
        // Validate parentCaseID format if provided
        if (parentCaseID && (typeof parentCaseID !== 'string' || parentCaseID.trim() === '')) {
          return {
            error: 'Invalid parentCaseID parameter. Parent case ID must be a non-empty string if provided.'
          };
        }
    
        // PROACTIVE: Auto-discover when no content provided
        // Try creation with empty content first for both V1 and V2 (many case types accept empty content)
        if (!content || Object.keys(content).length === 0) {
          const apiVersion = this.pegaClient.getApiVersion();
    
          // Try creation with empty content first (works for many case types)
          const emptyResult = await this.executeWithErrorHandling(
            `Case Creation: ${caseTypeID}`,
            async () => await this.pegaClient.createCase({
              caseTypeID: caseTypeID.trim(),
              parentCaseID: parentCaseID?.trim(),
              processID: processID?.trim(),
              content: {},
              pageInstructions,
              attachments,
              viewType,
              pageName
            }),
            { caseTypeID, viewType, pageName, sessionInfo }
          );
    
          // If empty content worked, return success
          if (emptyResult.content && emptyResult.content[0].text.includes('✅')) {
            return emptyResult;
          }
    
          // If it failed, provide version-specific guidance
          if (apiVersion === 'v1') {
            // V1: Field discovery not supported, provide manual guidance
            return {
              content: [{
                type: 'text',
                text: `## V1 Case Creation Failed
    
    ${emptyResult.content?.[0]?.text || 'Case creation with empty content failed.'}
    
    **Note**: Traditional DX API (V1) does not support automatic field discovery.
    
    ### To create a case with V1 API:
    
    Provide the content object with your case fields directly:
    
    \`\`\`json
    {
      "caseTypeID": "${caseTypeID}",
      "content": {
        "YourField1": "value1",
        "YourField2": "value2"
      }
    }
    \`\`\`
    
    **Tip**: Consult your Pega application's case type configuration to determine which fields are required.`
              }]
            };
          }
    
          // V2: Check if error is truly field-related before doing field discovery
          if (this.isFieldRelatedErrorInResult(emptyResult)) {
            return await this.discoverFieldsAndGuide(caseTypeID, { message: this.extractErrorMessage(emptyResult) });
          }
    
          // Not field-related, return the actual error
          return emptyResult;
        }
    
        // NORMAL: Try creation with provided content
        const result = await this.executeWithErrorHandling(
          `Case Creation: ${caseTypeID}`,
          async () => await this.pegaClient.createCase({
            caseTypeID: caseTypeID.trim(),
            parentCaseID: parentCaseID?.trim(),
            processID: processID?.trim(),
            content,
            pageInstructions,
            attachments,
            viewType,
            pageName
          }),
          { caseTypeID, viewType, pageName, sessionInfo }
        );
    
          // REACTIVE: If the result contains a field-related error, auto-discover and guide
          if (this.isFieldRelatedErrorInResult(result)) {
            return await this.discoverFieldsAndGuide(caseTypeID, { message: this.extractErrorMessage(result) }, content);
          }
    
          return result;
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `## Error: Create Case
    
    **Unexpected Error**: ${error.message}
    
    ${sessionInfo ? `**Session**: ${sessionInfo.sessionId} (${sessionInfo.authMode} mode)\n` : ''}*Error occurred at: ${new Date().toISOString()}*`
            }]
          };
        }
      }
  • Static method providing the tool definition for MCP protocol, including name 'create_case', detailed description, and comprehensive inputSchema defining parameters like caseTypeID, content, pageInstructions, attachments, etc.
    static getDefinition() {
      return {
        name: 'create_case',
        description: 'Create a new Pega case. This is the FIRST step in case workflows. Automatically creates the initial assignment (returned in nextAssignmentInfo). Many case types accept empty content {}. If fields required, automatic field discovery provides guidance. Returns: caseID, assignmentID (in nextAssignmentInfo.ID), eTag. Next steps: use get_assignment with assignmentID to view form fields.',
        inputSchema: {
          type: 'object',
          properties: {
            caseTypeID: {
              type: 'string',
              description: 'Case type ID (Example: "Org-App-Work-CaseType"). Use get_case_types to discover available types.'
            },
            parentCaseID: {
              type: 'string',
              description: 'Parent case ID for child case creation'
            },
            processID: {
              type: 'string',
              description: 'Starting process ID to use for case creation (Example: "pyStartCase"). Optional parameter that specifies which flow to use when creating the case. Some case types may require this to bypass initial validation.'
            },
            content: {
              type: 'object',
              description: 'Field values for case creation (optional). Empty {} often works. If fields required, automatic discovery provides guidance. For embedded pages use pageInstructions.'
            },
            pageInstructions: {
              type: 'array',
              items: {
                type: 'object',
                properties: {
                  instruction: {
                    type: 'string',
                    enum: ['UPDATE', 'REPLACE', 'DELETE', 'APPEND', 'INSERT', 'MOVE'],
                    description: 'Page instruction type. UPDATE (add fields to page), REPLACE (replace entire page), DELETE (remove page), APPEND (add item to page list), INSERT (insert item in page list), MOVE (reorder page list items)'
                  },
                  target: {
                    type: 'string',
                    description: 'Target embedded page name (Example: "Collection", "Datasource")'
                  },
                  content: {
                    type: 'object',
                    description: 'Content to set on the embedded page (required for UPDATE and REPLACE)'
                  }
                },
                required: ['instruction', 'target'],
                description: 'Page operation for embedded pages. IMPORTANT: Use REPLACE instruction to set embedded page references like Collection or Datasource with full object including pzInsKey. Example: {"instruction": "REPLACE", "target": "Collection", "content": {"CollectionName": "knowledge", "pyID": "DC-1", "pzInsKey": "PEGAFW-QNA-WORK DC-1"}}'
              },
              description: 'Optional list of page-related operations for embedded pages, page lists, or page groups. Required for setting embedded page references (Example: Collection, Datasource). See Pega DX API documentation on page instructions for embedded pages.'
            },
            attachments: {
              type: 'array',
              items: {
                type: 'object',
                properties: {
                  fileName: {
                    type: 'string',
                    description: 'Name of the attachment file'
                  },
                  fileContent: {
                    type: 'string',
                    description: 'Base64 encoded file content'
                  },
                  mimeType: {
                    type: 'string',
                    description: 'MIME type of the attachment'
                  }
                },
                description: 'Attachment object with file details and metadata'
              },
              description: 'A list of attachments to be added to specific attachment fields (optional)'
            },
            viewType: {
              type: 'string',
              enum: ['none', 'form', 'page'],
              description: 'UI resources to return. "none" returns no UI resources, "form" returns form UI metadata, "page" returns full page UI metadata',
              default: 'none'
            },
            pageName: {
              type: 'string',
              description: 'If provided, view metadata for specific page name will be returned (only used when viewType is "page")'
            },
            sessionCredentials: getSessionCredentialsSchema()
          },
          required: ['caseTypeID']
        }
      };
    }
  • Static getCategory() method returning 'cases', used by the dynamic tool loader (src/registry/tool-loader.js) to categorize and auto-register this tool during discovery.
    static getCategory() {
      return 'cases';
    }
  • Helper method for proactive field discovery using Case Type Action 'Create'. Extracts relevant fields from UI resources, groups by required/optional, and generates guidance for users when case creation fails due to missing fields.
    async discoverFieldsAndGuide(caseTypeID, originalError = null, attemptedContent = null) {
      try {
        // Use Case Type Action "Create" to get accurate creation form fields
        // This returns ~28 fields instead of 500+ from Data Views
        const actionResponse = await this.pegaClient.getCaseTypeAction(caseTypeID, 'Create');
    
        if (!actionResponse.success) {
          throw new Error(`Failed to retrieve case type action: ${actionResponse.error?.message || 'Unknown error'}`);
        }
    
        // Extract fields from UI resources
        const processedFields = this.processCaseTypeActionFields(actionResponse.data);
    
        // Format and return field discovery guidance
        return {
          content: [
            {
              type: "text",
              text: this.formatFieldDiscoveryGuidanceFromCaseTypeAction(caseTypeID, processedFields, originalError, attemptedContent)
            }
          ]
        };
      } catch (discoveryError) {
        // If field discovery fails, return a helpful fallback message
        let errorMessage = `Unable to discover fields for case type "${caseTypeID}".`;
    
        if (originalError) {
          errorMessage += `\n\nOriginal creation error: ${originalError.message}`;
        }
    
        errorMessage += `\n\nField discovery error: ${discoveryError.message}`;
        errorMessage += `\n\nPlease verify the case type ID is correct and accessible.`;
    
        return {
          error: errorMessage
        };
      }
    }
  • Underlying API method pegaClient.createCase(options) called by the tool handler to perform the actual case creation via Pega DX API. Handles both V1 and V2 API versions transparently.
    async createCase(options) {
      return this.client.createCase(options);
    }
    
    /**
     * Get case by ID
     * @param {string} caseID - Case ID
     * @param {Object} options - Optional parameters
     * @returns {Promise<Object>} Case details
     */
    async getCase(caseID, options = {}) {
      return this.client.getCase(caseID, options);
    }
    
    /**
     * Update case
     * V1 EXCLUSIVE - Use case actions in V2
     * @param {string} caseID - Case ID
     * @param {Object} content - Updated content
     * @returns {Promise<Object>} Updated case details
     */
    async updateCase(caseID, content) {
      if (!this.isFeatureAvailable('updateCase')) {
        this.throwUnsupportedFeatureError('updateCase', 'updateCase');
      }
      return this.client.updateCase(caseID, content);
    }
    
    /**
     * Delete case (only works for cases in create stage)
     * @param {string} caseID - Case ID
     * @returns {Promise<Object>} Deletion result
     */
    async deleteCase(caseID) {
      return this.client.deleteCase(caseID);
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: it discloses that the tool 'Automatically creates the initial assignment' and returns specific fields (caseID, assignmentID, eTag). It mentions that 'Many case types accept empty content {}' and provides guidance on field requirements. However, it lacks details on error handling or rate limits.

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 sized and front-loaded with key information (purpose and automatic assignment creation). Every sentence adds value, such as explaining return values and next steps. It could be slightly more concise by integrating some details, but overall it's well-structured.

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?

Given the complexity (9 parameters, nested objects) and no output schema, the description does a good job by explaining return values (caseID, assignmentID, eTag) and next steps. It covers key behavioral aspects like automatic assignment creation and content flexibility. However, it could benefit from more details on error cases or authentication requirements.

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 some context by noting 'Many case types accept empty content {}' and 'If fields required, automatic field discovery provides guidance' for the 'content' parameter, but doesn't provide significant additional meaning beyond the schema's detailed descriptions for each parameter.

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 specific action ('Create a new Pega case') and distinguishes it from siblings by emphasizing it's the 'FIRST step in case workflows' and automatically creates the initial assignment. It differentiates from tools like 'update_case' or 'get_case' by focusing on creation.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'This is the FIRST step in case workflows' tells when to use it, and 'Next steps: use get_assignment with assignmentID to view form fields' suggests alternatives for subsequent actions. It also implies when not to use it (e.g., for updates or queries).

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