Skip to main content
Glama
kingdomseed

Structured Workflow MCP

by kingdomseed

refactor_workflow

Improve existing code structure without changing functionality by following a structured refactoring workflow that maintains code quality.

Instructions

Start a structured refactoring workflow to improve existing code without changing functionality

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesDescription of what you want to refactor
contextNoAdditional context (optional)

Implementation Reference

  • The primary handler function that executes the 'refactor_workflow' tool logic by calling the general workflow executor with type 'refactor'.
    export async function handleRefactorWorkflow(
      params: { task: string; context?: any },
      sessionManager: SessionManager
    ) {
      return executeWorkflow(
        {
          task: params.task,
          workflowType: 'refactor',
          context: params.context
        },
        sessionManager
      );
    }
  • Input schema for the 'refactor_workflow' tool, defining the task parameter as required and optional context with targetFiles, scope, and constraints.
    inputSchema: {
      type: 'object',
      properties: {
        task: {
          type: 'string',
          description: 'Description of what you want to refactor'
        },
        context: {
          type: 'object',
          description: 'Additional context (optional)',
          properties: {
            targetFiles: { 
              type: 'array', 
              items: { type: 'string' },
              description: 'Specific files to refactor'
            },
            scope: { 
              type: 'string', 
              enum: ['file', 'directory', 'project'],
              description: 'The scope of the refactoring'
            },
            constraints: { 
              type: 'array', 
              items: { type: 'string' },
              description: 'Any constraints or requirements'
            }
          }
        }
      },
      required: ['task']
    }
  • src/index.ts:137-157 (registration)
    Registration of the 'refactor_workflow' tool via inclusion of createRefactorWorkflowTool() in the server's tools array.
    const tools = [
      // Workflow entry points
      createRefactorWorkflowTool(),                 // Refactoring workflow
      createFeatureWorkflowTool(),                  // Feature creation workflow
      createTestWorkflowTool(),                     // Test writing workflow
      createTddWorkflowTool(),                      // TDD workflow
      createBuildCustomWorkflowTool(),              // Custom workflow builder
      
      // Phase guidance tools
      ...createPhaseGuidanceTools(),                // Handles both suggestive and directive modes
      createTestGuidanceTool(),                     // TEST phase guidance
      
      // Validation tools
      ...createValidationTools(),                   // Both validate_action and validate_phase_completion
      
      // Workflow management
      createUserInputRequiredTool(),                // Escalation handling
      createWorkflowStatusTool(),                   // Workflow status
      createPhaseOutputTool(),                      // Phase output recording
      createDiscoverWorkflowToolsTool()             // Tool discovery
    ];
  • src/index.ts:226-232 (registration)
    Dispatch registration in the MCP server's tool call handler switch statement, routing 'refactor_workflow' calls to the handleRefactorWorkflow function.
    case 'refactor_workflow':
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(await handleRefactorWorkflow(args as any, sessionManager), null, 2)
        }]
      };

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/kingdomseed/structured-workflow-mcp'

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