Skip to main content
Glama

Update Instruction

update_instruction

Update an existing VS Code instruction file by modifying its description or content.

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 handler function for the update_instruction tool. Calls instruction_manager.update_instruction() after checking read_only mode.
    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)}"
  • The tool registration/schema definition for update_instruction, including name, description, tags, annotations, and parameter definitions.
    @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",
        },
    )
  • The InstructionManager.update_instruction() method that performs the actual file update logic: parses frontmatter, merges new content, and writes 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}")
  • The top-level tool registration that calls register_instruction_tools(), which registers update_instruction.
    def register_all_tools() -> None:
        """Register all tools with the server."""
        register_instruction_tools()
        register_memory_tools()
        register_remember_tools()
Behavior3/5

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

Annotations already indicate readOnlyHint=false and idempotentHint=false. Description adds no additional behavioral context such as whether the tool overwrites or merges fields, or if there are side effects. No contradiction found.

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?

A single sentence that efficiently conveys the tool's purpose without extraneous detail. Every word earns its place.

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

Completeness4/5

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

For a simple update tool, the description covers the main purpose. An output schema exists to document return values. However, missing details on whether updates are overwrite or merge could be helpful.

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 33% (only instruction_name has description). Description mentions 'new description or content', mapping to two parameters, but does not add format or constraints beyond parameter names. Baseline score of 3 is appropriate given self-explanatory names.

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

Purpose5/5

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

Description uses specific verb 'update' and clearly identifies the resource as 'existing VS Code .instructions.md file'. It distinguishes from sibling tools like create_instruction, delete_instruction, and get_instruction.

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

Usage Guidelines3/5

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

Description implies usage context (updating existing instruction), but there is no explicit guidance on when to use this tool versus alternatives or when not to use it. No mention of prerequisites or exclusions.

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