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'),
      }),
    },

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