get_chatmode
Retrieve raw content from a .chatmode.md file in VS Code for managing chat modes and instructions with library integration using Mode Manager MCP.
Instructions
Get the raw content of a VS Code .chatmode.md file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | The filename of the chatmode to retrieve (with or without extension) |
Implementation Reference
- MCP tool handler function that wraps chatmode_manager.get_raw_chatmode to retrieve and return the raw content of a specified .chatmode.md file.def get_chatmode( filename: Annotated[str, "The filename of the chatmode to retrieve (with or without extension)"], ) -> str: """Get the raw content of a VS Code .chatmode.md file.""" try: if not filename.endswith(".chatmode.md"): filename += ".chatmode.md" raw_content = chatmode_manager.get_raw_chatmode(filename) return raw_content except Exception as e: return f"Error getting VS Code chatmode '{filename}': {str(e)}"
- src/mode_manager_mcp/tools/chatmode_tools.py:88-104 (registration)Registers the 'get_chatmode' tool with the MCP server, defining its metadata, tags, and call annotations including input parameters and return description.@app.tool( name="get_chatmode", description="Get the raw content of a VS Code .chatmode.md file.", tags={"public", "chatmode"}, annotations={ "idempotentHint": True, "readOnlyHint": True, "title": "Get Chatmode", "parameters": { "filename": "The filename of the chatmode to retrieve. If a full filename is provided, it will be used as-is. Otherwise, .chatmode.md will be appended automatically. You can provide just the name (e.g. my-chatmode) or the full filename (e.g. my-chatmode.chatmode.md)." }, "returns": "Returns the raw markdown content of the specified chatmode 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": "chatmode", }, )
- Defines the input schema (parameters: filename) and output description for the 'get_chatmode' tool.annotations={ "idempotentHint": True, "readOnlyHint": True, "title": "Get Chatmode", "parameters": { "filename": "The filename of the chatmode to retrieve. If a full filename is provided, it will be used as-is. Otherwise, .chatmode.md will be appended automatically. You can provide just the name (e.g. my-chatmode) or the full filename (e.g. my-chatmode.chatmode.md)." }, "returns": "Returns the raw markdown content of the specified chatmode 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 ChatModeManager that reads and returns the raw UTF-8 content of the specified .chatmode.md file, used by the tool handler.def get_raw_chatmode(self, filename: str) -> str: """ Get the raw file content of a specific chatmode file without any processing. Args: filename: Name of the .chatmode.md file Returns: Raw file content as string Raises: FileOperationError: If file cannot be read """ # Ensure filename has correct extension if not filename.endswith(".chatmode.md"): filename += ".chatmode.md" file_path = self.prompts_dir / filename if not file_path.exists(): raise FileOperationError(f"Chatmode file not found: {filename}") try: with open(file_path, "r", encoding="utf-8") as f: return f.read() except Exception as e: raise FileOperationError(f"Error reading raw chatmode file {filename}: {e}")