Skip to main content
Glama
FOX2920

WeWork MCP Server

by FOX2920

analyze_project_tasks

Analyze tasks within a project to identify patterns, track progress, and optionally export data to CSV for further review.

Instructions

Phân tích các tasks trong dự án

Args:
    project_id: ID của dự án
    export_csv: Có xuất file CSV không (default: False)

Returns:
    Phân tích tasks dưới dạng dictionary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
export_csvNo

Implementation Reference

  • The core handler function for the 'analyze_project_tasks' MCP tool. It is decorated with @mcp.tool() for automatic registration, fetches project details and task analysis from WeWorkClient, processes data with pandas, computes task status statistics, converts to dictionary format, and optionally exports results to CSV.
    @mcp.tool()
    def analyze_project_tasks(project_id: str, export_csv: bool = False) -> Dict[str, Any]:
        """
        Phân tích các tasks trong dự án
        
        Args:
            project_id: ID của dự án
            export_csv: Có xuất file CSV không (default: False)
        
        Returns:
            Phân tích tasks dưới dạng dictionary
        """
        try:
            if not wework_client:
                return {'error': 'WeWork client not initialized'}
            
            logger.info(f"Analyzing tasks for project ID: {project_id}")
            
            # Lấy thông tin dự án
            project_info = wework_client.get_project_info(project_id)
            if not project_info:
                return {
                    'error': f'Không tìm thấy dự án với ID: {project_id}',
                    'success': False
                }
            
            # Phân tích tasks
            df = wework_client.get_project_analysis(project_id)
            
            if df.empty:
                return {
                    'success': True,
                    'project_name': project_info['name'],
                    'project_id': project_id,
                    'tasks': [],
                    'summary': {
                        'total_tasks': 0,
                        'completed_tasks': 0,
                        'in_progress_tasks': 0,
                        'failed_tasks': 0
                    }
                }
            
            # Tính thống kê
            status_counts = df['Trạng thái'].value_counts().to_dict() if 'Trạng thái' in df.columns else {}
            
            # Chuyển DataFrame thành dictionary
            tasks_data = df.to_dict(orient='records')
            
            # Xuất CSV nếu được yêu cầu
            csv_filename = None
            if export_csv:
                csv_filename = f"{project_info['name']}_tasks_analysis.csv"
                try:
                    df.to_csv(csv_filename, index=False, encoding='utf-8-sig')
                    logger.info(f"CSV exported to: {csv_filename}")
                except Exception as csv_error:
                    logger.error(f"Failed to export CSV: {csv_error}")
            
            result = {
                'success': True,
                'project_name': project_info['name'],
                'project_id': project_id,
                'tasks': tasks_data,
                'total_tasks': len(df),
                'summary': {
                    'total_tasks': len(df),
                    'completed_tasks': status_counts.get('Hoàn thành', 0),
                    'in_progress_tasks': status_counts.get('Đang thực hiện', 0),
                    'failed_tasks': status_counts.get('Thất bại', 0),
                    'status_breakdown': status_counts
                }
            }
            
            if csv_filename:
                result['csv_file'] = csv_filename
                
            return result
            
        except Exception as e:
            logger.error(f"Error in analyze_project_tasks: {e}")
            return {'error': str(e), 'success': False}
  • Input schema defined by function parameters with type hints (project_id: str, export_csv: bool = False) and output as Dict[str, Any]. Detailed in the docstring with Args and Returns sections.
    def analyze_project_tasks(project_id: str, export_csv: bool = False) -> Dict[str, Any]:
        """
        Phân tích các tasks trong dự án
        
        Args:
            project_id: ID của dự án
            export_csv: Có xuất file CSV không (default: False)
        
        Returns:
            Phân tích tasks dưới dạng dictionary
        """
  • The @mcp.tool() decorator registers the analyze_project_tasks function as an MCP tool in the FastMCP server.
    @mcp.tool()
  • Import of the analyze_project_tasks tool function from the MCP server module for use in the HTTP server endpoints.
    from wework_mcp_server import (
        search_projects, get_project_details, analyze_project_tasks,
  • Usage of the analyze_project_tasks function within the HTTP server's project analysis endpoint.
    result = analyze_project_tasks(project_id, export_csv)

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/FOX2920/Aplus-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server