Skip to main content
Glama

加载工作流配置

gitea_workflow_load_config

Load and parse workflow configuration from .gitea/issue-workflow.yaml to validate and retrieve structured workflow rules for Gitea repositories.

Instructions

Load and parse the workflow configuration from .gitea/issue-workflow.yaml. Returns the parsed config and validation results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNoRepository owner. Uses context if not provided
repoNoRepository name. Uses context if not provided

Implementation Reference

  • Main handler function that implements the gitea_workflow_load_config tool: fetches .gitea/issue-workflow.yaml from repo, parses YAML, validates config, and returns structured result.
    // ============ 工具 2: 加载工作流配置 ============
    
    /**
     * 加载工作流配置
     */
    export async function workflowLoadConfig(
      ctx: WorkflowToolsContext,
      args: {
        owner?: string;
        repo?: string;
      }
    ): Promise<{
      success: boolean;
      config?: WorkflowConfig;
      validation?: { valid: boolean; errors: string[]; warnings: string[] };
      error?: string;
    }> {
      logger.debug({ args }, 'Loading workflow config');
    
      const { owner, repo } = ctx.contextManager.resolveOwnerRepo(args.owner, args.repo);
    
      try {
        // 尝试从仓库读取配置文件
        const response = await ctx.client.get<{ content: string }>(
          `/repos/${owner}/${repo}/contents/.gitea/issue-workflow.yaml`
        );
    
        // 解码 Base64 内容
        const yamlContent = Buffer.from(response.content, 'base64').toString('utf-8');
        const parseResult = parseConfig(yamlContent);
    
        if (!parseResult.success || !parseResult.config) {
          return {
            success: false,
            error: `配置解析失败: ${parseResult.errors?.join(', ') || '未知错误'}`,
          };
        }
    
        const validation = validateConfig(parseResult.config);
    
        logger.info({ owner, repo, valid: validation.valid }, 'Workflow config loaded');
    
        return {
          success: true,
          config: parseResult.config,
          validation,
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        logger.warn({ owner, repo, error: errorMessage }, 'Failed to load workflow config');
    
        return {
          success: false,
          error: `无法加载工作流配置: ${errorMessage}`,
        };
      }
    }
  • MCP tool registration for 'gitea_workflow_load_config', defines input schema (owner/repo optional), wraps the workflowLoadConfig handler with error handling and JSON response formatting.
    // 2. gitea_workflow_load_config - 加载工作流配置
    mcpServer.registerTool(
      'gitea_workflow_load_config',
      {
        title: '加载工作流配置',
        description:
          'Load and parse the workflow configuration from .gitea/issue-workflow.yaml. Returns the parsed config and validation results.',
        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'),
        }),
      },
      async (args) => {
        try {
          const result = await WorkflowTools.workflowLoadConfig(
            { 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,
          };
        }
      }
    );
  • Input schema definition using Zod: optional owner and repo strings, resolved via context if omitted.
      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'),
      }),
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool loads, parses, and returns validation results, which is helpful, but lacks critical behavioral details: it doesn't specify error handling (e.g., if the file doesn't exist), authentication needs, rate limits, or whether it's a read-only operation. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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 a single, well-structured sentence that efficiently conveys the core action, resource, and outcome without unnecessary words. It is front-loaded with the main purpose, making it easy to understand quickly.

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 tool's moderate complexity (loading and parsing a config file) and no annotations or output schema, the description is minimally adequate. It covers the basic purpose but lacks details on error handling, return format, or integration with other tools. Without an output schema, it should ideally explain the return structure more, but the mention of 'parsed config and validation results' provides some context.

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% description coverage, with clear documentation for 'owner' and 'repo' parameters. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't need to given the schema's completeness.

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 ('Load and parse'), the resource ('.gitea/issue-workflow.yaml'), and the outcome ('Returns the parsed config and validation results'). It distinguishes itself from sibling tools like gitea_workflow_init or gitea_workflow_check_issues by focusing on configuration loading rather than initialization or issue checking.

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 prerequisites (e.g., whether the config file must exist), when it's appropriate (e.g., before other workflow operations), or what to do if the file is missing. Without such context, usage is implied but not explicit.

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