Skip to main content
Glama

suggest_workflow

Automatically recommends a suitable workflow based on the task description, enabling efficient collaboration between AI models for complex tasks.

Instructions

根据任务自动推荐合适的工作流

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYes任务描述

Implementation Reference

  • The handler for the 'suggest_workflow' tool. It extracts the 'task' argument, calls workflowManager.matchWorkflow(task) to find a matching workflow, and returns either the recommended workflow details or a fallback message listing available workflows.
            case 'suggest_workflow': {
              const { task } = args as { task: string };
              
              const matched = workflowManager.matchWorkflow(task);
              
              if (matched) {
                const stepsDesc = matched.steps
                  .filter(s => s.type === 'expert')
                  .map((s, i) => `${i + 1}. **${s.name}** - ${s.expert?.role.slice(0, 50)}...`)
                  .join('\n');
                
                return {
                  content: [{ type: 'text', text: `# 💡 推荐工作流
    
    ## ${matched.name} (\`${matched.id}\`)
    ${matched.description}
    
    ### 执行步骤
    ${stepsDesc}
    
    ### 触发原因
    任务包含关键词: ${matched.triggers.filter(t => task.toLowerCase().includes(t.toLowerCase())).join(', ')}
    
    ---
    > 使用 \`run_workflow\` 执行此工作流:
    > \`{ "workflow": "${matched.id}", "task": "${task.slice(0, 50)}..." }\`` }],
                };
              } else {
                return {
                  content: [{ type: 'text', text: `# 💡 工作流推荐
    
    未找到匹配的预定义工作流。
    
    **建议**: 使用 \`team_work\` 让 Tech Lead 动态分析任务并创建专家团队。
    
    **可用工作流**:
    - \`code-generation\` - 代码生成(写、创建、实现)
    - \`bug-fix\` - Bug 修复(修复、错误、fix)
    - \`refactoring\` - 代码重构(重构、优化)
    - \`code-review\` - 代码审查(审查、review)
    - \`documentation\` - 文档生成(文档、doc)` }],
                };
              }
  • Tool registration/definition for 'suggest_workflow' in the ListToolsRequestSchema handler. Defines the tool name, description, and inputSchema (requires a 'task' string).
    {
      name: 'suggest_workflow',
      description: '根据任务自动推荐合适的工作流',
      inputSchema: {
        type: 'object',
        properties: {
          task: {
            type: 'string',
            description: '任务描述',
          },
        },
        required: ['task'],
      },
    },
  • src/server.ts:120-403 (registration)
    The 'suggest_workflow' tool is registered as part of the ListToolsRequestSchema handler along with other tools (line 388-401). The actual call handling is in the CallToolRequestSchema switch-case (line 936).
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'team_work',
          description:
            '让 AI 开发团队协作完成任务。团队包含前端专家、后端专家、QA专家,会智能分配任务并互相协作。',
          inputSchema: {
            type: 'object',
            properties: {
              task: {
                type: 'string',
                description: '任务描述,例如:帮我写一个用户登录功能',
              },
              context: {
                type: 'string',
                description: '额外的上下文信息(可选)',
              },
            },
            required: ['task'],
          },
        },
        {
          name: 'ask_expert',
          description: '向特定专家咨询问题',
          inputSchema: {
            type: 'object',
            properties: {
              expert: {
                type: 'string',
                enum: expertEnumInfo.enum,
                description: expertEnumInfo.description,
              },
              question: {
                type: 'string',
                description: '要咨询的问题',
              },
            },
            required: ['expert', 'question'],
          },
        },
        {
          name: 'code_review',
          description: '让专家审查代码',
          inputSchema: {
            type: 'object',
            properties: {
              code: {
                type: 'string',
                description: '要审查的代码',
              },
              reviewer: {
                type: 'string',
                enum: expertEnumInfo.enum,
                description: `审查者:${expertEnumInfo.description}`,
              },
              context: {
                type: 'string',
                description: '代码的背景信息(可选)',
              },
            },
            required: ['code', 'reviewer'],
          },
        },
        {
          name: 'fix_bug',
          description: '让 QA 专家修复 Bug',
          inputSchema: {
            type: 'object',
            properties: {
              code: {
                type: 'string',
                description: '有 Bug 的代码',
              },
              error: {
                type: 'string',
                description: '错误信息或 Bug 描述',
              },
            },
            required: ['code', 'error'],
          },
        },
        {
          name: 'history_list',
          description: '查看团队协作历史记录列表',
          inputSchema: {
            type: 'object',
            properties: {
              limit: {
                type: 'number',
                description: '返回记录数量,默认 10',
              },
            },
          },
        },
        {
          name: 'history_get',
          description: '获取某次协作的详细记录',
          inputSchema: {
            type: 'object',
            properties: {
              id: {
                type: 'string',
                description: '协作记录 ID',
              },
            },
            required: ['id'],
          },
        },
        {
          name: 'history_search',
          description: '搜索协作历史记录',
          inputSchema: {
            type: 'object',
            properties: {
              query: {
                type: 'string',
                description: '搜索关键词',
              },
              limit: {
                type: 'number',
                description: '返回记录数量,默认 10',
              },
            },
            required: ['query'],
          },
        },
        {
          name: 'history_context',
          description: '获取最近的协作上下文,可用于继续之前的工作',
          inputSchema: {
            type: 'object',
            properties: {
              count: {
                type: 'number',
                description: '获取最近几次协作,默认 3',
              },
            },
          },
        },
        {
          name: 'usage_stats',
          description: '查看各模型的使用统计(调用次数、成功率、平均耗时)',
          inputSchema: {
            type: 'object',
            properties: {},
          },
        },
        {
          name: 'team_dashboard',
          description: '查看团队当前状态:可用专家、模型配置、最近活动',
          inputSchema: {
            type: 'object',
            properties: {},
          },
        },
        {
          name: 'cost_estimate',
          description: '预估任务执行成本(Token 用量、预计耗时)',
          inputSchema: {
            type: 'object',
            properties: {
              task: {
                type: 'string',
                description: '要预估的任务描述',
              },
            },
            required: ['task'],
          },
        },
        {
          name: 'explain_plan',
          description: '解释 Tech Lead 会如何分配任务(不实际执行)',
          inputSchema: {
            type: 'object',
            properties: {
              task: {
                type: 'string',
                description: '要分析的任务描述',
              },
            },
            required: ['task'],
          },
        },
        {
          name: 'read_project_files',
          description: '读取项目文件内容,让专家了解代码上下文',
          inputSchema: {
            type: 'object',
            properties: {
              path: {
                type: 'string',
                description: '文件或目录路径(相对于当前工作目录)',
              },
              pattern: {
                type: 'string',
                description: '文件匹配模式(如 *.ts, *.js),仅读取目录时有效',
              },
              maxFiles: {
                type: 'number',
                description: '最多读取文件数(默认 10)',
              },
            },
            required: ['path'],
          },
        },
        {
          name: 'generate_commit_message',
          description: '根据代码变更生成 Git commit message',
          inputSchema: {
            type: 'object',
            properties: {
              diff: {
                type: 'string',
                description: '代码变更内容(git diff 输出)',
              },
              style: {
                type: 'string',
                enum: ['conventional', 'simple', 'detailed'],
                description: '提交信息风格:conventional(约定式)、simple(简洁)、detailed(详细)',
              },
            },
            required: ['diff'],
          },
        },
        {
          name: 'analyze_project_structure',
          description: '分析项目结构,识别技术栈和架构',
          inputSchema: {
            type: 'object',
            properties: {
              path: {
                type: 'string',
                description: '项目根目录路径(默认当前目录)',
              },
            },
          },
        },
        {
          name: 'list_workflows',
          description: '列出所有可用的工作流模板',
          inputSchema: {
            type: 'object',
            properties: {},
          },
        },
        {
          name: 'run_workflow',
          description: '使用指定工作流执行任务',
          inputSchema: {
            type: 'object',
            properties: {
              workflow: {
                type: 'string',
                enum: ['code-generation', 'bug-fix', 'refactoring', 'code-review', 'documentation'],
                description: '工作流 ID',
              },
              task: {
                type: 'string',
                description: '任务描述',
              },
              context: {
                type: 'string',
                description: '额外上下文(可选)',
              },
            },
            required: ['workflow', 'task'],
          },
        },
        {
          name: 'suggest_workflow',
          description: '根据任务自动推荐合适的工作流',
          inputSchema: {
            type: 'object',
            properties: {
              task: {
                type: 'string',
                description: '任务描述',
              },
            },
            required: ['task'],
          },
        },
      ],
    }));
  • The WorkflowManager.matchWorkflow() method. Called by the handler, it iterates custom workflows first, then predefined templates, checking if any trigger keywords match the task string (case-insensitive). Returns the first matching WorkflowDefinition or undefined.
    matchWorkflow(task: string): WorkflowDefinition | undefined {
      const taskLower = task.toLowerCase();
      
      // 先检查自定义工作流
      for (const workflow of this.customWorkflows.values()) {
        if (workflow.triggers.some(t => taskLower.includes(t.toLowerCase()))) {
          return workflow;
        }
      }
      
      // 再检查预定义模板
      for (const workflow of this.templates.values()) {
        if (workflow.triggers.some(t => taskLower.includes(t.toLowerCase()))) {
          return workflow;
        }
      }
      
      return undefined;
    }
  • The WorkflowManager class definition containing the templates map, customWorkflows map, and methods including matchWorkflow() used by suggest_workflow.
    export class WorkflowManager {
      private templates: Map<string, WorkflowDefinition>;
      private customWorkflows: Map<string, WorkflowDefinition>;
    
      constructor() {
        this.templates = new Map(Object.entries(WORKFLOW_TEMPLATES));
        this.customWorkflows = new Map();
      }
    
      /**
       * 注册自定义工作流
       */
      registerWorkflow(workflow: WorkflowDefinition): void {
        this.customWorkflows.set(workflow.id, workflow);
      }
    
      /**
       * 获取工作流
       */
      getWorkflow(id: string): WorkflowDefinition | undefined {
        return this.customWorkflows.get(id) || this.templates.get(id);
      }
    
      /**
       * 根据任务自动匹配工作流
       */
      matchWorkflow(task: string): WorkflowDefinition | undefined {
        const taskLower = task.toLowerCase();
        
        // 先检查自定义工作流
        for (const workflow of this.customWorkflows.values()) {
          if (workflow.triggers.some(t => taskLower.includes(t.toLowerCase()))) {
            return workflow;
          }
        }
        
        // 再检查预定义模板
        for (const workflow of this.templates.values()) {
          if (workflow.triggers.some(t => taskLower.includes(t.toLowerCase()))) {
            return workflow;
          }
        }
        
        return undefined;
      }
    
      /**
       * 列出所有可用工作流
       */
      listWorkflows(): WorkflowDefinition[] {
        return [
          ...this.templates.values(),
          ...this.customWorkflows.values(),
        ];
      }
    
      /**
       * 将工作流转换为 Tech Lead 格式
       */
      toTaskAnalysis(workflow: WorkflowDefinition, task: string): {
        experts: DynamicExpert[];
        subtasks: SubTask[];
        workflow: WorkflowType;
      } {
        const experts: DynamicExpert[] = [];
        const subtasks: SubTask[] = [];
        let expertIndex = 0;
    
        // 收集所有专家步骤
        const expertSteps = workflow.steps.filter(s => s.type === 'expert' && s.expert);
        
        for (const step of expertSteps) {
          if (!step.expert) continue;
          
          const expertId = `expert-${expertIndex++}`;
          experts.push({
            id: expertId,
            name: step.expert.name,
            role: step.expert.role,
            tier: step.expert.tier,
            skills: step.expert.skills || [],
          });
          
          subtasks.push({
            id: step.id,
            description: step.taskTemplate?.replace('{{task}}', task) || task,
            expertId,
            dependencies: step.dependencies || [],
            priority: expertIndex,
          });
        }
    
        // 判断工作流类型
        const hasParallel = workflow.steps.some(s => s.type === 'parallel');
        const hasDependencies = workflow.steps.some(s => s.dependencies && s.dependencies.length > 0);
        
        let workflowType: WorkflowType = 'sequential';
        if (hasParallel && !hasDependencies) {
          workflowType = 'parallel';
        } else if (hasParallel && hasDependencies) {
          workflowType = 'mixed';
        }
    
        return { experts, subtasks, workflow: workflowType };
      }
    }
    
    /** 全局工作流管理器实例 */
    export const workflowManager = new WorkflowManager();
Behavior2/5

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

No annotations are provided, so the description bears the full burden of disclosing behavior. It only states 'automatically recommend suitable workflow' without explaining how the recommendation is made, whether it requires additional context, or what side effects (if any) exist. This is insufficient for an agent to understand the tool's behavior.

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 a single, concise sentence that conveys the core purpose without extraneous words. While efficient, it could benefit from slightly more detail about when to use it, but it is not wasteful.

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?

Given the simplicity (one parameter, no output schema) and presence of sibling tools, the description is adequate for basic understanding but lacks behavioral transparency and usage context. It does not fully equip the agent to select or invoke the tool correctly without additional assumptions.

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?

The input schema has 100% coverage with a description for the single parameter. The tool description adds no extra meaning beyond the schema's '任务描述' (task description). Baseline score of 3 is appropriate as the schema already defines the parameter adequately.

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 tool's function: it recommends a suitable workflow for a given task. The verb 'recommend' and resource 'workflow' are specific. It distinguishes from siblings like list_workflows (which lists all) and run_workflow (which executes).

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?

No explicit guidance on when to use this tool versus alternatives. The description implies it's for automatic recommendation based on a task description, but does not specify when not to use it or mention any prerequisites. Context with siblings suggests its role, but lacks explicit direction.

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/7836246/claude-team-mcp'

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