Skip to main content
Glama

create_chatmode

Generate a VS Code .chatmode.md file by defining its filename, description, content, and tools. Simplifies chatmode creation for managing conversations and instructions within the Mode Manager MCP server.

Instructions

Create a new VS Code .chatmode.md file with the specified description, content, and tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesThe main content/instructions for the chatmode in markdown format
descriptionYesA brief description of what this chatmode does
filenameYesThe filename for the new chatmode (with or without extension)
toolsNo

Implementation Reference

  • The primary handler function for the MCP 'create_chatmode' tool. Processes input parameters, checks read-only mode, splits tools string into list, delegates to ChatModeManager.create_chatmode(), and formats success/error response.
    def create_chatmode( filename: Annotated[str, "The filename for the new chatmode (with or without extension)"], description: Annotated[str, "A brief description of what this chatmode does"], content: Annotated[str, "The main content/instructions for the chatmode in markdown format"], tools: Annotated[Optional[str], "Optional comma-separated list of tool names"] = None, ) -> str: """Create a new VS Code .chatmode.md file with the specified description, content, and tools.""" if read_only: return "Error: Server is running in read-only mode" try: tools_list = tools.split(",") if tools else None success = chatmode_manager.create_chatmode(filename, description, content, tools_list) if success: return f"Successfully created VS Code chatmode: {filename}" else: return f"Failed to create VS Code chatmode: {filename}" except Exception as e: return f"Error creating VS Code chatmode '{filename}': {str(e)}"
  • The @app.tool decorator that registers the 'create_chatmode' tool with the MCP server, including name, description, tags, metadata, and detailed parameter/return annotations serving as input/output schema.
    @app.tool( name="create_chatmode", description="Create a new VS Code .chatmode.md file with the specified description, content, and tools.", tags={"public", "chatmode"}, annotations={ "idempotentHint": False, "readOnlyHint": False, "title": "Create Chatmode", "parameters": { "filename": "The filename for the new chatmode. If .chatmode.md extension is not provided, it will be added automatically.", "description": "A brief description of what this chatmode does. This will be stored in the frontmatter.", "content": "The main content/instructions for the chatmode in markdown format.", "tools": "Optional comma-separated list of tool names that this chatmode should have access to.", }, "returns": "Returns a success message if the chatmode was created, or an error message if the operation failed.", }, meta={ "category": "chatmode", }, )
  • Core helper method in ChatModeManager class that implements the file creation logic: ensures .chatmode.md extension, checks for existing file, constructs frontmatter with description and tools, writes the markdown file using write_frontmatter_file, logs success, returns boolean.
    def create_chatmode( self, filename: str, description: str, content: str, tools: Optional[List[str]] = None, ) -> bool: """ Create a new chatmode file. Args: filename: Name for the new .chatmode.md file description: Description of the chatmode content: Chatmode content/instructions tools: List of tools (optional) Returns: True if successful Raises: FileOperationError: If file cannot be created """ # Ensure filename has correct extension if not filename.endswith(".chatmode.md"): filename += ".chatmode.md" file_path = self.prompts_dir / filename if file_path.exists(): raise FileOperationError(f"Chatmode file already exists: {filename}") # Create frontmatter frontmatter: Dict[str, Any] = {"description": description} if tools: frontmatter["tools"] = tools try: success = write_frontmatter_file(file_path, frontmatter, content, create_backup=False) if success: logger.info(f"Created chatmode file: {filename}") return success except Exception as e: raise FileOperationError(f"Error creating 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