Skip to main content
Glama

update_instruction

Modify a VS Code .instructions.md file by updating its description or content using the specified instruction name. Simplifies instruction management in Mode Manager MCP.

Instructions

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

Input Schema

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

Implementation Reference

  • MCP tool 'update_instruction' handler: decorated with @app.tool providing schema via annotations and parameters, implements the tool logic by checking read-only mode, calling the core instruction_manager.update_instruction, and returning user-friendly success/error messages.
    @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", }, ) 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)}"
  • Supporting utility in InstructionManager class: the actual implementation delegated by the tool handler. Updates .instructions.md file by reading current frontmatter/content, optionally parsing new content for frontmatter, merging changes, and writing the file with automatic 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}")
  • Registration entry point that calls register_instruction_tools(), which defines and registers the update_instruction tool via @app.tool decorator.
    def register_all_tools() -> None: """Register all tools with the server.""" register_instruction_tools() register_chatmode_tools() register_library_tools() register_memory_tools() register_remember_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