list_chatmodes
Discover available VS Code chat modes by listing all .chatmode.md files in the prompts directory for easy selection and management.
Instructions
List all VS Code .chatmode.md files in the prompts directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main tool handler function that lists all .chatmode.md files by calling the chatmode_manager, formats the output as a readable string with name, file, description, size, and preview.def list_chatmodes() -> str: """List all VS Code .chatmode.md files in the prompts directory.""" try: chatmodes = chatmode_manager.list_chatmodes() if not chatmodes: return "No VS Code chatmode files found in the prompts directory" result = f"Found {len(chatmodes)} VS Code chatmode(s):\n\n" for cm in chatmodes: result += f"Name: {cm['name']}\n" result += f" File: {cm['filename']}\n" if cm["description"]: result += f" Description: {cm['description']}\n" result += f" Size: {cm['size']} bytes\n" if cm["content_preview"]: result += f" Preview: {cm['content_preview'][:100]}...\n" result += "\n" return result except Exception as e: return f"Error listing VS Code chatmodes: {str(e)}"
- src/mode_manager_mcp/tools/chatmode_tools.py:54-67 (registration)Registers the 'list_chatmodes' tool with the MCP app, including description, tags, annotations for schema/hints, and metadata.@app.tool( name="list_chatmodes", description="List all VS Code .chatmode.md files in the prompts directory.", tags={"public", "chatmode"}, annotations={ "idempotentHint": True, "readOnlyHint": True, "title": "List Chatmodes", "returns": "Returns a formatted list of all chatmode files with their names, descriptions, sizes, and content previews. If no chatmodes are found, returns an informational message.", }, meta={ "category": "chatmode", }, )
- Schema annotations defining the tool's behavior hints, title, and return description (no input parameters).annotations={ "idempotentHint": True, "readOnlyHint": True, "title": "List Chatmodes", "returns": "Returns a formatted list of all chatmode files with their names, descriptions, sizes, and content previews. If no chatmodes are found, returns an informational message.", },
- Underlying helper method in ChatModeManager class that scans the prompts directory for .chatmode.md files, parses frontmatter and content previews, and returns a list of structured dictionaries.def list_chatmodes(self) -> List[Dict[str, Any]]: """ List all .chatmode.md files in the prompts directory. Returns: List of chatmode file information """ chatmodes: List[Dict[str, Any]] = [] if not self.prompts_dir.exists(): return chatmodes for file_path in self.prompts_dir.glob("*.chatmode.md"): try: frontmatter, content = parse_frontmatter_file(file_path) # Get preview of content (first 100 chars) content_preview = content.strip()[:100] if content.strip() else "" chatmode_info = { "filename": file_path.name, "name": file_path.stem.replace(".chatmode", ""), "path": str(file_path), "description": frontmatter.get("description", ""), "tools": frontmatter.get("tools", []), "frontmatter": frontmatter, "content_preview": content_preview, "size": file_path.stat().st_size, "modified": file_path.stat().st_mtime, } chatmodes.append(chatmode_info) except Exception as e: logger.warning(f"Error reading chatmode file {file_path}: {e}") continue # Sort by name chatmodes.sort(key=lambda x: x["name"].lower()) return chatmodes