Skip to main content
Glama

use_tag

Switch task operation contexts by specifying a tag name with Task Master’s tool, enabling focused management of tasks within AI-driven development projects.

Instructions

Switch to a different tag context for task operations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNoPath to the tasks file (default: tasks/tasks.json)
nameYesName of the tag to switch to
projectRootYesThe directory of the project. Must be an absolute path.

Implementation Reference

  • Registers the 'use_tag' MCP tool with server.addTool(), including name, description, input schema (parameters), and execute handler that normalizes project root, finds tasks.json path, calls useTagDirect core logic, and handles the API result.
    export function registerUseTagTool(server) {
    	server.addTool({
    		name: 'use_tag',
    		description: 'Switch to a different tag context for task operations',
    		parameters: z.object({
    			name: z.string().describe('Name of the tag to switch to'),
    			file: z
    				.string()
    				.optional()
    				.describe('Path to the tasks file (default: tasks/tasks.json)'),
    			projectRoot: z
    				.string()
    				.describe('The directory of the project. Must be an absolute path.')
    		}),
    		execute: withNormalizedProjectRoot(async (args, { log, session }) => {
    			try {
    				log.info(`Starting use-tag with args: ${JSON.stringify(args)}`);
    
    				// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
    				let tasksJsonPath;
    				try {
    					tasksJsonPath = findTasksPath(
    						{ projectRoot: args.projectRoot, file: args.file },
    						log
    					);
    				} catch (error) {
    					log.error(`Error finding tasks.json: ${error.message}`);
    					return createErrorResponse(
    						`Failed to find tasks.json: ${error.message}`
    					);
    				}
    
    				// Call the direct function
    				const result = await useTagDirect(
    					{
    						tasksJsonPath: tasksJsonPath,
    						name: args.name,
    						projectRoot: args.projectRoot
    					},
    					log,
    					{ session }
    				);
    
    				return handleApiResult({
    					result,
    					log: log,
    					errorPrefix: 'Error switching tag',
    					projectRoot: args.projectRoot
    				});
    			} catch (error) {
    				log.error(`Error in use-tag tool: ${error.message}`);
    				return createErrorResponse(error.message);
    			}
    		})
    	});
    }
  • Core handler function useTagDirect that performs parameter validation, enables silent mode for MCP, calls the underlying tag-management useTag function with JSON output, processes the result, handles errors, and returns structured success/error response.
    export async function useTagDirect(args, log, context = {}) {
    	// Destructure expected args
    	const { tasksJsonPath, name, projectRoot } = args;
    	const { session } = context;
    
    	// Enable silent mode to prevent console logs from interfering with JSON response
    	enableSilentMode();
    
    	// Create logger wrapper using the utility
    	const mcpLog = createLogWrapper(log);
    
    	try {
    		// Check if tasksJsonPath was provided
    		if (!tasksJsonPath) {
    			log.error('useTagDirect called without tasksJsonPath');
    			disableSilentMode();
    			return {
    				success: false,
    				error: {
    					code: 'MISSING_ARGUMENT',
    					message: 'tasksJsonPath is required'
    				}
    			};
    		}
    
    		// Check required parameters
    		if (!name || typeof name !== 'string') {
    			log.error('Missing required parameter: name');
    			disableSilentMode();
    			return {
    				success: false,
    				error: {
    					code: 'MISSING_PARAMETER',
    					message: 'Tag name is required and must be a string'
    				}
    			};
    		}
    
    		log.info(`Switching to tag: ${name}`);
    
    		// Call the useTag function
    		const result = await useTag(
    			tasksJsonPath,
    			name,
    			{}, // options (empty for now)
    			{
    				session,
    				mcpLog,
    				projectRoot
    			},
    			'json' // outputFormat - use 'json' to suppress CLI UI
    		);
    
    		// Restore normal logging
    		disableSilentMode();
    
    		return {
    			success: true,
    			data: {
    				tagName: result.currentTag,
    				switched: result.switched,
    				previousTag: result.previousTag,
    				taskCount: result.taskCount,
    				message: `Successfully switched to tag "${result.currentTag}"`
    			}
    		};
    	} catch (error) {
    		// Make sure to restore normal logging even if there's an error
    		disableSilentMode();
    
    		log.error(`Error in useTagDirect: ${error.message}`);
    		return {
    			success: false,
    			error: {
    				code: error.code || 'USE_TAG_ERROR',
    				message: error.message
    			}
    		};
    	}
    }
  • Central tool registry maps 'use_tag' tool name to its registerUseTagTool function for dynamic server registration.
    import { registerUseTagTool } from './use-tag.js';
    import { registerValidateDependenciesTool } from './validate-dependencies.js';
    
    // Import TypeScript tools from apps/mcp
    import {
    	registerAutopilotAbortTool,
    	registerAutopilotCommitTool,
    	registerAutopilotCompleteTool,
    	registerAutopilotFinalizeTool,
    	registerAutopilotNextTool,
    	registerAutopilotResumeTool,
    	registerAutopilotStartTool,
    	registerAutopilotStatusTool,
    	registerGenerateTool,
    	registerGetTaskTool,
    	registerGetTasksTool,
    	registerSetTaskStatusTool
    } from '@tm/mcp';
    
    /**
     * Comprehensive tool registry mapping tool names to their registration functions
     * Used for dynamic tool registration and validation
     */
    export const toolRegistry = {
    	initialize_project: registerInitializeProjectTool,
    	models: registerModelsTool,
    	rules: registerRulesTool,
    	parse_prd: registerParsePRDTool,
    	'response-language': registerResponseLanguageTool,
    	analyze_project_complexity: registerAnalyzeProjectComplexityTool,
    	expand_task: registerExpandTaskTool,
    	expand_all: registerExpandAllTool,
    	scope_up_task: registerScopeUpTool,
    	scope_down_task: registerScopeDownTool,
    	get_tasks: registerGetTasksTool,
    	get_task: registerGetTaskTool,
    	next_task: registerNextTaskTool,
    	complexity_report: registerComplexityReportTool,
    	set_task_status: registerSetTaskStatusTool,
    	add_task: registerAddTaskTool,
    	add_subtask: registerAddSubtaskTool,
    	update: registerUpdateTool,
    	update_task: registerUpdateTaskTool,
    	update_subtask: registerUpdateSubtaskTool,
    	remove_task: registerRemoveTaskTool,
    	remove_subtask: registerRemoveSubtaskTool,
    	clear_subtasks: registerClearSubtasksTool,
    	move_task: registerMoveTaskTool,
    	add_dependency: registerAddDependencyTool,
    	remove_dependency: registerRemoveDependencyTool,
    	validate_dependencies: registerValidateDependenciesTool,
    	fix_dependencies: registerFixDependenciesTool,
    	list_tags: registerListTagsTool,
    	add_tag: registerAddTagTool,
    	delete_tag: registerDeleteTagTool,
    	use_tag: registerUseTagTool,
  • Input schema using Zod for validating tool parameters: name (string), file (optional string), projectRoot (string). Note: schema is embedded in registration.
    parameters: z.object({
    	name: z.string().describe('Name of the tag to switch to'),
    	file: z
    		.string()
    		.optional()
    		.describe('Path to the tasks file (default: tasks/tasks.json)'),
    	projectRoot: z
    		.string()
    		.describe('The directory of the project. Must be an absolute path.')
    }),
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions switching context but doesn't explain what this entails—whether it's a temporary change, affects other operations, has side effects, or requires specific permissions. This leaves significant gaps in understanding the tool's behavior.

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 wastes no space, making it easy to parse 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 context-switching operations and the lack of annotations and output schema, the description is insufficient. It doesn't clarify what 'tag context' means, how it impacts task operations, or what the expected outcome is, leaving critical gaps for an agent to use the tool effectively.

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?

The schema description coverage is 100%, providing clear documentation for all parameters (file, name, projectRoot). The description adds no additional meaning beyond the schema, such as explaining how 'name' relates to tags or the implications of switching context. This meets the baseline for high schema coverage.

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 ('Switch to') and the resource ('tag context for task operations'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_tags' or 'rename_tag' in terms of functionality, which prevents a perfect score.

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 like 'list_tags' or 'add_tag', nor does it mention any prerequisites or exclusions. It lacks context for decision-making, leaving the agent to infer usage from the name alone.

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