get_team_productivity
Measure team productivity by analyzing task completion, collaboration, code quality, and other dimensions over a chosen time range.
Instructions
Analyze team productivity patterns and performance
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| team_members | No | Specific team member IDs to analyze (optional) | |
| project_id | No | Project context for analysis (optional) | |
| time_range | No | Time range for analysis | month |
| productivity_dimensions | No | Dimensions of productivity to measure |
Implementation Reference
- src/tools/analytics-insights.ts:170-223 (handler)Main handler function for get_team_productivity tool. Parses input (team_members, project_id, time_range, productivity_dimensions), fetches team data, analyzes each requested productivity dimension (task_completion, collaboration, code_quality, documentation, mentoring, innovation), calculates an overall score, and returns insights with improvement suggestions.
export const getTeamProductivity = requireAuth(async (args: any) => { const { team_members, project_id, time_range, productivity_dimensions } = GetTeamProductivitySchema.parse(args) logger.info('Analyzing team productivity', { team_members, project_id, time_range }) // Get team data const teamData = await getTeamData(team_members, project_id, time_range) const productivity: any = { time_range, team_size: teamData.members.length, project_context: project_id, analyzed_at: new Date().toISOString(), dimensions: {} } // Analyze each productivity dimension for (const dimension of productivity_dimensions) { try { switch (dimension) { case 'task_completion': productivity.dimensions.task_completion = analyzeTaskCompletion(teamData) break case 'collaboration': productivity.dimensions.collaboration = analyzeCollaboration(teamData) break case 'code_quality': productivity.dimensions.code_quality = analyzeCodeQuality(teamData) break case 'documentation': productivity.dimensions.documentation = analyzeDocumentation(teamData) break case 'mentoring': productivity.dimensions.mentoring = analyzeMentoring(teamData) break case 'innovation': productivity.dimensions.innovation = analyzeInnovation(teamData) break } } catch (error) { logger.error(`Failed to analyze ${dimension}:`, error) productivity.dimensions[dimension] = { error: 'Analysis failed' } } } // Calculate overall productivity score productivity.overall_score = calculateOverallProductivityScore(productivity.dimensions) // Generate team insights productivity.insights = generateTeamInsights(productivity.dimensions, teamData) productivity.improvement_suggestions = generateImprovementSuggestions(productivity.dimensions) return productivity }) - Zod schema defining input validation for get_team_productivity: optional team_members array, optional project_id, time_range enum (week/month/quarter) defaulting to 'month', and productivity_dimensions array of six options defaulting to task_completion and collaboration.
const GetTeamProductivitySchema = z.object({ team_members: z.array(z.string()).optional(), project_id: z.string().optional(), time_range: z.enum(['week', 'month', 'quarter']).default('month'), productivity_dimensions: z.array(z.enum(['task_completion', 'collaboration', 'code_quality', 'documentation', 'mentoring', 'innovation'])).default(['task_completion', 'collaboration']) }) - src/tools/analytics-insights.ts:129-161 (registration)Tool definition/registration object for get_team_productivity with name, description, and inputSchema (JSON Schema format) matching the Zod schema. Exported via analyticsInsightsTools and registered in src/index.ts.
export const getTeamProductivityTool: MCPTool = { name: 'get_team_productivity', description: 'Analyze team productivity patterns and performance', inputSchema: { type: 'object', properties: { team_members: { type: 'array', items: { type: 'string' }, description: 'Specific team member IDs to analyze (optional)' }, project_id: { type: 'string', description: 'Project context for analysis (optional)' }, time_range: { type: 'string', enum: ['week', 'month', 'quarter'], default: 'month', description: 'Time range for analysis' }, productivity_dimensions: { type: 'array', items: { type: 'string', enum: ['task_completion', 'collaboration', 'code_quality', 'documentation', 'mentoring', 'innovation'] }, default: ['task_completion', 'collaboration'], description: 'Dimensions of productivity to measure' } } } } - src/tools/analytics-insights.ts:786-790 (registration)Export mapping the string key 'get_team_productivity' to the getTeamProductivity handler function, which gets merged into allHandlers in src/index.ts and invoked by the CallToolRequestSchema handler.
export const analyticsInsightsHandlers = { get_project_analytics: getProjectAnalytics, get_team_productivity: getTeamProductivity, get_workspace_health: getWorkspaceHealth, generate_custom_report: generateCustomReport - Supporting helper functions called by the getTeamProductivity handler: getTeamData (fetches team data - currently placeholder), dimension analyzers (each returning mock scores), calculateOverallProductivityScore (averages all dimension scores), and insight/suggestion generators.
// Additional helper functions would be implemented here... async function getTeamData(teamMembers?: string[], projectId?: string, timeRange?: string): Promise<any> { return { members: [] } // Placeholder } function analyzeTaskCompletion(teamData: any): any { return { score: 85, trends: 'positive' } // Placeholder } function analyzeCollaboration(teamData: any): any { return { score: 72, interaction_frequency: 'high' } // Placeholder } function analyzeCodeQuality(teamData: any): any { return { score: 78, review_coverage: 85 } // Placeholder } function analyzeDocumentation(teamData: any): any { return { score: 65, coverage: 'medium' } // Placeholder } function analyzeMentoring(teamData: any): any { return { score: 60, active_relationships: 3 } // Placeholder } function analyzeInnovation(teamData: any): any { return { score: 70, new_ideas: 5 } // Placeholder } function calculateOverallProductivityScore(dimensions: any): number { const scores = Object.values(dimensions).map((d: any) => d.score).filter(s => typeof s === 'number') return scores.length > 0 ? Math.round(scores.reduce((sum: number, score: number) => sum + score, 0) / scores.length) : 0 } function generateTeamInsights(dimensions: any, teamData: any): string[] { return ['Team showing strong collaboration patterns', 'Documentation practices need improvement'] } function generateImprovementSuggestions(dimensions: any): string[] { return ['Implement pair programming sessions', 'Create documentation templates'] }