switch_mode
Change the operational mode of the MCP server (architect, ask, code, debug, test) to align tasks with specific functionalities. Supports centralized SSH-based knowledge management.
Instructions
Switches to a specific mode
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | Name of the mode to switch to (architect, ask, code, debug, test) |
Implementation Reference
- src/server/tools/ModeTools.ts:7-20 (schema)Defines the tool metadata, description, and input schema for 'switch_mode'.{ name: 'switch_mode', description: 'Switches to a specific mode', inputSchema: { type: 'object', properties: { mode: { type: 'string', description: 'Name of the mode to switch to (architect, ask, code, debug, test)', }, }, required: ['mode'], }, },
- src/server/tools/ModeTools.ts:59-96 (handler)Primary handler function that validates the input mode and delegates to MemoryBankManager.switchMode, returning appropriate success/error responses.export function handleSwitchMode(memoryBankManager: MemoryBankManager, mode: string) { const validModes = ['architect', 'ask', 'code', 'debug', 'test']; if (!validModes.includes(mode)) { return { content: [ { type: 'text', text: `Invalid mode: ${mode}. Valid modes are: ${validModes.join(', ')}`, }, ], isError: true, }; } const success = memoryBankManager.switchMode(mode); if (!success) { return { content: [ { type: 'text', text: `Failed to switch to mode ${mode}. Make sure the .clinerules-${mode} file exists in the project directory.`, }, ], isError: true, }; } return { content: [ { type: 'text', text: `Successfully switched to mode ${mode}.`, }, ], }; }
- src/server/tools/index.ts:30-38 (registration)Registers the modeTools (including switch_mode) for tool listing requests.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ ...coreTools, ...progressTools, ...contextTools, ...decisionTools, ...modeTools, ], }));
- src/server/tools/index.ts:253-259 (registration)Routes switch_mode tool calls to the handleSwitchMode function in the main tool request handler.case 'switch_mode': { const { mode } = request.params.arguments as { mode: string }; if (!mode) { throw new McpError(ErrorCode.InvalidParams, 'Mode not specified'); } return handleSwitchMode(memoryBankManager, mode); }
- Underlying method invoked by the tool handler to perform the actual mode switch (minimal implementation).switchMode(mode: string): boolean { logger.debug('MemoryBankManager', `Switching to mode: ${mode}`); // Minimal implementation return true; }