Skip to main content
Glama

create_mode

Generate custom operational modes by defining unique slugs, display names, role capabilities, allowed tool groups, and optional instructions on the Modes MCP Server for enhanced mode management.

Instructions

Create a new custom mode

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customInstructionsNoOptional additional instructions for the mode
groupsYesArray of allowed tool groups
nameYesDisplay name for the mode
roleDefinitionYesDetailed description of the mode's role and capabilities
slugYesUnique slug for the mode (lowercase letters, numbers, and hyphens)

Implementation Reference

  • Handler for the 'create_mode' tool: parses arguments as CustomModeSchema, checks for existing slug, validates with Zod, appends to config array, writes config file atomically, returns success message.
    case 'create_mode': { const mode = request.params.arguments as z.infer<typeof CustomModeSchema>; const config = await this.readConfig(); if (config.customModes.some((m) => m.slug === mode.slug)) { throw new McpError( ErrorCode.InvalidParams, `Mode with slug "${mode.slug}" already exists` ); } try { CustomModeSchema.parse(mode); } catch (error) { throw new McpError( ErrorCode.InvalidParams, `Invalid mode configuration: ${error instanceof Error ? error.message : String(error)}` ); } config.customModes.push(mode); await this.writeConfig(config); return { content: [ { type: 'text', text: `Mode "${mode.name}" created successfully`, }, ], }; }
  • Zod schema defining the structure and validation rules for a custom mode object, used for input validation in create_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(), });
  • Zod schema for mode groups, supporting simple string groups or tuples with fileRegex and description, referenced by CustomModeSchema.
    const GroupSchema = z.union([ z.string(), z.tuple([ z.string(), z.object({ fileRegex: z.string(), description: z.string(), }), ]), ]);
  • src/index.ts:198-246 (registration)
    Tool registration in list_tools response, defining name, description, and JSON inputSchema matching the Zod CustomModeSchema.
    { name: 'create_mode', description: 'Create a new custom mode', inputSchema: { type: 'object', properties: { slug: { type: 'string', description: 'Unique slug for the mode (lowercase letters, numbers, and hyphens)', }, name: { type: 'string', description: 'Display name for the mode', }, roleDefinition: { type: 'string', description: 'Detailed description of the mode\'s role and capabilities', }, groups: { type: 'array', items: { oneOf: [ { type: 'string' }, { type: 'array', items: [ { type: 'string' }, { type: 'object', properties: { fileRegex: { type: 'string' }, description: { type: 'string' }, }, required: ['fileRegex', 'description'], }, ], }, ], }, description: 'Array of allowed tool groups', }, customInstructions: { type: 'string', description: 'Optional additional instructions for the mode', }, }, required: ['slug', 'name', 'roleDefinition', 'groups'], }, },
  • Helper function to atomically write the modes configuration to the JSON file, used by create_mode after updating the config.
    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)}` ); } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ccc0168/modes-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server