Skip to main content
Glama

get_chatmode

Retrieve raw content from VS Code .chatmode.md files to access and manage chatmode configurations for development workflows.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYesThe filename of the chatmode to retrieve (with or without extension)

Implementation Reference

  • The handler function that executes the 'get_chatmode' tool logic, retrieving raw content via chatmode_manager.
    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)}"
  • Registers the 'get_chatmode' tool with the MCP app, defining its metadata, description, parameters, and return info.
    @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",
        },
    )
  • Core helper method in ChatModeManager that reads the raw content of a .chatmode.md file from disk.
    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}")

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