enrich_issue
Automatically enhance GitHub issues by adding labels, priority, type, complexity, and effort estimates using AI analysis.
Instructions
AI-powered issue enrichment. Automatically adds labels, priority, type, complexity, and effort estimates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ||
| issueId | Yes | ||
| issueNumber | Yes | ||
| issueTitle | Yes | ||
| issueDescription | No | ||
| projectContext | No | ||
| autoApply | No |
Implementation Reference
- src/index.ts:659-689 (handler)Handler function that processes 'enrich_issue' tool calls, delegates to IssueEnrichmentService, and optionally auto-applies changesprivate async handleEnrichIssue(args: any): Promise<any> { try { const enrichment = await this.enrichmentService.enrichIssue({ projectId: args.projectId, issueId: args.issueId, issueTitle: args.issueTitle, issueDescription: args.issueDescription, projectContext: args.projectContext }); if (args.autoApply) { await this.enrichmentService.applyEnrichment({ projectId: args.projectId, issueNumber: args.issueNumber, enrichment, applyLabels: true }); } return { success: true, enrichment }; } catch (error) { this.logger.error("Failed to enrich issue:", error); throw new McpError( ErrorCode.InternalError, `Failed to enrich issue: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:507-508 (handler)Switch case dispatcher for 'enrich_issue' tool in main executeToolHandlercase "enrich_issue": return await this.handleEnrichIssue(args);
- Tool definition including name, description, input schema, and examples for 'enrich_issue'export const enrichIssueTool: ToolDefinition<EnrichIssueArgs> = { name: "enrich_issue", description: "AI-powered issue enrichment. Automatically adds labels, priority, type, complexity, and effort estimates.", schema: enrichIssueSchema as unknown as ToolSchema<EnrichIssueArgs>, examples: [ { name: "Enrich issue", description: "Add tags and metadata to an issue", args: { projectId: "PVT_kwDOLhQ7gc4AOEbH", issueId: "I_kwDOJrIzLs5eGXAT", issueNumber: 42, issueTitle: "Add user authentication", issueDescription: "Implement OAuth 2.0 authentication", autoApply: true } } ] };
- Zod input schema validation for 'enrich_issue' tool parametersexport const enrichIssueSchema = z.object({ projectId: z.string().min(1, "Project ID is required"), issueId: z.string().min(1, "Issue ID is required"), issueNumber: z.number().int().positive(), issueTitle: z.string().min(1, "Issue title is required"), issueDescription: z.string().optional(), projectContext: z.string().optional(), autoApply: z.boolean().default(false).optional() }); export type EnrichIssueArgs = z.infer<typeof enrichIssueSchema>;
- src/infrastructure/tools/ToolRegistry.ts:296-296 (registration)Registers the 'enrichIssueTool' in the central ToolRegistry singletonthis.registerTool(enrichIssueTool);
- Core enrichment logic using AI to analyze issue and suggest labels, priority, type, complexity, effort, etc.async enrichIssue(params: { projectId: string; issueId: string; issueTitle: string; issueDescription?: string; projectContext?: string; existingLabels?: string[]; milestones?: Array<{ title: string; description: string }>; }): Promise<IssueEnrichmentResult> { try { this.logger.info(`Enriching issue: ${params.issueTitle}`); const model = this.aiFactory.getModel('main') || this.aiFactory.getBestAvailableModel(); if (!model) { throw new Error('AI service is not available'); } const prompt = `You are an expert project manager. Analyze this issue and provide enrichment as JSON: {"suggestedLabels":[],"suggestedPriority":"medium","suggestedType":"task","complexity":"moderate","estimatedEffort":"2 hours","relatedIssues":[],"reasoning":"..."}`; const response = await generateText({ model, prompt: `${prompt}\n\nIssue: ${params.issueTitle}\nDescription: ${params.issueDescription || 'None'}`, temperature: 0.5, maxTokens: 1000 }); const jsonMatch = response.text.match(/\{[\s\S]*\}/); if (!jsonMatch) { throw new Error('Failed to parse AI response'); } const enrichment = JSON.parse(jsonMatch[0]); return { issueId: params.issueId, ...enrichment }; } catch (error) { this.logger.error(`Failed to enrich issue ${params.issueId}`, error); throw error; } }