Skip to main content
Glama

初始化工作流配置

gitea_workflow_init

Initialize issue workflow configuration for a project by generating .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type.

Instructions

Initialize Issue workflow configuration for a project. Generates .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoRepository owner. Uses context if not provided
repoNoRepository name. Uses context if not provided
project_typeYesProject type for template selection
languageNoPrimary programming language (e.g., go, typescript, python)

Implementation Reference

  • Core handler function for gitea_workflow_init tool. Resolves repository context, generates default workflow configuration using helpers, serializes to YAML, and returns the configuration details.
    /**
     * 初始化工作流配置
     */
    export async function workflowInit(
      ctx: WorkflowToolsContext,
      args: {
        owner?: string;
        repo?: string;
        project_type: ProjectType;
        language?: string;
      }
    ): Promise<{
      success: boolean;
      message: string;
      config_path: string;
      config_content: string;
    }> {
      logger.debug({ args }, 'Initializing workflow config');
    
      const { owner, repo } = ctx.contextManager.resolveOwnerRepo(args.owner, args.repo);
    
      // 生成默认配置
      const config = generateDefaultConfig(repo, args.project_type, `${owner}/${repo}`, args.language);
    
      // 序列化为 YAML
      const yamlContent = serializeConfig(config);
      const configPath = '.gitea/issue-workflow.yaml';
    
      logger.info({ owner, repo, project_type: args.project_type }, 'Workflow config generated');
    
      return {
        success: true,
        message: `工作流配置已生成,请将以下内容保存到 ${configPath}`,
        config_path: configPath,
        config_content: yamlContent,
      };
    }
  • Registration of the gitea_workflow_init MCP tool, including title, description, Zod inputSchema for validation, and async handler wrapper that invokes the core workflowInit function.
    mcpServer.registerTool(
      'gitea_workflow_init',
      {
        title: '初始化工作流配置',
        description:
          'Initialize Issue workflow configuration for a project. Generates .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type.',
        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'),
          project_type: z
            .enum(['backend', 'frontend', 'fullstack', 'library'])
            .describe('Project type for template selection'),
          language: z.string().optional().describe('Primary programming language (e.g., go, typescript, python)'),
        }),
      },
      async (args) => {
        try {
          const result = await WorkflowTools.workflowInit(
            { 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,
          };
        }
      }
    );
  • Critical helper function `generateDefaultConfig` called by the handler to produce the complete WorkflowConfig object, including labels, board columns, automation rules, and notifications tailored to the specified project type.
    /**
     * 生成默认工作流配置
     */
    export function generateDefaultConfig(
      projectName: string,
      projectType: ProjectType,
      repo: string,
      language?: string
    ): WorkflowConfig {
      return {
        project: {
          name: projectName,
          type: projectType,
          repo,
          language,
        },
        labels: {
          status: DEFAULT_STATUS_LABELS,
          priority: DEFAULT_PRIORITY_LABELS,
          type: DEFAULT_TYPE_LABELS,
          area: AREA_LABELS_BY_TYPE[projectType],
          workflow: DEFAULT_WORKFLOW_LABELS,
          special: DEFAULT_SPECIAL_LABELS,
          prefixes: DEFAULT_LABEL_PREFIXES,
        },
        board: {
          name: 'Issue Workflow Board',
          columns: DEFAULT_BOARD_COLUMNS,
        },
        automation: {
          label_inference: {
            enabled: true,
            confidence_threshold: 0.7,
            type_keywords: DEFAULT_TYPE_KEYWORDS,
            priority_keywords: DEFAULT_PRIORITY_KEYWORDS,
          },
          priority_escalation: {
            enabled: true,
            rules: DEFAULT_ESCALATION_RULES,
          },
          blocked_detection: {
            enabled: true,
            rules: DEFAULT_BLOCKED_RULES,
          },
          status_sync: {
            enabled: true,
            direction: 'both',
            conflict_resolution: 'board-wins',
          },
          new_issue_defaults: {
            auto_add_to_backlog: true,
            require_type_label: true,
            require_priority_label: false,
            default_priority: 'P2',
          },
        },
        notifications: {
          blocked_issues: {
            enabled: true,
            channels: ['issue_comment'],
            template: '⚠️ 此 Issue 已超过 SLA 时间,请及时处理!',
          },
          priority_escalation: {
            enabled: true,
            channels: ['issue_comment'],
            template: '⬆️ 优先级已自动升级为 {new_priority}',
          },
        },
      };
    }
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 states the tool 'Generates .gitea/issue-workflow.yaml', it doesn't disclose whether this is a write operation that modifies repository files, what permissions are required, whether existing files are overwritten, or what happens on failure. For a tool that appears to create configuration files, this represents significant gaps 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.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with two sentences that each earn their place. The first sentence states the core purpose, and the second sentence provides essential details about the output and customization basis. There's no wasted language, repetition, or unnecessary elaboration.

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?

For a tool with 4 parameters, no annotations, and no output schema, the description provides adequate but incomplete context. It explains what the tool does and what it generates, but lacks information about behavioral aspects (permissions, file overwriting), error handling, and return values. The description is complete enough to understand the tool's purpose but insufficient for confident invocation 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?

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds minimal value beyond what's in the schema - it mentions 'project type for template selection' which aligns with the schema's enum, but doesn't provide additional context about how project_type influences the generated configuration or how language interacts with project_type. Baseline 3 is appropriate when the schema does the heavy lifting.

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 ('Initialize Issue workflow configuration'), the target resource ('for a project'), and the concrete outcome ('Generates .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type'). It distinguishes this tool from sibling tools like gitea_workflow_load_config (which loads rather than initializes) and gitea_workflow_sync_labels (which syncs rather than creates from scratch).

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?

The description implies usage context through 'based on project type' and mentions the configuration file generated, but doesn't explicitly state when to use this tool versus alternatives like gitea_workflow_load_config or gitea_workflow_sync_labels. No guidance is provided about prerequisites, timing, or exclusions, leaving the agent to infer appropriate usage scenarios.

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