Skip to main content
Glama

Get Instruction

get_instruction
Read-onlyIdempotent

Retrieve raw content from VS Code instruction files to access predefined guidance or commands for development workflows.

Instructions

Get the raw content of a VS Code .instructions.md file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instruction_nameYesName of the instruction (without extension)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'get_instruction' MCP tool. It ensures the correct file extension, calls instruction_manager.get_raw_instruction to fetch the raw content, and returns it or an error message.
    def get_instruction(
        instruction_name: Annotated[str, "Name of the instruction (without extension)"],
    ) -> str:
        """Get the raw content of a VS Code .instructions.md file."""
        try:
            # Ensure correct extension
            if not instruction_name.endswith(INSTRUCTION_FILE_EXTENSION):
                instruction_name += INSTRUCTION_FILE_EXTENSION
            raw_content = instruction_manager.get_raw_instruction(instruction_name)
            return raw_content
        except Exception as e:
            return f"Error getting VS Code instruction '{instruction_name}': {str(e)}"
  • Registration of the 'get_instruction' tool using @app.tool decorator, including name, description, tags, schema annotations for parameters and returns, and metadata.
    @app.tool(
        name="get_instruction",
        description="Get the raw content of a VS Code .instructions.md file.",
        tags={"public", "instruction"},
        annotations={
            "idempotentHint": True,
            "readOnlyHint": True,
            "title": "Get Instruction",
            "parameters": {
                "instruction_name": "The name of the instruction (without extension). If a full filename is provided, it will be used as-is. Otherwise, .instructions.md will be appended automatically. This tool is flexible: you can provide just the name (e.g. <instruction_name>) or the full filename (e.g. <instruction_name>.instructions.md). If the extension is missing, it will be added automatically."
            },
            "returns": "Returns the raw markdown content of the specified instruction file, or an error message if not found. Display recommendation: If the file is longer than 40 lines, show the first 10 lines, then '........', then the last 10 lines.",
        },
        meta={
            "category": "instruction",
        },
    )
  • Supporting helper method in InstructionManager class that reads and returns the raw content of the instruction file from the file system, used by the tool handler.
    def get_raw_instruction(self, instruction_name: str, scope: MemoryScope = MemoryScope.user) -> str:
        """
        Get the raw file content of a specific instruction file without any processing.
    
        Args:
            instruction_name: Name of the .instructions.md file
            scope: "user" or "workspace" to determine which directory to use
    
        Returns:
            Raw file content as string
    
        Raises:
            FileOperationError: If file cannot be read
        """
    
        # Ensure filename has correct extension
        instruction_name = self._ensure_instruction_extension(instruction_name)
    
        prompts_dir = self._get_prompts_dir(scope)
        file_path = prompts_dir / instruction_name
    
        if not file_path.exists():
            raise FileOperationError(f"Instruction file not found: {instruction_name}")
    
        try:
            with open(file_path, "r", encoding="utf-8") as f:
                return f.read()
    
        except Exception as e:
            raise FileOperationError(f"Error reading raw instruction file {instruction_name}: {e}")
Behavior3/5

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

Annotations already declare readOnlyHint=true and idempotentHint=true, indicating this is a safe, repeatable read operation. The description adds context about retrieving 'raw content' from a specific file type (.instructions.md), which clarifies the output format beyond what annotations provide. However, it doesn't mention potential behaviors like error handling for non-existent files or authentication requirements.

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, clear sentence that efficiently conveys the core functionality without unnecessary words. It's front-loaded with the main action and resource, making it easy to parse. Every word earns its place, and there's no redundancy or fluff.

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?

Given the tool's simplicity (1 parameter, read-only, idempotent), the presence of annotations covering safety, and an output schema (implied by 'Has output schema: true'), the description is reasonably complete. It specifies the file type and content format, which complements the structured data. For a basic retrieval tool, this provides adequate context, though it could benefit from mentioning sibling relationships.

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 100%, with the single parameter 'instruction_name' fully documented in the schema as 'Name of the instruction (without extension)'. The description doesn't add any additional parameter semantics beyond what the schema already provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate.

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 ('Get the raw content') and resource ('a VS Code .instructions.md file'), making the purpose immediately understandable. It distinguishes from siblings like 'list_instructions' (which lists) and 'create_instruction' (which creates), though it doesn't explicitly mention these distinctions. The specificity about the file type and format is helpful.

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?

The description implies usage when raw content of a specific instruction file is needed, but provides no explicit guidance on when to use this versus alternatives like 'list_instructions' (for listing available instructions) or 'get_chatmode' (for similar retrieval of chat modes). There's no mention of prerequisites, error conditions, or when not to use this tool.

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