Skip to main content
Glama

检查 Issue 工作流

gitea_workflow_check_issues

Analyzes open issues for workflow compliance by identifying missing labels, detecting conflicts, and providing actionable improvement suggestions.

Instructions

Check all open issues against workflow rules. Identifies missing labels, conflicts, and provides suggestions for improvement.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoRepository owner. Uses context if not provided
repoNoRepository name. Uses context if not provided
issue_numberNoCheck only a specific issue (optional)
rulesNoApply only specific rules (optional)

Implementation Reference

  • Main handler function implementing the tool logic: loads config, fetches issues, checks for missing labels, conflicts, backlog needs, and generates problems/suggestions.
    export async function workflowCheckIssues(
      ctx: WorkflowToolsContext,
      args: {
        owner?: string;
        repo?: string;
        config?: WorkflowConfig;
        issue_number?: number;
        rules?: string[];
      }
    ): Promise<{
      success: boolean;
      checked: number;
      issues_with_problems: Array<{
        number: number;
        title: string;
        problems: string[];
        suggestions: string[];
      }>;
      error?: string;
    }> {
      logger.debug({ args: { ...args, config: args.config ? '[provided]' : undefined } }, 'Checking issues');
    
      const { owner, repo } = ctx.contextManager.resolveOwnerRepo(args.owner, args.repo);
    
      // 获取配置
      let config = args.config;
      if (!config) {
        const loadResult = await workflowLoadConfig(ctx, { owner, repo });
        if (!loadResult.success || !loadResult.config) {
          return {
            success: false,
            checked: 0,
            issues_with_problems: [],
            error: loadResult.error || '无法加载配置',
          };
        }
        config = loadResult.config;
      }
    
      const issuesWithProblems: Array<{
        number: number;
        title: string;
        problems: string[];
        suggestions: string[];
      }> = [];
    
      try {
        // 获取 Issue 列表
        let issues: Issue[];
        if (args.issue_number) {
          const issue = await ctx.client.get<Issue>(`/repos/${owner}/${repo}/issues/${args.issue_number}`);
          issues = [issue];
        } else {
          issues = await ctx.client.get<Issue[]>(`/repos/${owner}/${repo}/issues?state=open&limit=100`);
        }
    
        const inferenceEngine = new LabelInferenceEngine(config);
        const boardSyncManager = new BoardSyncManager(config);
    
        for (const issue of issues) {
          const problems: string[] = [];
          const suggestions: string[] = [];
    
          // 检查标签完整性
          const missingLabels = inferenceEngine.checkMissingLabels(issue);
          if (missingLabels.length > 0) {
            problems.push(`缺少必要标签: ${missingLabels.join(', ')}`);
    
            // 推断标签
            const inference = inferenceEngine.inferAll(issue);
            for (const item of inference.all) {
              suggestions.push(`建议添加标签 ${item.label} (置信度: ${(item.confidence * 100).toFixed(0)}%)`);
            }
          }
    
          // 检查标签冲突
          const conflicts = boardSyncManager.checkLabelConflicts(issue);
          if (conflicts.length > 0) {
            problems.push(...conflicts);
            suggestions.push('建议保留最新的标签,移除冲突标签');
          }
    
          // 检查是否需要添加到 Backlog
          if (boardSyncManager.shouldAddToBacklog(issue)) {
            const prefixes = getLabelPrefixes(config);
            suggestions.push(`建议添加 ${buildLabel(prefixes.status, 'backlog')} 标签`);
          }
    
          if (problems.length > 0 || suggestions.length > 0) {
            issuesWithProblems.push({
              number: issue.number,
              title: issue.title,
              problems,
              suggestions,
            });
          }
        }
    
        logger.info(
          { owner, repo, checked: issues.length, problems: issuesWithProblems.length },
          'Issues checked'
        );
    
        return {
          success: true,
          checked: issues.length,
          issues_with_problems: issuesWithProblems,
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        logger.error({ owner, repo, error: errorMessage }, 'Failed to check issues');
    
        return {
          success: false,
          checked: 0,
          issues_with_problems: [],
          error: errorMessage,
        };
      }
    }
  • MCP tool registration including name, title, description, Zod input schema, and async handler wrapper that calls the implementation.
    mcpServer.registerTool(
      'gitea_workflow_check_issues',
      {
        title: '检查 Issue 工作流',
        description:
          'Check all open issues against workflow rules. Identifies missing labels, conflicts, and provides suggestions for improvement.',
        inputSchema: z.object({
          owner: z.string().optional().describe('Repository owner. Uses context if not provided'),
          repo: z.string().optional().describe('Repository name. Uses context if not provided'),
          issue_number: z.number().optional().describe('Check only a specific issue (optional)'),
          rules: z.array(z.string()).optional().describe('Apply only specific rules (optional)'),
        }),
      },
      async (args) => {
        try {
          const result = await WorkflowTools.workflowCheckIssues(
            { client: ctx.client, contextManager: ctx.contextManager },
            args
          );
          return {
            content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }],
            isError: !result.success,
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [{ type: 'text' as const, text: `Error: ${errorMessage}` }],
            isError: true,
          };
        }
      }
    );
  • Zod input schema defining parameters for the tool: owner, repo, optional issue_number and rules.
    inputSchema: z.object({
      owner: z.string().optional().describe('Repository owner. Uses context if not provided'),
      repo: z.string().optional().describe('Repository name. Uses context if not provided'),
      issue_number: z.number().optional().describe('Check only a specific issue (optional)'),
      rules: z.array(z.string()).optional().describe('Apply only specific rules (optional)'),
    }),
Behavior2/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 mentions what the tool does (checking issues, identifying missing labels/conflicts, providing suggestions) but lacks critical details: whether it's read-only or modifies data, permission requirements, rate limits, error handling, or output format. This is inadequate for a tool with potential compliance implications.

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, efficient sentence that front-loads the core functionality. It avoids redundancy and wastes no words, though it could be slightly more structured for clarity.

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?

Given no annotations and no output schema, the description is incomplete. It doesn't explain the return format (e.g., report structure, error responses), behavioral traits like safety or side effects, or how it interacts with sibling tools. For a compliance-checking tool, this leaves significant gaps.

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 four parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain 'rules' format or 'issue_number' constraints). Baseline 3 is appropriate when schema does the heavy lifting.

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: 'Check all open issues against workflow rules. Identifies missing labels, conflicts, and provides suggestions for improvement.' It specifies the verb ('Check'), resource ('open issues'), and scope ('against workflow rules'), but doesn't explicitly differentiate from sibling tools like 'gitea_workflow_check_blocked' or 'gitea_workflow_generate_report'.

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. It doesn't mention sibling tools like 'gitea_workflow_check_blocked' or 'gitea_workflow_generate_report', nor does it specify prerequisites, exclusions, or appropriate contexts for usage.

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/SupenBysz/gitea-mcp-tool'

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