get_instruction
Retrieve raw content from a VS Code .instructions.md file to access detailed instructions for Mode Manager MCP. Specify the instruction name to fetch the required file directly.
Instructions
Get the raw content of a VS Code .instructions.md file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instruction_name | Yes | Name of the instruction (without extension) |
Implementation Reference
- The MCP tool handler function for 'get_instruction'. Ensures the filename extension and delegates to InstructionManager.get_raw_instruction() to retrieve and return the raw markdown content of the specified .instructions.md file.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)}"
- src/mode_manager_mcp/tools/instruction_tools.py:86-102 (registration)Registers the 'get_instruction' tool with the MCP server, including name, description, tags, input parameters schema, return description, 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", }, )
- Defines the input schema (parameters) and output description for the 'get_instruction' tool.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.", },
- Supporting method in InstructionManager that performs the actual file reading for raw instruction content, handling path resolution by scope, extension appending, existence check, and UTF-8 reading.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}")
- src/mode_manager_mcp/tools/__init__.py:18-24 (registration)Top-level registration function that calls register_instruction_tools(), which defines and registers the 'get_instruction' tool among others.def register_all_tools() -> None: """Register all tools with the server.""" register_instruction_tools() register_chatmode_tools() register_library_tools() register_memory_tools() register_remember_tools()