update_mode
Modify an existing custom mode by updating its name, role definition, groups, or custom instructions using the provided slug. Supports schema validation and real-time configuration changes for precise mode management.
Instructions
Update an existing custom mode
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | Slug of the mode to update | |
| updates | Yes |
Implementation Reference
- src/index.ts:395-433 (handler)Handler for the 'update_mode' tool. It reads the config, finds the mode by slug, merges updates, validates with CustomModeSchema, writes the config atomically, and returns success message or throws McpError on failure.case 'update_mode': { const { slug, updates } = request.params.arguments as { slug: string; updates: Partial<z.infer<typeof CustomModeSchema>>; }; const config = await this.readConfig(); const index = config.customModes.findIndex((m) => m.slug === slug); if (index === -1) { throw new McpError(ErrorCode.InvalidParams, `Mode not found: ${slug}`); } const updatedMode = { ...config.customModes[index], ...updates, }; try { CustomModeSchema.parse(updatedMode); } catch (error) { throw new McpError( ErrorCode.InvalidParams, `Invalid mode configuration: ${error instanceof Error ? error.message : String(error)}` ); } config.customModes[index] = updatedMode; await this.writeConfig(config); return { content: [ { type: 'text', text: `Mode "${updatedMode.name}" updated successfully`, }, ], }; }
- src/index.ts:247-290 (registration)Registration of the 'update_mode' tool in the ListTools response, defining its name, description, and detailed inputSchema matching the expected arguments.{ name: 'update_mode', description: 'Update an existing custom mode', inputSchema: { type: 'object', properties: { slug: { type: 'string', description: 'Slug of the mode to update', }, updates: { type: 'object', properties: { name: { type: 'string' }, roleDefinition: { type: 'string' }, groups: { type: 'array', items: { oneOf: [ { type: 'string' }, { type: 'array', items: [ { type: 'string' }, { type: 'object', properties: { fileRegex: { type: 'string' }, description: { type: 'string' }, }, required: ['fileRegex', 'description'], }, ], }, ], }, }, customInstructions: { type: 'string' }, }, }, }, required: ['slug', 'updates'], }, },
- src/index.ts:50-56 (schema)Zod schema used for validating the mode configuration in the update_mode handler (and others). Enforces structure and constraints on mode objects.const CustomModeSchema = z.object({ slug: z.string().regex(/^[a-z0-9-]+$/), name: z.string().min(1), roleDefinition: z.string().min(1), groups: z.array(GroupSchema), customInstructions: z.string().optional(), });
- src/index.ts:31-40 (schema)Zod schema for group definitions used within CustomModeSchema, supporting simple strings or tuples with fileRegex and description.const GroupSchema = z.union([ z.string(), z.tuple([ z.string(), z.object({ fileRegex: z.string(), description: z.string(), }), ]), ]);