Skip to main content
Glama

List Instructions

list_instructions
Read-onlyIdempotent

Retrieve all VS Code instruction files from the prompts directory to manage and access available guidance documents.

Instructions

List all VS Code .instructions.md files in the prompts directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'list_instructions' tool. It calls the instruction manager to get the list of instructions and formats them into a human-readable string with details like name, filename, 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)}"
  • The @app.tool decorator that registers the 'list_instructions' tool with the MCP server, specifying name, description, tags, annotations, and metadata.
    @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",
        },
    )
  • Schema definition in annotations: confirms no input parameters needed, specifies return type description, and provides hints like idempotent and read-only.
    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.",
    },
  • Supporting utility method in InstructionManager class that scans the prompts directory for all *.instructions.md files, parses frontmatter and content previews, collects metadata, and returns a sorted list of instruction dictionaries 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
Behavior3/5

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

Annotations already declare readOnlyHint=true and idempotentHint=true, indicating a safe, repeatable read operation. The description adds context about the specific directory and file type, but does not disclose additional behavioral traits like pagination, sorting, or error handling. No contradiction with annotations exists.

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 ('List all VS Code .instructions.md files') and specifies the location ('in the prompts directory'). There is no wasted wording, and every element earns its place.

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

Completeness5/5

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

Given the tool's low complexity (0 parameters, read-only), rich annotations (readOnlyHint, idempotentHint), and the presence of an output schema, the description is complete enough. It clearly states what the tool does without needing to explain return values or behavioral details covered elsewhere.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, with 100% schema description coverage. The description does not need to add parameter details, and it appropriately omits any parameter discussion. A baseline of 4 is applied for zero-parameter tools, as no compensation is needed.

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?

The description clearly states the specific action ('List all') and resource ('.instructions.md files in the prompts directory'), distinguishing it from siblings like 'get_instruction' (which retrieves a single instruction) or 'list_chatmodes' (which lists chatmodes instead). It precisely defines the scope and file type.

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

Usage Guidelines4/5

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

The description implies usage for retrieving all instruction files in a specific directory, but does not explicitly state when to use this tool versus alternatives like 'get_instruction' (for a single file) or 'list_chatmodes' (for a different resource type). It provides clear context but lacks explicit exclusions or named alternatives.

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