gitea_workflow_sync_status
Sync Gitea issue status labels with project board columns to maintain consistent workflow tracking across both systems.
Instructions
Synchronize issue status labels with project board column positions. Supports label-to-board, board-to-label, or bidirectional sync.
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 | |
| direction | Yes | Sync direction |
Implementation Reference
- src/tools/workflow.ts:851-930 (handler)Core implementation of the gitea_workflow_sync_status tool. This function handles bidirectional synchronization between Gitea issue status labels and project board column positions. It loads the workflow config if not provided, finds the relevant project board, fetches open issues, and uses BoardSyncManager to calculate necessary sync actions based on the specified direction.export async function workflowSyncStatus( ctx: WorkflowToolsContext, args: { owner?: string; repo?: string; config?: WorkflowConfig; direction: 'label-to-board' | 'board-to-label' | 'both'; } ): Promise<{ success: boolean; synced_count: number; actions: SyncAction[]; error?: string; }> { logger.debug({ args: { ...args, config: args.config ? '[provided]' : undefined } }, 'Syncing status'); 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, synced_count: 0, actions: [], error: loadResult.error || '无法加载配置', }; } config = loadResult.config; } const boardSyncManager = new BoardSyncManager(config); const actions: SyncAction[] = []; try { // 获取项目和列 const projects = await ctx.client.get<Array<{ id: number; title: string }>>( `/repos/${owner}/${repo}/projects` ); const workflowProject = projects.find((p) => p.title === config.board.name); if (!workflowProject) { return { success: false, synced_count: 0, actions: [], error: `未找到项目看板: ${config.board.name}`, }; } // 获取开放的 Issue const issues = await ctx.client.get<Issue[]>(`/repos/${owner}/${repo}/issues?state=open&limit=100`); // 计算同步操作(这里只返回建议的操作,实际同步需要更复杂的实现) for (const issue of issues) { const syncActions = boardSyncManager.calculateSyncActions(issue, null, args.direction); actions.push(...syncActions); } logger.info({ owner, repo, actions: actions.length }, 'Status sync calculated'); return { success: true, synced_count: actions.length, actions, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); logger.error({ owner, repo, error: errorMessage }, 'Failed to sync status'); return { success: false, synced_count: 0, actions: [], error: errorMessage, }; } }
- src/tools-registry/workflow-registry.ts:287-319 (registration)MCP tool registration for 'gitea_workflow_sync_status', including Zod input schema validation (owner, repo, direction), title, description, and wrapper handler that invokes the core workflowSyncStatus function from workflow.ts.mcpServer.registerTool( 'gitea_workflow_sync_status', { title: '状态双向同步', description: 'Synchronize issue status labels with project board column positions. Supports label-to-board, board-to-label, or bidirectional sync.', 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'), direction: z .enum(['label-to-board', 'board-to-label', 'both']) .describe('Sync direction'), }), }, async (args) => { try { const result = await WorkflowTools.workflowSyncStatus( { 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 definition for the tool, specifying optional owner/repo (resolved from context) and required direction enum for sync mode.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'), direction: z .enum(['label-to-board', 'board-to-label', 'both']) .describe('Sync direction'), }),