list_instructions
Retrieve all .instructions.md files from the prompts directory for managing VS Code chat modes and instructions efficiently.
Instructions
List all VS Code .instructions.md files in the prompts directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool handler function that executes the list_instructions tool. It retrieves the list of instructions from the InstructionManager and formats them into a readable string output including name, file, description, size, and content preview.def list_instructions() -> str: """List all VS Code .instructions.md files in the prompts directory.""" try: instructions = instruction_manager.list_instructions() if not instructions: return "No VS Code instruction files found in the prompts directory" result = f"Found {len(instructions)} VS Code instruction(s):\n\n" for instruction in instructions: result += f"Name: {instruction['name']}\n" result += f" File: {instruction['filename']}\n" if instruction["description"]: result += f" Description: {instruction['description']}\n" result += f" Size: {instruction['size']} bytes\n" if instruction["content_preview"]: result += f" Preview: {instruction['content_preview'][:100]}...\n" result += "\n" return result except Exception as e: return f"Error listing VS Code instructions: {str(e)}"
- src/mode_manager_mcp/tools/instruction_tools.py:52-65 (registration)Registers the list_instructions tool with the MCP server app, specifying name, description, tags, annotations for idempotence/read-only hints, title, return description, and meta category.@app.tool( name="list_instructions", description="List all VS Code .instructions.md files in the prompts directory.", tags={"public", "instruction"}, annotations={ "idempotentHint": True, "readOnlyHint": True, "title": "List Instructions", "returns": "Returns a formatted list of all instruction files with their names, descriptions, sizes, and content previews. If no instructions are found, returns an informational message.", }, meta={ "category": "instruction", }, )
- Helper method in InstructionManager class that scans the appropriate prompts directory for .instructions.md files, parses frontmatter and content preview, collects metadata into dicts, sorts by name, and returns the list used by the tool handler.def list_instructions(self, scope: MemoryScope = MemoryScope.user) -> List[Dict[str, Any]]: """ List all .instructions.md files in the prompts directory. Args: scope: "user" or "workspace" to determine which directory to list Returns: List of instruction file information """ instructions: List[Dict[str, Any]] = [] prompts_dir = self._get_prompts_dir(scope) if not prompts_dir.exists(): return instructions for file_path in prompts_dir.glob(f"*{INSTRUCTION_FILE_EXTENSION}"): try: frontmatter, content = parse_frontmatter_file(file_path) # Get preview of content (first 100 chars) content_preview = content.strip()[:100] if content.strip() else "" instruction_info = { "filename": file_path.name, "name": file_path.name.replace(INSTRUCTION_FILE_EXTENSION, ""), "path": str(file_path), "description": frontmatter.get("description", ""), "frontmatter": frontmatter, "content_preview": content_preview, "size": file_path.stat().st_size, "modified": file_path.stat().st_mtime, "scope": scope, } instructions.append(instruction_info) except Exception as e: logger.warning(f"Error reading instruction file {file_path}: {e}") continue # Sort by name instructions.sort(key=lambda x: x["name"].lower()) return instructions