Skip to main content
Glama

validate_mode

Check mode configuration for errors before saving to ensure proper setup in the Modes MCP Server.

Instructions

Validate a mode configuration without saving it

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeYes

Implementation Reference

  • The handler function for the 'validate_mode' tool. It extracts the mode object from the request arguments, attempts to parse/validate it using CustomModeSchema.parse(), and returns a success message or an error message with isError: true.
    case 'validate_mode': {
      const { mode } = request.params.arguments as {
        mode: z.infer<typeof CustomModeSchema>;
      };
    
      try {
        CustomModeSchema.parse(mode);
        return {
          content: [
            {
              type: 'text',
              text: 'Mode configuration is valid',
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Invalid mode configuration: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod schema (CustomModeSchema) defining the structure and validation rules for a custom mode configuration, used directly in the validate_mode handler for input validation.
    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:305-325 (registration)
    Tool registration in the list_tools handler, defining the name, description, and JSON input schema for the validate_mode tool.
    {
      name: 'validate_mode',
      description: 'Validate a mode configuration without saving it',
      inputSchema: {
        type: 'object',
        properties: {
          mode: {
            type: 'object',
            properties: {
              slug: { type: 'string' },
              name: { type: 'string' },
              roleDefinition: { type: 'string' },
              groups: { type: 'array' },
              customInstructions: { type: 'string' },
            },
            required: ['slug', 'name', 'roleDefinition', 'groups'],
          },
        },
        required: ['mode'],
      },
    },

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