Skip to main content
Glama

complexity_report

Analyze and display task complexity metrics in a clear, readable format to help developers assess and manage their AI-driven project workflows effectively.

Instructions

Display the complexity analysis report in a readable format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNoPath to the report file (default: .taskmaster/reports/task-complexity-report.json)
projectRootYesThe directory of the project. Must be an absolute path.

Implementation Reference

  • Core handler function that reads the complexity report file using readComplexityReport, handles errors, and returns structured data or error.
    export async function complexityReportDirect(args, log) {
    	// Destructure expected args
    	const { reportPath } = args;
    	try {
    		log.info(`Getting complexity report with args: ${JSON.stringify(args)}`);
    
    		// Check if reportPath was provided
    		if (!reportPath) {
    			log.error('complexityReportDirect called without reportPath');
    			return {
    				success: false,
    				error: { code: 'MISSING_ARGUMENT', message: 'reportPath is required' }
    			};
    		}
    
    		// Use the provided report path
    		log.info(`Looking for complexity report at: ${reportPath}`);
    
    		// Generate cache key based on report path
    		const cacheKey = `complexityReport:${reportPath}`;
    
    		// Define the core action function to read the report
    		const coreActionFn = async () => {
    			try {
    				// Enable silent mode to prevent console logs from interfering with JSON response
    				enableSilentMode();
    
    				const report = readComplexityReport(reportPath);
    
    				// Restore normal logging
    				disableSilentMode();
    
    				if (!report) {
    					log.warn(`No complexity report found at ${reportPath}`);
    					return {
    						success: false,
    						error: {
    							code: 'FILE_NOT_FOUND_ERROR',
    							message: `No complexity report found at ${reportPath}. Run 'analyze-complexity' first.`
    						}
    					};
    				}
    
    				return {
    					success: true,
    					data: {
    						report,
    						reportPath
    					}
    				};
    			} catch (error) {
    				// Make sure to restore normal logging even if there's an error
    				disableSilentMode();
    
    				log.error(`Error reading complexity report: ${error.message}`);
    				return {
    					success: false,
    					error: {
    						code: 'READ_ERROR',
    						message: error.message
    					}
    				};
    			}
    		};
    
    		// Use the caching utility
    		try {
    			const result = await coreActionFn();
    			log.info('complexityReportDirect completed');
    			return result;
    		} catch (error) {
    			// Ensure silent mode is disabled
    			disableSilentMode();
    
    			log.error(`Unexpected error during complexityReport: ${error.message}`);
    			return {
    				success: false,
    				error: {
    					code: 'UNEXPECTED_ERROR',
    					message: error.message
    				}
    			};
    		}
    	} catch (error) {
    		// Ensure silent mode is disabled if an outer error occurs
    		disableSilentMode();
    
    		log.error(`Error in complexityReportDirect: ${error.message}`);
    		return {
    			success: false,
    			error: {
    				code: 'UNEXPECTED_ERROR',
    				message: error.message
    			}
    		};
    	}
    }
  • Zod schema defining input parameters: optional file path and required projectRoot.
    parameters: z.object({
    	file: z
    		.string()
    		.optional()
    		.describe(
    			`Path to the report file (default: ${COMPLEXITY_REPORT_FILE})`
    		),
    	projectRoot: z
    		.string()
    		.describe('The directory of the project. Must be an absolute path.')
    }),
  • Function that registers the 'complexity_report' tool with the MCP server using server.addTool, including name, description, parameters schema, and execute handler.
    export function registerComplexityReportTool(server) {
    	server.addTool({
    		name: 'complexity_report',
    		description: 'Display the complexity analysis report in a readable format',
    		parameters: z.object({
    			file: z
    				.string()
    				.optional()
    				.describe(
    					`Path to the report file (default: ${COMPLEXITY_REPORT_FILE})`
    				),
    			projectRoot: z
    				.string()
    				.describe('The directory of the project. Must be an absolute path.')
    		}),
    		execute: withNormalizedProjectRoot(async (args, { log, session }) => {
    			try {
    				log.info(
    					`Getting complexity report with args: ${JSON.stringify(args)}`
    				);
    
    				const resolvedTag = getCurrentTag(args.projectRoot);
    
    				const pathArgs = {
    					projectRoot: args.projectRoot,
    					complexityReport: args.file,
    					tag: resolvedTag
    				};
    
    				const reportPath = findComplexityReportPath(pathArgs, log);
    				log.info('Reading complexity report from path: ', reportPath);
    
    				if (!reportPath) {
    					return createErrorResponse(
    						'No complexity report found. Run task-master analyze-complexity first.'
    					);
    				}
    
    				const result = await complexityReportDirect(
    					{
    						reportPath: reportPath
    					},
    					log
    				);
    
    				if (result.success) {
    					log.info('Successfully retrieved complexity report');
    				} else {
    					log.error(
    						`Failed to retrieve complexity report: ${result.error.message}`
    					);
    				}
    
    				return handleApiResult({
    					result,
    					log: log,
    					errorPrefix: 'Error retrieving complexity report',
    					projectRoot: args.projectRoot
    				});
    			} catch (error) {
    				log.error(`Error in complexity-report tool: ${error.message}`);
    				return createErrorResponse(
    					`Failed to retrieve complexity report: ${error.message}`
    				);
    			}
    		})
    	});
    }
  • Tool registry mapping 'complexity_report' to its registration function for dynamic tool setup.
    complexity_report: registerComplexityReportTool,
  • Re-exports the complexityReportDirect function for use across modules.
    import { complexityReportDirect } from './direct-functions/complexity-report.js';
    import { copyTagDirect } from './direct-functions/copy-tag.js';
    import { deleteTagDirect } from './direct-functions/delete-tag.js';
    import { expandAllTasksDirect } from './direct-functions/expand-all-tasks.js';
    import { expandTaskDirect } from './direct-functions/expand-task.js';
    import { fixDependenciesDirect } from './direct-functions/fix-dependencies.js';
    import { initializeProjectDirect } from './direct-functions/initialize-project.js';
    import { listTagsDirect } from './direct-functions/list-tags.js';
    import { modelsDirect } from './direct-functions/models.js';
    import { moveTaskCrossTagDirect } from './direct-functions/move-task-cross-tag.js';
    import { moveTaskDirect } from './direct-functions/move-task.js';
    import { nextTaskDirect } from './direct-functions/next-task.js';
    import { parsePRDDirect } from './direct-functions/parse-prd.js';
    import { removeDependencyDirect } from './direct-functions/remove-dependency.js';
    import { removeSubtaskDirect } from './direct-functions/remove-subtask.js';
    import { removeTaskDirect } from './direct-functions/remove-task.js';
    import { renameTagDirect } from './direct-functions/rename-tag.js';
    import { researchDirect } from './direct-functions/research.js';
    import { scopeDownDirect } from './direct-functions/scope-down.js';
    import { scopeUpDirect } from './direct-functions/scope-up.js';
    import { setTaskStatusDirect } from './direct-functions/set-task-status.js';
    import { updateSubtaskByIdDirect } from './direct-functions/update-subtask-by-id.js';
    import { updateTaskByIdDirect } from './direct-functions/update-task-by-id.js';
    import { updateTasksDirect } from './direct-functions/update-tasks.js';
    import { useTagDirect } from './direct-functions/use-tag.js';
    import { validateDependenciesDirect } from './direct-functions/validate-dependencies.js';
    
    // Re-export utility functions
    export { findTasksPath } from './utils/path-utils.js';
    
    // Use Map for potential future enhancements like introspection or dynamic dispatch
    export const directFunctions = new Map([
    	['getCacheStatsDirect', getCacheStatsDirect],
    	['parsePRDDirect', parsePRDDirect],
    	['updateTasksDirect', updateTasksDirect],
    	['updateTaskByIdDirect', updateTaskByIdDirect],
    	['updateSubtaskByIdDirect', updateSubtaskByIdDirect],
    	['setTaskStatusDirect', setTaskStatusDirect],
    	['nextTaskDirect', nextTaskDirect],
    	['expandTaskDirect', expandTaskDirect],
    	['addTaskDirect', addTaskDirect],
    	['addSubtaskDirect', addSubtaskDirect],
    	['removeSubtaskDirect', removeSubtaskDirect],
    	['analyzeTaskComplexityDirect', analyzeTaskComplexityDirect],
    	['clearSubtasksDirect', clearSubtasksDirect],
    	['expandAllTasksDirect', expandAllTasksDirect],
    	['removeDependencyDirect', removeDependencyDirect],
    	['validateDependenciesDirect', validateDependenciesDirect],
    	['fixDependenciesDirect', fixDependenciesDirect],
    	['complexityReportDirect', complexityReportDirect],
    	['addDependencyDirect', addDependencyDirect],
    	['removeTaskDirect', removeTaskDirect],
    	['initializeProjectDirect', initializeProjectDirect],
    	['modelsDirect', modelsDirect],
    	['moveTaskDirect', moveTaskDirect],
    	['moveTaskCrossTagDirect', moveTaskCrossTagDirect],
    	['researchDirect', researchDirect],
    	['addTagDirect', addTagDirect],
    	['deleteTagDirect', deleteTagDirect],
    	['listTagsDirect', listTagsDirect],
    	['useTagDirect', useTagDirect],
    	['renameTagDirect', renameTagDirect],
    	['copyTagDirect', copyTagDirect],
    	['scopeUpDirect', scopeUpDirect],
    	['scopeDownDirect', scopeDownDirect]
    ]);
    
    // Re-export all direct function implementations
    export {
    	getCacheStatsDirect,
    	parsePRDDirect,
    	updateTasksDirect,
    	updateTaskByIdDirect,
    	updateSubtaskByIdDirect,
    	setTaskStatusDirect,
    	nextTaskDirect,
    	expandTaskDirect,
    	addTaskDirect,
    	addSubtaskDirect,
    	removeSubtaskDirect,
    	analyzeTaskComplexityDirect,
    	clearSubtasksDirect,
    	expandAllTasksDirect,
    	removeDependencyDirect,
    	validateDependenciesDirect,
    	fixDependenciesDirect,
    	complexityReportDirect,
    	addDependencyDirect,
    	removeTaskDirect,
    	initializeProjectDirect,
    	modelsDirect,
    	moveTaskDirect,
    	moveTaskCrossTagDirect,
    	researchDirect,
    	addTagDirect,
    	deleteTagDirect,
    	listTagsDirect,
    	useTagDirect,
    	renameTagDirect,
    	copyTagDirect,
    	scopeUpDirect,
    	scopeDownDirect
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions the output format ('readable format') but doesn't disclose whether this is a read-only operation, what happens if the file doesn't exist, or any performance/error considerations. The description is too vague for a tool that presumably reads and formats data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and includes a useful detail about formatting. Every part of the sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 2 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what a 'complexity analysis report' contains, how the display differs from raw data, or what happens if inputs are invalid. The lack of behavioral context makes it incomplete for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description adds no parameter-specific information beyond what's in the schema, maintaining the baseline score of 3. It doesn't explain how parameters interact or their impact on the report display.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('display') and resource ('complexity analysis report'), and specifies the output format ('readable format'). It doesn't explicitly differentiate from sibling tools like 'analyze_project_complexity', but the focus on display vs. analysis is implied.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'analyze_project_complexity' for generating reports or clarify if this is for viewing pre-existing reports versus creating new ones.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/eyaltoledano/claude-task-master'

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