update_mode
Modify an existing custom operational mode by updating its name, role definition, groups, or custom instructions using its unique slug identifier.
Instructions
Update an existing custom mode
Input 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 update_mode tool: retrieves config, locates mode by slug, applies partial updates, validates the updated mode using CustomModeSchema, persists changes to config file, and returns success message.
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 update_mode tool in the list_tools handler, including name, description, and detailed inputSchema for slug and partial updates.
{ 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 CustomModeSchema used to validate the updated mode configuration in the update_mode handler.
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 GroupSchema defining allowed tool groups, used within CustomModeSchema for update_mode validation.
const GroupSchema = z.union([ z.string(), z.tuple([ z.string(), z.object({ fileRegex: z.string(), description: z.string(), }), ]), ]); - src/index.ts:155-168 (helper)Helper method writeConfig used by update_mode to atomically persist the updated modes configuration to file.
private async writeConfig(config: z.infer<typeof CustomModesConfigSchema>) { try { await fs.writeFile( this.configPath, JSON.stringify(config, null, 2), 'utf-8' ); } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to write config: ${error instanceof Error ? error.message : String(error)}` ); } }