Skip to main content
Glama

Create Instruction

create_instruction

Generate VS Code .instructions.md files with custom descriptions and markdown content to document procedures and workflows.

Instructions

Create a new VS Code .instructions.md file with the specified description and content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instruction_nameYesThe name for the new instruction (with or without extension)
descriptionYesA brief description of what this instruction does
contentYesThe main content/instructions in markdown format

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function for 'create_instruction'. Checks read-only mode and delegates core logic to InstructionManager.create_instruction, returning success/error messages.
    def create_instruction(
        instruction_name: Annotated[str, "The name for the new instruction (with or without extension)"],
        description: Annotated[str, "A brief description of what this instruction does"],
        content: Annotated[str, "The main content/instructions in markdown format"],
    ) -> str:
        """Create a new VS Code .instructions.md file with the specified description and content."""
        if read_only:
            return "Error: Server is running in read-only mode"
        try:
            success = instruction_manager.create_instruction(instruction_name, description, content)
            if success:
                return f"Successfully created VS Code instruction: {instruction_name}"
            else:
                return f"Failed to create VS Code instruction: {instruction_name}"
        except Exception as e:
            return f"Error creating VS Code instruction '{instruction_name}': {str(e)}"
  • Core helper method in InstructionManager that implements the file creation logic: ensures extension, checks existence, builds frontmatter with applyTo '**' and description, writes file using write_frontmatter_file.
    def create_instruction(self, instruction_name: str, description: str, content: str) -> bool:
        """
        Create a new instruction file.
    
        Args:
            instruction_name: Name for the new .instructions.md file
            description: Description of the instruction
            content: Instruction content
    
        Returns:
            True if successful
    
        Raises:
            FileOperationError: If file cannot be created
        """
    
        # Ensure filename has correct extension
        instruction_name = self._ensure_instruction_extension(instruction_name)
    
        file_path = self.prompts_dir / instruction_name
    
        if file_path.exists():
            raise FileOperationError(f"Instruction file already exists: {instruction_name}")
    
        # Create frontmatter with applyTo field so instructions are actually applied
        frontmatter: Dict[str, Any] = {"applyTo": "**", "description": description}
    
        try:
            success = write_frontmatter_file(file_path, frontmatter, content, create_backup=False)
            if success:
                logger.info(f"Created instruction file: {instruction_name}")
            return success
    
        except Exception as e:
            raise FileOperationError(f"Error creating instruction file {instruction_name}: {e}")
  • Triggers registration of all instruction tools, including 'create_instruction', via register_instruction_tools() call in register_all_tools().
    register_instruction_tools()
  • Tool schema definition in @app.tool annotations, specifying parameters (instruction_name, description, content), return type, and hints like non-idempotent and non-readonly.
    annotations={
        "idempotentHint": False,
        "readOnlyHint": False,
        "title": "Create Instruction",
        "parameters": {
            "instruction_name": "The name for the new instruction. If .instructions.md extension is not provided, it will be added automatically.",
            "description": "A brief description of what this instruction does. This will be stored in the frontmatter.",
            "content": "The main content/instructions in markdown format.",
        },
        "returns": "Returns a success message if the instruction was created, or an error message if the operation failed.",
    },
Behavior3/5

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

Annotations already indicate this is a write operation (readOnlyHint: false) and not idempotent (idempotentHint: false). The description adds that it creates a 'new' file, which reinforces the non-idempotent behavior, but doesn't disclose additional traits like file location, overwrite behavior, or error conditions. It provides some context beyond annotations but not rich behavioral details.

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 action and includes essential details (VS Code, .instructions.md file, parameters). There is no wasted text, and every word contributes to understanding the tool's purpose.

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 has annotations covering safety (readOnlyHint: false), an output schema exists (so return values are documented elsewhere), and schema coverage is 100%, the description is reasonably complete. It specifies the file type and creation action, but could benefit from more behavioral context (e.g., file path, error handling) for a write operation.

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%, so the schema fully documents all three parameters. The description mentions 'description and content' as parameters but adds no additional meaning beyond what's in the schema (e.g., format details, examples, or constraints). Baseline score of 3 is appropriate as the schema carries the parameter documentation burden.

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 ('Create a new VS Code .instructions.md file') and identifies the resource (instruction file) with the key parameters (description and content). It distinguishes from siblings like 'update_instruction' or 'delete_instruction' by specifying creation of a new file.

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 a new instruction file is needed, but provides no explicit guidance on when to use this versus alternatives like 'update_instruction' or prerequisites. It mentions the file type (.instructions.md) which gives some context, but lacks when-not-to-use scenarios or comparisons to sibling tools.

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