gitea_workflow_load_config
Load and parse workflow configuration from .gitea/issue-workflow.yaml to validate and retrieve structured workflow settings for repository management.
Instructions
Load and parse the workflow configuration from .gitea/issue-workflow.yaml. Returns the parsed config and validation results.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | No | Repository owner. Uses context if not provided | |
| repo | No | Repository name. Uses context if not provided |
Implementation Reference
- src/tools/workflow.ts:103-154 (handler)The handler function that loads the .gitea/issue-workflow.yaml configuration file from the repository, decodes it from base64, parses it using parseConfig, validates it with validateConfig, and returns the config or error.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}`, }; } }
- src/tools-registry/workflow-registry.ts:55-84 (registration)Registers the 'gitea_workflow_load_config' tool in the MCP server, provides input schema validation using Zod, description, and wraps the handler function with error handling and response formatting.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, }; } } );
- Zod input schema defining optional owner and repo parameters for the tool.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'), }), },