Skip to main content
Glama

Update Instruction

update_instruction

Modify existing VS Code instruction files by updating descriptions or content to maintain accurate documentation for development workflows.

Instructions

Update an existing VS Code .instructions.md file with new description or content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instruction_nameYesThe name of the instruction to update (with or without extension)
descriptionNo
contentNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler function for 'update_instruction'. Checks read-only mode, calls InstructionManager.update_instruction with the provided content (description param is accepted but ignored), and returns success/error message.
    def update_instruction(
        instruction_name: Annotated[str, "The name of the instruction to update (with or without extension)"],
        description: Annotated[Optional[str], "Optional new description for the instruction"] = None,
        content: Annotated[Optional[str], "Optional new content for the instruction"] = None,
    ) -> str:
        """Update an existing VS Code .instructions.md file with new description or content."""
        if read_only:
            return "Error: Server is running in read-only mode"
        try:
            success = instruction_manager.update_instruction(instruction_name, content=content)
            if success:
                return f"Successfully updated VS Code instruction: {instruction_name}"
            else:
                return f"Failed to update VS Code instruction: {instruction_name}"
        except Exception as e:
            return f"Error updating VS Code instruction '{instruction_name}': {str(e)}"
  • Registers the 'update_instruction' MCP tool with the server, including schema definition for parameters (instruction_name, optional description, optional content) and returns description.
    @app.tool(
        name="update_instruction",
        description="Update an existing VS Code .instructions.md file with new description or content.",
        tags={"public", "instruction"},
        annotations={
            "idempotentHint": False,
            "readOnlyHint": False,
            "title": "Update Instruction",
            "parameters": {
                "instruction_name": "The name of the instruction to update. If .instructions.md extension is not provided, it will be added automatically.",
                "description": "Optional new description for the instruction. If not provided, the existing description will be kept.",
                "content": "Optional new content for the instruction. If not provided, the existing content will be kept.",
            },
            "returns": "Returns a success message if the instruction was updated, or an error message if the operation failed.",
        },
        meta={
            "category": "instruction",
        },
    )
  • Input/output schema definition for the 'update_instruction' tool via annotations: parameters for instruction_name (str), optional description (str), optional content (str); returns success/error str.
    annotations={
        "idempotentHint": False,
        "readOnlyHint": False,
        "title": "Update Instruction",
        "parameters": {
            "instruction_name": "The name of the instruction to update. If .instructions.md extension is not provided, it will be added automatically.",
            "description": "Optional new description for the instruction. If not provided, the existing description will be kept.",
            "content": "Optional new content for the instruction. If not provided, the existing content will be kept.",
        },
        "returns": "Returns a success message if the instruction was updated, or an error message if the operation failed.",
    },
  • Core helper method in InstructionManager that updates the .instructions.md file: ensures extension, reads current frontmatter/content, merges updates (note: tool only passes content, keeps frontmatter), rewrites file with backup.
    def update_instruction(
        self,
        instruction_name: str,
        frontmatter: Optional[Dict[str, Any]] = None,
        content: Optional[str] = None,
    ) -> bool:
        """
        Replace the content and/or frontmatter of an instruction file.
    
        This method is for full rewrites. To append to a section, use append_to_section.
    
        Args:
            instruction_name: Name of the .instructions.md file
            frontmatter: New frontmatter (optional)
            content: New content (optional, replaces all markdown content)
    
        Returns:
            True if successful
    
        Raises:
            FileOperationError: If file cannot be updated
        """
        # Ensure filename has correct extension
        instruction_name = self._ensure_instruction_extension(instruction_name)
    
        file_path = self.prompts_dir / instruction_name
    
        if not file_path.exists():
            raise FileOperationError(f"Instruction file not found: {instruction_name}")
    
        try:
            # Read current content
            current_frontmatter, current_content = parse_frontmatter_file(file_path)
    
            if content is not None and frontmatter is None:
                # We check if the content is actually including yaml
                frontmatter, content = parse_frontmatter(content)
    
            # Use provided values or keep current ones
            new_frontmatter = frontmatter if frontmatter is not None else current_frontmatter
            # If new content is provided, replace all markdown content
            if content is not None:
                new_content = content
            else:
                new_content = current_content
    
            success = write_frontmatter_file(file_path, new_frontmatter, new_content, create_backup=True)
            if success:
                logger.info(f"Updated instruction file with backup: {instruction_name}")
            return success
    
        except Exception as e:
            raise FileOperationError(f"Error updating instruction file {instruction_name}: {e}")
Behavior3/5

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

Annotations indicate this is a write operation (readOnlyHint: false) and not idempotent (idempotentHint: false). The description adds context about updating specific fields in a VS Code file, which aligns with annotations. However, it doesn't disclose additional behavioral traits like error conditions, file format expectations, or what happens when only one field is provided.

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 front-loads the core purpose. Every word contributes essential information without redundancy, making it appropriately sized for the tool's complexity.

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

Completeness3/5

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

Given the tool has an output schema (which reduces need to describe returns) and annotations cover basic safety, the description is minimally adequate. However, for a mutation tool with low schema coverage and no usage guidance, it should better explain parameter usage and error scenarios to be fully complete.

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 only 33%, with only 'instruction_name' documented. The description mentions 'description or content' as updatable fields, which maps to two of the three parameters, adding some semantic value beyond the schema. However, it doesn't explain parameter interactions or constraints, leaving gaps in understanding.

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 ('Update') and target resource ('existing VS Code .instructions.md file'), specifying what fields can be updated ('new description or content'). It distinguishes from sibling 'create_instruction' by focusing on updates, but doesn't explicitly differentiate from 'update_chatmode' or other update tools.

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 guidance is provided on when to use this tool versus alternatives like 'create_instruction' or 'update_chatmode'. The description implies it's for modifying existing files but doesn't specify prerequisites (e.g., file must exist) or when to choose other tools for similar operations.

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

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/NiclasOlofsson/mode-manager-mcp'

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