Skip to main content
Glama
Hive-Academy

π“‚€π“’π“‹Ήπ”Έβ„•π•Œπ”Ήπ•€π•Šπ“‹Ήπ“’π“‚€ - Intelligent Guidance for

by Hive-Academy

workflow_execution_operations

Manages workflow execution by creating, querying, updating, and completing workflows with validated parameters. Tracks context and progress to ensure efficient workflow orchestration and state management.

Instructions

Manages workflow execution state through strongly-typed operations for creating, querying, updating, and completing workflow executions. Handles execution context and progress tracking with validated parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
autoCreatedTaskNoWhether task was auto-created
contextUpdatesNoContext updates to merge with existing execution context
dataKeyNoSpecific data key to retrieve from context
executionContextNoAdditional execution context
executionIdNoExecution ID for operations requiring it
executionModeNoExecution mode
operationYesOperation to execute
orchestrationConfigNoConfiguration for orchestrating multiple service calls
roleNameNoRole name for execution
stepIdNoCurrent step ID
taskIdNoTask ID (optional for bootstrap executions)
updateDataNoFields that can be updated in WorkflowExecution

Implementation Reference

  • Tool registration via @Tool decorator with name 'workflow_execution_operations' and the entry point handler function.
    @Tool({
      name: 'workflow_execution_operations',
      description: `Manages workflow execution state through strongly-typed operations for creating, querying, updating, and completing workflow executions. Handles execution context and progress tracking with validated parameters.`,
      parameters: WorkflowExecutionSchema,
    })
  • Handler logic that parses input.operation and delegates to corresponding methods in WorkflowExecutionOperationsService.
      async executeWorkflowOperation(
        input: WorkflowExecutionInputSchema,
      ): Promise<McpResponse> {
        try {
          const workflowInput: WorkflowExecutionInput = {
            taskId: input.taskId,
            executionId: input.executionId,
            roleName: input.roleName,
            executionMode: input.executionMode,
            executionContext: input.executionContext,
            updateData: input.updateData,
            stepId: input.stepId,
            orchestrationConfig: input.orchestrationConfig,
          };
    
          let result: any;
    
          switch (input.operation) {
            case 'create_execution':
              result = await this.executionOps.createExecution(workflowInput);
              break;
            case 'get_execution':
              result = await this.executionOps.getExecution(workflowInput);
              break;
            case 'update_execution':
              result = await this.executionOps.updateExecution(workflowInput);
              break;
            case 'complete_execution':
              result = await this.executionOps.completeExecution(workflowInput);
              break;
            case 'get_active_executions':
              result = await this.executionOps.getActiveExecutions();
              break;
    
            case 'get_execution_context':
              if (!input.executionId) {
                throw new Error(
                  'executionId is required for get_execution_context',
                );
              }
              result = await this.executionOps.getExecutionContext({
                executionId: input.executionId,
                dataKey: input.dataKey,
              });
              break;
            case 'update_execution_context':
              if (!input.executionId) {
                throw new Error(
                  'executionId is required for update_execution_context',
                );
              }
              if (!input.contextUpdates) {
                throw new Error(
                  'contextUpdates is required for update_execution_context',
                );
              }
              result = await this.executionOps.updateExecutionContext({
                executionId: input.executionId,
                contextUpdates: input.contextUpdates,
              });
              break;
            default: {
              const exhaustiveCheck: never = input.operation;
              throw new Error(`Unknown operation: ${String(exhaustiveCheck)}`);
            }
          }
    
          // Return MINIMAL state data only - NO guidance generation, NO envelopes
          return this.buildResponse({
            success: true,
            data: result,
            timestamp: new Date().toISOString(),
          });
        } catch (error: unknown) {
          const errorMessage =
            error instanceof Error ? error.message : 'Unknown error';
    
          return this.buildErrorResponse(
            errorMessage,
            '',
            'WORKFLOW_EXECUTION_FAILED',
          );
        }
      }
    }
  • Primary Zod schema for tool input validation, including operation enum and conditional requirements via refine.
    const WorkflowExecutionSchema = z
      .object({
        operation: z
          .enum([
            'create_execution',
            'get_execution',
            'update_execution',
            'complete_execution',
            'get_active_executions',
            'get_execution_context',
            'update_execution_context',
          ])
          .describe('Operation to execute'),
    
        // Identifiers
        taskId: z
          .number()
          .optional()
          .describe('Task ID (optional for bootstrap executions)'),
        executionId: z
          .string()
          .optional()
          .describe('Execution ID for operations requiring it'),
    
        // Role and execution settings
        roleName: z
          .enum(['product-manager', 'architect', 'senior-developer', 'code-review'])
          .optional()
          .describe('Role name for execution'),
    
        executionMode: z
          .enum(['GUIDED', 'AUTOMATED', 'HYBRID'])
          .optional()
          .describe('Execution mode'),
        autoCreatedTask: z
          .boolean()
          .optional()
          .describe('Whether task was auto-created'),
    
        // Structured data fields - NO MORE z.any()
        executionContext: ExecutionContextSchema.optional(),
        updateData: UpdateDataSchema.optional(),
        stepId: z.string().optional().describe('Current step ID'),
        orchestrationConfig: OrchestrationConfigSchema.optional(),
    
        // Context operation fields
        dataKey: z
          .string()
          .optional()
          .describe('Specific data key to retrieve from context'),
        contextUpdates: ContextUpdatesSchema.optional(),
      })
      .refine(
        (data) => {
          // Validation rules for different operations
          if (data.operation === 'get_execution') {
            return data.taskId !== undefined || data.executionId !== undefined;
          }
          if (
            [
              'update_execution',
              'complete_execution',
              'get_execution_context',
              'update_execution_context',
            ].includes(data.operation)
          ) {
            return data.executionId !== undefined;
          }
          if (data.operation === 'create_execution') {
            return data.roleName !== undefined;
          }
          if (data.operation === 'update_execution_context') {
            return data.contextUpdates !== undefined;
          }
          return true;
        },
        {
          message:
            'Invalid operation parameters - check required fields for each operation',
        },
      )
      .describe('Workflow execution operation with strongly typed parameters');
  • NestJS module registration of WorkflowExecutionMcpService in providers and exports arrays.
      WorkflowGuidanceMcpService,
      StepExecutionMcpService,
      RoleTransitionMcpService,
      WorkflowExecutionMcpService,
      WorkflowBootstrapMcpService,
    
      // Core Services
      WorkflowGuidanceService,
      ProgressCalculatorService,
      StepExecutionService,
      StepGuidanceService,
      StepProgressTrackerService,
      StepQueryService,
      RoleTransitionService,
      WorkflowExecutionService,
      WorkflowExecutionOperationsService,
      ExecutionDataEnricherService,
      WorkflowBootstrapService,
      ExecutionAnalyticsService,
      WorkflowContextCacheService,
    
      // Guards
      WorkflowContextValidationGuard,
    ],
    exports: [
      // MCP Operations
      WorkflowGuidanceMcpService,
      StepExecutionMcpService,
      RoleTransitionMcpService,
      WorkflowExecutionMcpService,
  • Core service implementing the execution operations (create, get, update, complete, etc.) delegated by the MCP handler.
    export class WorkflowExecutionOperationsService extends ConfigurableService<ExecutionOperationsConfig> {
      // Configuration with sensible defaults
      protected readonly defaultConfig: ExecutionOperationsConfig = {
        defaults: {
          executionMode: 'GUIDED',
          orchestrationMode: 'sequential',
          continueOnFailure: false,
        },
        validation: {
          requireExecutionId: true,
          requireRoleName: true,
          maxServiceCalls: 20,
        },
        performance: {
          operationTimeoutMs: 30000,
          maxConcurrentExecutions: 10,
          cacheResultsMs: 300000, // 5 minutes
        },
      };
    
      constructor(
        private readonly workflowExecution: WorkflowExecutionService,
        private readonly dataEnricher: ExecutionDataEnricherService,
        private readonly analytics: ExecutionAnalyticsService,
      ) {
        super();
        this.initializeConfig();
      }
    
      /**
       * Validate input parameters
       */
      private validateInput(
        input: WorkflowExecutionInput,
        operation: string,
      ): void {
        // Special handling for operations that can work without taskId
    
        // get_execution can work with either taskId OR executionId
        if (operation === 'get_execution') {
          if (!input.taskId && !input.executionId) {
            throw new Error(`get_execution requires either taskId or executionId`);
          }
        }
    
        if (
          operation === 'create' &&
          this.getConfigValue('validation').requireRoleName &&
          !input.roleName
        ) {
          throw new Error(`roleName is required for ${operation}`);
        }
    
        if (
          ['update', 'complete'].includes(operation) &&
          this.getConfigValue('validation').requireExecutionId &&
          !input.executionId
        ) {
          throw new Error(`executionId is required for ${operation}`);
        }
    
        if (input.orchestrationConfig?.serviceCalls) {
          const serviceCallCount = input.orchestrationConfig.serviceCalls.length;
          const maxServiceCalls = this.getConfigValue('validation').maxServiceCalls;
          if (serviceCallCount > maxServiceCalls) {
            throw new Error(
              `Too many service calls: ${serviceCallCount}. Maximum allowed: ${maxServiceCalls}`,
            );
          }
        }
      }
    
      /**
       * Create new workflow execution
       */
      async createExecution(
        input: WorkflowExecutionInput,
      ): Promise<ExecutionResult> {
        this.validateInput(input, 'create');
    
        const createInput: CreateWorkflowExecutionInput = {
          taskId: input.taskId,
          currentRoleId: input.roleName!, // Safe after validation
          executionMode:
            input.executionMode || this.getConfigValue('defaults').executionMode,
          executionContext: input.executionContext,
        };
    
        const execution = await this.workflowExecution.createExecution(createInput);
        const nextSteps = await this.dataEnricher.getNextStepsForExecution(
          execution.id,
        );
    
        return {
          execution,
          nextSteps,
        };
      }
    
      /**
       * Get execution with enriched context
       */
      async getExecution(input: WorkflowExecutionInput): Promise<ExecutionResult> {
        this.validateInput(input, 'get');
    
        let execution: WorkflowExecutionWithRelations | null;
    
        if (!input.executionId) {
          if (!input.taskId) {
            throw new Error(
              `Either taskId or executionId is required for get operation`,
            );
          }
          execution = await this.workflowExecution.getExecutionByTaskId(
            input.taskId,
          );
          if (!execution) {
            throw new Error(`No execution found for task ${input.taskId}`);
          }
        } else {
          execution = await this.workflowExecution.getExecutionById(
            input.executionId, // Safe after validation
          );
        }
    
        return await this.dataEnricher.enrichExecutionData(execution);
      }
    
      /**
       * Get execution context data
       * Used by product-manager workflow to retrieve task creation data
       */
      async getExecutionContext(input: {
        executionId: string;
        dataKey?: string;
      }): Promise<any> {
        const execution = await this.workflowExecution.getExecutionById(
          input.executionId,
        );
    
        if (input.dataKey) {
          // Return specific data from execution context
          if (
            execution.executionContext &&
            typeof execution.executionContext === 'object' &&
            execution.executionContext !== null &&
            input.dataKey in execution.executionContext
          ) {
            return (execution.executionContext as Record<string, any>)[
              input.dataKey
            ];
          }
          // Also check in taskCreationData for backward compatibility
          if (execution.taskCreationData && input.dataKey === 'taskCreationData') {
            return execution.taskCreationData;
          }
          throw new Error(
            `Data key '${input.dataKey}' not found in execution context`,
          );
        }
    
        // Return full execution context
        return {
          executionContext: execution.executionContext,
          taskCreationData: execution.taskCreationData,
          executionState: execution.executionState,
        };
      }
    
      /**
       * Update execution context
       * Used by product-manager workflow to update context after task updates
       */
      async updateExecutionContext(input: {
        executionId: string;
        contextUpdates: Record<string, any>;
      }): Promise<any> {
        const execution = await this.workflowExecution.getExecutionById(
          input.executionId,
        );
    
        // Merge context updates with existing context
        const currentContext =
          execution.executionContext &&
          typeof execution.executionContext === 'object' &&
          execution.executionContext !== null
            ? (execution.executionContext as Record<string, any>)
            : {};
    
        const updatedContext = {
          ...currentContext,
          ...input.contextUpdates,
        };
    
        const updatedExecution = await this.workflowExecution.updateExecution(
          input.executionId,
          {
            executionContext: updatedContext,
          },
        );
    
        return {
          success: true,
          updatedContext: updatedExecution.executionContext,
          executionId: input.executionId,
        };
      }
    
      /**
       * Update execution state
       */
      async updateExecution(
        input: WorkflowExecutionInput,
      ): Promise<ExecutionResult> {
        this.validateInput(input, 'update');
    
        const execution = await this.workflowExecution.updateExecution(
          input.executionId!, // Safe after validation
          input.updateData || {},
        );
    
        const nextActions = await this.dataEnricher.getNextStepsForExecution(
          execution.id,
        );
        const progressMatrix =
          this.dataEnricher.calculateProgressMetrics(execution);
    
        return {
          execution,
          progressMatrix,
          nextActions,
        };
      }
    
      /**
       * Complete execution
       */
      async completeExecution(
        input: WorkflowExecutionInput,
      ): Promise<ExecutionResult> {
        this.validateInput(input, 'complete');
    
        const execution = await this.workflowExecution.completeExecution(
          input.executionId!, // Safe after validation
        );
        const completionSummary =
          this.analytics.generateCompletionSummary(execution);
        const finalRecommendations = this.analytics.getFinalRecommendations();
    
        return {
          execution,
          completionSummary,
          finalRecommendations,
        };
      }
    
      /**
       * Get active executions with summary
       */
      async getActiveExecutions(): Promise<ExecutionsSummary> {
        const executions = await this.workflowExecution.getActiveExecutions();
    
        return {
          executions,
          summary: {
            total: executions.length,
            byRole: this.analytics.groupExecutionsByRole(executions),
            progressOverview: this.analytics.calculateOverallProgress(executions),
          },
        };
      }
    }
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. While it mentions 'strongly-typed operations' and 'validated parameters,' it doesn't disclose critical behavioral traits: whether operations are read-only or mutative, authentication requirements, rate limits, error handling, or what 'managing execution state' entails in practice. For a tool with 12 parameters and complex nested objects, this is a significant gap in behavioral transparency.

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 efficiently structured in two sentences that cover purpose and key characteristics. It's appropriately sized for a complex tool, though the second sentence could be more specific about what 'handles execution context and progress tracking' means in practice. There's no wasted verbiage, and the information is front-loaded with the core purpose.

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?

For a highly complex tool with 12 parameters, nested objects, no annotations, and no output schema, the description is inadequate. It doesn't explain the relationship between different operations, what 'managing workflow execution state' entails, how operations differ, or what the tool returns. With 15 sibling tools on the server, the lack of differentiation and behavioral context makes this description incomplete for effective tool selection and invocation.

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 12 parameters thoroughly. The description adds minimal value beyond what's in the schema - it mentions 'validated parameters' and 'strongly-typed operations' but provides no additional semantic context about parameter relationships, dependencies, or usage patterns. The baseline of 3 is appropriate when the schema does the heavy lifting, though the description doesn't compensate for the tool's complexity.

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 'manages workflow execution state through strongly-typed operations' and lists specific operations (creating, querying, updating, completing). It specifies the resource ('workflow executions') and mentions context and progress tracking. However, it doesn't explicitly differentiate this from sibling tools like 'execute_transition' or 'report_step_completion' that also handle workflow execution aspects.

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 no guidance on when to use this tool versus alternatives. With 15 sibling tools on the server, many related to workflow execution (like execute_transition, report_step_completion, get_step_progress), there's no indication of which scenarios call for this comprehensive operation-based approach versus more specific sibling tools. The description mentions 'validated parameters' but doesn't provide usage context.

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

Related 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/Hive-Academy/Anubis-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server