Skip to main content
Glama

generate

Create individual task files in the tasks/ directory from tasks.json. Specify the project root, optional output directory, and tag context to organize task management effectively.

Instructions

Generates individual task files in tasks/ directory based on tasks.json

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNoAbsolute path to the tasks file
outputNoOutput directory (default: same directory as tasks file)
projectRootYesThe directory of the project. Must be an absolute path.
tagNoTag context to operate on

Implementation Reference

  • Zod schema defining input parameters for the 'generate' MCP tool: output directory, project root, and optional tag.
    const GenerateSchema = z.object({
    	output: z
    		.string()
    		.optional()
    		.describe(
    			'Output directory for generated files (default: same directory as tasks file)'
    		),
    	projectRoot: z
    		.string()
    		.describe('The directory of the project. Must be an absolute path.'),
    	tag: z.string().optional().describe('Tag context to operate on')
    });
  • Core handler logic for the 'generate' tool. Parses args, resolves output dir, calls tmCore.tasks.generateTaskFiles, handles success/error, and returns formatted result.
    const { projectRoot, tag, output } = args;
    
    try {
    	log.info(`Generating task files with args: ${JSON.stringify(args)}`);
    
    	// Resolve output directory
    	const outputDir = output
    		? path.resolve(projectRoot, output)
    		: undefined;
    
    	// Call tm-core to generate task files
    	const result = await tmCore.tasks.generateTaskFiles({
    		tag,
    		outputDir
    	});
    
    	if (result.success) {
    		log.info(
    			`Successfully generated ${result.count} task files in ${result.directory}`
    		);
    		if (result.orphanedFilesRemoved > 0) {
    			log.info(
    				`Removed ${result.orphanedFilesRemoved} orphaned task files`
    			);
    		}
    	} else {
    		log.error(
    			`Failed to generate task files: ${result.error || 'Unknown error'}`
    		);
    	}
    
    	return handleApiResult({
    		result: {
    			success: result.success,
    			data: result.success
    				? {
    						message: `Successfully generated ${result.count} task file(s)`,
    						count: result.count,
    						directory: result.directory,
    						orphanedFilesRemoved: result.orphanedFilesRemoved
    					}
    				: undefined,
    			error: result.success ? undefined : { message: result.error || 'Unknown error' }
    		},
    		log,
    		projectRoot,
    		tag
    	});
    } catch (error: any) {
    	log.error(`Error in generate tool: ${error.message}`);
    	if (error.stack) {
    		log.debug(error.stack);
    	}
    	return handleApiResult({
    		result: {
    			success: false,
    			error: {
    				message: `Failed to generate task files: ${error.message}`
    			}
    		},
    		log,
    		projectRoot
    	});
    }
  • Registration function that defines and adds the 'generate' tool to the FastMCP server instance.
    export function registerGenerateTool(server: FastMCP) {
    	server.addTool({
    		name: 'generate',
    		description:
    			'Generates individual task files in tasks/ directory based on tasks.json. Only works with local file storage.',
    		parameters: GenerateSchema,
    		execute: withToolContext(
    			'generate',
    			async (args: GenerateArgs, { log, tmCore }: ToolContext) => {
    				const { projectRoot, tag, output } = args;
    
    				try {
    					log.info(`Generating task files with args: ${JSON.stringify(args)}`);
    
    					// Resolve output directory
    					const outputDir = output
    						? path.resolve(projectRoot, output)
    						: undefined;
    
    					// Call tm-core to generate task files
    					const result = await tmCore.tasks.generateTaskFiles({
    						tag,
    						outputDir
    					});
    
    					if (result.success) {
    						log.info(
    							`Successfully generated ${result.count} task files in ${result.directory}`
    						);
    						if (result.orphanedFilesRemoved > 0) {
    							log.info(
    								`Removed ${result.orphanedFilesRemoved} orphaned task files`
    							);
    						}
    					} else {
    						log.error(
    							`Failed to generate task files: ${result.error || 'Unknown error'}`
    						);
    					}
    
    					return handleApiResult({
    						result: {
    							success: result.success,
    							data: result.success
    								? {
    										message: `Successfully generated ${result.count} task file(s)`,
    										count: result.count,
    										directory: result.directory,
    										orphanedFilesRemoved: result.orphanedFilesRemoved
    									}
    								: undefined,
    							error: result.success ? undefined : { message: result.error || 'Unknown error' }
    						},
    						log,
    						projectRoot,
    						tag
    					});
    				} catch (error: any) {
    					log.error(`Error in generate tool: ${error.message}`);
    					if (error.stack) {
    						log.debug(error.stack);
    					}
    					return handleApiResult({
    						result: {
    							success: false,
    							error: {
    								message: `Failed to generate task files: ${error.message}`
    							}
    						},
    						log,
    						projectRoot
    					});
    				}
    			}
    		)
    	});
    }
  • Central tool registry mapping the 'generate' tool name to its registration function.
    generate: registerGenerateTool
  • Dynamic registration loop that invokes the generate tool's registration function (along with others) on the MCP server.
    toolsToRegister.forEach((toolName) => {
    	try {
    		const registerFunction = getToolRegistration(toolName);
    		if (registerFunction) {
    			registerFunction(server);
    			logger.debug(`Registered tool: ${toolName}`);
    			registeredTools.push(toolName);
    		} else {
    			logger.warn(`Tool ${toolName} not found in registry`);
    			failedTools.push(toolName);
    		}
    	} catch (error) {
    		if (error.message && error.message.includes('already registered')) {
    			logger.debug(`Tool ${toolName} already registered, skipping`);
    			registeredTools.push(toolName);
    		} else {
    			logger.error(`Failed to register tool ${toolName}: ${error.message}`);
    			failedTools.push(toolName);
    		}
    	}
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool generates files, implying a write operation, but doesn't disclose behavioral traits such as whether it overwrites existing files, requires specific permissions, handles errors, or has side effects. This is a significant gap for a tool that modifies the filesystem.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded and earns its place by clearly conveying the core functionality, making it easy for an agent to grasp quickly.

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?

Given the complexity of a file-generation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavior, error handling, output format, or how it interacts with the filesystem, which are crucial for safe and effective use. This leaves gaps that could hinder the agent's ability to invoke the tool correctly.

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 all four parameters. The description adds no additional meaning beyond the schema, such as explaining how parameters interact or providing examples. This meets the baseline of 3, as the schema handles the parameter documentation adequately.

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 action ('Generates') and the resource ('individual task files in tasks/ directory based on tasks.json'), making the purpose understandable. It doesn't explicitly differentiate from siblings like 'add_task' or 'update_task', which are about modifying tasks rather than generating files from a JSON source, but the distinction is implied rather than stated.

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?

No explicit guidance on when to use this tool versus alternatives is provided. The description implies usage when needing to generate task files from a tasks.json file, but it doesn't specify prerequisites, exclusions, or compare to siblings like 'initialize_project' or 'get_tasks'. This leaves the agent to infer context without clear direction.

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