Skip to main content
Glama

Create Instruction

create_instruction

Create a new .instructions.md file in VS Code with a specified name, description, and markdown content to manage custom instructions.

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

  • The actual implementation of create_instruction in InstructionManager class. Handles ensuring the .instructions.md extension, creates frontmatter with 'applyTo' and 'description' fields, and writes the 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}")
  • The MCP tool handler function for 'create_instruction'. Decorated with @app.tool(name='create_instruction'), it checks read-only mode, delegates to instruction_manager.create_instruction(), and returns a success/error message.
    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)}"
  • The tool registration decorator with name='create_instruction', description, tags, annotations (parameters & returns), and meta data. Registers the tool on the MCP app instance.
    @app.tool(
        name="create_instruction",
        description="Create a new VS Code .instructions.md file with the specified description and content.",
        tags={"public", "instruction"},
        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.",
        },
        meta={
            "category": "instruction",
        },
    )
  • The register_all_tools() function which calls register_instruction_tools() to register all instruction tools including create_instruction.
    def register_all_tools() -> None:
        """Register all tools with the server."""
        register_instruction_tools()
        register_memory_tools()
        register_remember_tools()
Behavior3/5

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

Annotations already declare readOnlyHint=false and idempotentHint=false, so the description does not need to repeat those. However, the description does not clarify what happens if the instruction_name already exists (e.g., overwrite or error), nor does it discuss side effects. It adds minor context by specifying the file type.

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, short sentence (14 words) that directly conveys the purpose. It is front-loaded with the action and resource, and every word is necessary. There is no redundancy.

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

Completeness3/5

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

While the tool has an output schema (not shown), the description does not explain the output or edge cases like naming conflicts or content limits. It covers the basic function but lacks completeness for a creation tool with multiple parameters and potential duplicates.

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 baseline is 3. The description mentions 'description and content' but adds no additional semantic details beyond the schema descriptions. No parameter-specific guidance is provided.

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 tool creates a new VS Code .instructions.md file with specified description and content. It uses specific verb 'create' and resource 'VS Code .instructions.md file', which distinguishes it from siblings like update_instruction or delete_instruction.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives such as update_instruction. There is no mention of prerequisites, constraints, or situations where using this tool is inappropriate. The description only implies usage for new instructions.

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