create_chatmode
Create a new VS Code chatmode file with custom instructions and tools to manage conversation workflows in development environments.
Instructions
Create a new VS Code .chatmode.md file with the specified description, content, and tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes | The filename for the new chatmode (with or without extension) | |
| description | Yes | A brief description of what this chatmode does | |
| content | Yes | The main content/instructions for the chatmode in markdown format | |
| tools | No |
Implementation Reference
- The MCP tool handler function implementing the core logic for creating a chatmode file. It processes input parameters, checks read-only mode, parses the tools list, calls the ChatModeManager, and returns a formatted success or error message.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)}"
- src/mode_manager_mcp/tools/chatmode_tools.py:15-34 (registration)Registration of the 'create_chatmode' tool using the @app.tool decorator. Includes name, description, tags, detailed input/output schema in annotations.parameters and annotations.returns, and metadata.@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", }, )
- Type annotations and descriptions for the input parameters of the create_chatmode handler, providing schema validation hints.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,
- Supporting helper method in ChatModeManager class that handles the actual creation of the .chatmode.md file: adds extension if needed, checks for existence, constructs frontmatter dict, and writes the file using write_frontmatter_file utility.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}")
- src/mode_manager_mcp/tools/__init__.py:18-25 (registration)Central registration function that invokes register_chatmode_tools() among others to register all MCP tools with the server.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()